MATLAB: How to get Color Histogram of an Image

colordigital image processinghistogramimage processingImage Processing Toolbox

Hello everyone,I want to get Color Histogram from a image.What is the Code to get color histogram.what is the difference between HISTOGRAM and COLOR HISTOGRAM.How to show it on screen.

Best Answer

Histogram is displaying the distribution of data. Color histogram shows distribution for each band.
%Split into RGB Channels
Red = image(:,:,1);
Green = image(:,:,2);
Blue = image(:,:,3);
%Get histValues for each channel
[yRed, x] = imhist(Red);
[yGreen, x] = imhist(Green);
[yBlue, x] = imhist(Blue);
%Plot them together in one plot
plot(x, yRed, 'Red', x, yGreen, 'Green', x, yBlue, 'Blue');