How to show histogram of RGB image in Matlab?

后端 未结 5 1132
离开以前
离开以前 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:42

    An histogarm plot will have number of pixels for the intensity levels. Yours is an rgb image. So you first need to convert it to an intensity image.

    The code here will be:

    input = imread ('sample.jpeg');
    
    input=rgb2gray(input);
    
    imhist(input);
    
    imshow(input);
    

    You will be able to get the histogram of the image.

提交回复
热议问题