matlab的这个错误怎么解决?

??? Error using ==> run
Error using ==> images\private\checkinput>check_attributes
Function ORDFILT2 expected its first input argument, A,
to be two-dimensional.
源程序

I=imread('tatanic.jpg');

I1=imnoise(I,'gaussian');

I2=imnoise(I,'salt & pepper',0.02);

I3=imnoise(I,'speckle');

J1=medfilt2(I1,[3,3]);

J2=medfilt2(I2,[3,3]);

J3=medfilt2(I3,[3,3]);

figure,imshow(J1);

title('tatanic高斯噪声—3*3中值滤波')

figure,imshow(J2);

title('tatanic椒盐噪声—3*3中值滤波')

figure,imshow(J3);

title('tatanic乘性噪声—3*3中值滤波')

medfilt2()只能处理二维的图像,你可以考虑将三维的jpg图像转为二维的grayscale图像,如下:

I=imread('tatanic.jpg');

I = .2989*I(:,:,1)...
+.5870*I(:,:,2)...
+.1140*I(:,:,3);

I1=imnoise(I,'gaussian');

I2=imnoise(I,'salt & pepper',0.02);

I3=imnoise(I,'speckle');

J1=medfilt2(I1,[3,3]);

J2=medfilt2(I2,[3,3]);

J3=medfilt2(I3,[3,3]);

figure,imshow(J1);

title('tatanic高斯噪声—3*3中值滤波')

figure,imshow(J2);

title('tatanic椒盐噪声—3*3中值滤波')

figure,imshow(J3);

title('tatanic乘性噪声—3*3中值滤波')
温馨提示:答案为网友推荐,仅供参考
相似回答