How to show histogram of RGB image in Matlab?

后端 未结 5 1136
离开以前
离开以前 2020-12-05 18:46

I read an image in matlab using

input = imread (\'sample.jpeg\');

Then I do

imhist(input);

It gives this

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-05 19:28

    imhist displays a histogram of a grayscale or binary images. Use rgb2gray on the image, or use imhist(input(:,:,1)) to see one of the channel at a time (red in this example).

    Alternatively you can do this:

    hist(reshape(input,[],3),1:max(input(:))); 
    colormap([1 0 0; 0 1 0; 0 0 1]);
    

    to show the 3 channels simultaneously...

提交回复
热议问题