???Errorusing==> iptcheckinput Function IMHIST expected its first input, I or X, to be two-dimensional.Errorin==> imhist>parse_inputs at 275 iptcheckinput(a,{'double','uint8','logical','uint16','int16','single'},...Errorin==> imhist at 57[a, n, isScaled, top, map]= parse_inputs(varargin{:});
After running size(input), I see my input image is of size 300x200x3. I know the third dimension is for color channel, but is there any way to show histogram of this? Thanks.
回答1:
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).
I pefere to plot the histogram for Red, Green and Blue in one plot:
%Splitinto RGB ChannelsRed= 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');
回答3:
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.
Remember to include mat2gray(); because it converts the matrix A to the intensity image grayImg. The returned matrix grayImg contains values in the range 0.0 (black) to 1.0 (full intensity or white).
回答5:
Histogram is useful to analyze pixel distribution in an image. Histogram plots number of pixel in an image with respect to intensity value.