永发信息网

matlab7.0中的edge函数总是报错,我的代码和错误提示信息如下,请大侠们帮帮忙

答案:2  悬赏:70  手机版
解决时间 2021-02-25 13:10
  • 提问者网友:不爱我么
  • 2021-02-24 20:46
I=IMREAD('剪纸.jpg');
I2=imnoise(I,'salt & pepper',0.3);
%I3=imnoise(I,'gaussian',0,100); %加均值为0,方差为100的高斯噪声
figure
subplot(1,2,1);imshow(I);title('灰白原图');
subplot(1,2,2);imshow(I2);title('加椒盐噪声的图像');
%subplot(1,3,3);imshow(I3);title('加椒盐和高斯噪声的图像');
%BJ2=edge(I2,'prewitt'); %prewitt图像边缘提取
BW2=edge(I,'prewitt');
figure
subplot(1,2,1);imshow(BW2);title('含噪图像边界');

运行后总提示
??? Error using ==> images\private\checkinput>check_attributes
Function EDGE expected its first input argument, I,
to be two-dimensional.
Error in ==> images\private\checkinput at 37
check_attributes(A, attributes, function_name, variable_name, ...

Error in ==> edge>parse_inputs at 502
checkinput(I,{'double','logical','uint8','uint16'},...

Error in ==> edge at 161
[a,method,thresh,sigma,H,kx,ky] = parse_inputs(varargin{:});
最佳答案
  • 五星知识达人网友:七十二街
  • 2021-02-24 21:20
报错信息说了,你要把图像变成灰度图像。
I=imread('剪纸.jpg');
I=rgb2gray(I);
I2=imnoise(I,'salt & pepper',0.3);
%I3=imnoise(I,'gaussian',0,100); %加均值为0,方差为100的高斯噪声
figure
subplot(1,2,1);imshow(I);title('灰白原图');
subplot(1,2,2);imshow(I2);title('加椒盐噪声的图像');
%subplot(1,3,3);imshow(I3);title('加椒盐和高斯噪声的图像');
%BJ2=edge(I2,'prewitt'); %prewitt图像边缘提取
BW2=edge(I,'prewitt');
figure
subplot(1,2,1);imshow(BW2);title('含噪图像边界');
全部回答
  • 1楼网友:持酒劝斜阳
  • 2021-02-24 22:05
你得把你代码发出来才能让人帮你看问题啊
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯