Image 直方图均衡化在MATLAB中的帮助

Image 直方图均衡化在MATLAB中的帮助,image,matlab,image-processing,image-conversion,Image,Matlab,Image Processing,Image Conversion,我的代码如下所示: G= histeq(imread('F:\Thesis\images\image1.tif')); figure,imshow(G); 我收到的错误消息如下,我不知道为什么会出现: Error using histeq Expected input number 1, I, to be two-dimensional. Error in histeq (line 68) validateattributes(a,{'uint8','uint16','double','in

我的代码如下所示:

G= histeq(imread('F:\Thesis\images\image1.tif'));
figure,imshow(G);
我收到的错误消息如下,我不知道为什么会出现:

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

Error in histeq (line 68)
validateattributes(a,{'uint8','uint16','double','int16','single'}, ...

Error in testFile1 (line 8)
G= histeq(imread('F:\Thesis\images\image1.tif'));

你的图像很可能是彩色的<代码>histeq仅适用于灰度图像。根据您想做什么,有三个选项可供选择。您可以将图像转换为灰度,可以单独对每个通道进行直方图均衡,或者更好的方法是将图像转换为HSV颜色空间,对V或值分量进行直方图均衡,然后再转换回RGB。我倾向于选择彩色图像的最后一个选项。因此,一种方法是增强灰度图像,另两种方法是增强彩色图像

选项#1-转换为灰度,然后进行均衡 用于将图像转换为灰度,然后均衡图像

选项2-分别均衡每个通道 通过每个通道循环并均衡

选项#3-转换为HSV,直方图均衡V通道,然后转换回
使用该功能将彩色图像转换为HSV。然后,我们在V或值通道上使用直方图均衡化,然后使用将HSV转换回RGB。请注意,
hsv2rgb
的输出将是一个
double
类型的图像,因此假设原始输入图像是
uint8
,使用该函数将
double
转换回
uint8

,显然,您的图像不是二维的,即灰度。
G = imread('F:\Thesis\images\image1.tif');
G = histeq(rgb2gray(G));
figure; imshow(G);
G = imread('F:\Thesis\images\image1.tif');
for i = 1 : size(G, 3)
    G(:,:,i) = histeq(G(:,:,i));
end
figure; imshow(G);
G = imread('F:\Thesis\images\images1.tif');
Gh = rgb2hsv(G);
Gh(:,:,3) = histeq(Gh(:,:,3));
G = im2uint8(hsv2rgb(Gh));
figure; imshow(G);