- You could convert the image to grayscale.
- You could histogram equalize each channel individually
- You could convert the image into the LAB or HSV colour space, histogram equalize the L or V component, then convert back into RGB. Applying histogram equalization to each RGB channel separately can distort colors because it processes each channel independently.I tend to prefer the last option for colour images because it enhances contrast while preserving colors. Therefore, one method will be an enhanced grayscale image, and the other two will be an enhanced colour image.
Histogram Equalization in RGB
5 ビュー (過去 30 日間)
古いコメントを表示
Hi,
How can I practice HistogramEqualization on RGB at 3 channels? What does it has available function to do this?, I know it just support to GrayScale.
Thanks!
0 件のコメント
回答 (2 件)
Samayochita
2025 年 3 月 28 日
編集済み: Samayochita
2025 年 3 月 28 日
Hi Jony,
In MATLAB, the “histeq” function works only on grayscale images. There are three options available to you depending on what you want to do:
Convert to grayscale then equalize:
G = imread('image1.jpg');
G = histeq(rgb2gray(G));
figure; imshow(G);
Equalize each channel individually:
G = imread('image1.jpg');
for i = 1 : size(G, 3)
G(:,:,i) = histeq(G(:,:,i));
end
figure; imshow(G);
Convert to HSV, histogram equalize the V channel then convert back:
G = imread('image1.jpg');
Gh = rgb2hsv(G);
Gh(:,:,3) = histeq(Gh(:,:,3));
G = im2uint8(hsv2rgb(Gh));
figure; imshow(G);
The “rgb2hsv” function is used to convert a coloured image to HSV.
Note that the output of "hsv2rgb" will be a “double” type image and so assuming that the original input image was “uint8”, use the “im2uint8” function to convert from “double” back to “uint8”.
For more information on “rgb2grey”, “hsv2rgb”, “rgb2hsv”, “histeq” functions, please refer to the following documentation links:
I hope this helps you perform histogram equalization in your image.
0 件のコメント
DGM
2025 年 3 月 28 日
The following links show global and adaptive histogram equalization as applied in RGB, HSV, unconstrained LAB, and chroma-constrained LCHab, using basic tools and third-party convenience tools.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Histograms についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!