Histogram

3 次查看(过去 30 天)
Muhammad
Muhammad 2011-3-16
编辑: Leepakshi 2025-6-3
please tell me the way to display histogram of colored image? thanks

回答(2 个)

Walter Roberson
Walter Roberson 2011-3-16
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?

Leepakshi
Leepakshi 2025-6-3
编辑:Leepakshi 2025-6-3
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

类别

Help CenterFile Exchange 中查找有关 Histograms 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by