How to show histogram of RGB image in Matlab?

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

    I pefere to plot the histogram for Red, Green and Blue in one plot:

    %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');
    

提交回复
热议问题