报错信息说了,你要把图像变成灰度图像。
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('含噪图像边界');