Histeq matlab 不工作

Histeq matlab not working

我想对 SPOT5 图像进行直方图均衡。我正在尝试使用 histeq 命令。为什么这不起作用?

这是我的输入和错误:

>>I = imread('C:\Users\windows 8\Downloads\ori.tif');

>>imshow( I(:,:,1:3) )

Warning: Image is too big to fit on screen; displaying at 17% In imuitools\private\initSize at 72In imshow at 283

>> J = histeq(I);

Error using histeq Expected input number 1, I, to be two-dimensional.

我对 还是个新手。我真的 感谢一些帮助。提前谢谢你

出现警告是因为 or.tif 的图像尺寸比您的屏幕大。它只是告诉您它没有以全尺寸显示。这不会影响直方图均衡。

直方图均衡的错误是因为 matlab 期望 I 是一个二维矩阵。您的 TIFF 文件是一个 3D 矩阵,它具有宽度 x 高度 x 颜色。

根据您尝试通过直方图均衡实现的目标,您可能需要先将图像转换为灰度图像

greyI = rgb2gray( I(:,:,1:3) );
J = histeq( greyI );

或者依次对三个颜色平面应用直方图均衡化。

J = zeros( size( I ) );
J(:,:,1) = histeq( squeeze( I(:,:,1) ) );
J(:,:,2) = histeq( squeeze( I(:,:,2) ) );
J(:,:,3) = histeq( squeeze( I(:,:,3) ) );
% Next line if you have alpha channel
if( size( J, 3 ) == 4 )
    J(:,:,4) = histeq( squeeze( I(:,:,4) ) );
end