Histogram
3 views (last 30 days)
Show older comments
please tell me the way to display histogram of colored image? thanks
0 Comments
Answers (2)
Walter Roberson
on 16 Mar 2011
In order to display a histogram of something, there has to be a measurable property that can be quantized. Unfortunately, color images have multiple measurable properties that can be quantized, so you are going to have to figure out which property you want to construct the histogram of.
Is this, by the way, one of those questions where you have to construct 72 or 144 bins based upon the HSV values?
0 Comments
Leepakshi
on 3 Jun 2025
Edited: Leepakshi
on 3 Jun 2025
Hi Muhammad,
To display the histogram of a colored image in MATLAB, plot separate histograms for each color channel (Red, Green, and Blue).
Refer to following example:
img = imread('sampleImage.jpg');
redChannel = img(:,:,1);
greenChannel = img(:,:,2);
blueChannel = img(:,:,3);
figure;
hold on;
histogram(redChannel(:), 256, 'FaceColor', 'r', 'EdgeColor', 'r');
histogram(greenChannel(:), 256, 'FaceColor', 'g', 'EdgeColor', 'g');
histogram(blueChannel(:), 256, 'FaceColor', 'b', 'EdgeColor', 'b');
hold off;
This code extracts each color channel from the RGB image and plots their histograms overlaid in red, green, and blue colors, showing the distribution of pixel intensities for each channel separately.
Hope this helps!
Thanks
0 Comments
See Also
Categories
Find more on Histograms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!