- 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
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (2)
Samayochita
el 28 de Mzo. de 2025
Editada: Samayochita
el 28 de Mzo. de 2025
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 comentarios
DGM
el 28 de Mzo. de 2025
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 comentarios
Ver también
Categorías
Más información sobre Histograms en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!