Matlab 程序错误,在线等高手解答!!!!!!!

>> I=imread('一号.jpg');
I1=imadjust(I,[0.1 0.5],[0 1]);
I2=histeq(I1);
I3=imadd(I2,50);
I4=im2bw(I3,0.25);
I5= ~im2bw(I4);
figure(1);
I6=bwmorph(I5,'close');
I7=bwmorph(I6,'remove');
I8=ordfilt2(I7,5,ones(3,3));
subplot(3,3,1);
imshow(I);
title('原图');
subplot(3,3,2)
imshow(I1);
title('对比度扩展图');
subplot(3,3,3);
imshow(I2);
title('直方图均衡图');
subplot(3,3,4);
imshow(I3);
title('加法运算图');
subplot(3,3,5)
imshow(I4);
title('二值化图');
subplot(3,3,6)
imshow(I5)
title('图像求反图')
subplot(3,3,7)
imshow(I6)
title('闭合图')
subplot(3,3,8)
imshow(I7)
title('边界图')
subplot(3,3,9)
imshow(I8)
title('中值滤波图')
??? Error using ==> iptcheckinput
Function HISTEQ expected its first input, I, to be two-dimensional.

Error in ==> histeq at 71
iptcheckinput(a,{'uint8','uint16','double','int16','single'}, ...

原因很简单啊,你读入的jpg图像是RGB三个通道的,而函数histeq的输入只能是单通道的图像。
可以把第三句话改为:
I2(:,:,1)=histeq(I1(:,:,1));
I2(:,:,2)=histeq(I1(:,:,2));
I2(:,:,3)=histeq(I1(:,:,3));
这样对三个通道分别进行直方图均衡
温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-06-18
一号.jpg不是灰度图像;直方图均衡是用来处理灰度图的 I=imread('一号.jpg'); 后面加一句 I=rgb2gray(I);