matlab7.0中的edge函数总是报错,我的代码和错误提示信息如下,请大侠们帮帮忙
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{:});
答案:报错信息说了,你要把图像变成灰度图像。
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('含噪图像边界');
上一个:matlab求解三元回归方程。 请把代码贴出来看下
下一个:Matlab数字图像处理,要求详细解释代码,每个函数都要解释.这个是对图像求幅值谱和相位谱,并对其进行重构.