MATLAB: How to draw histogram of an RGB image

histogram of rgb image

Best Answer

image_test=imread('Baboon.jpeg');
red_plane=image_test(:,:,1);
green_plane=image_test(:,:,2);
blue_plane=image_test(:,:,3);
[red_data pixel_level]=imhist(red_plane);
[green_data pixel_level]=imhist(green_plane);
[blue_data pixel_level]=imhist(blue_plane);
bar(pixel_level, red_data,'r');
hold on;
bar(pixel_level, green_data,'g');
bar(pixel_level, blue_data,'b');
Note: You can plot all in single matlab line code.
pic11.png
Related Question