FUNCTION REFERENCE
imhist
Histogram of a grayscale image.
Histogram of a grayscale image.
Syntax
[counts, x] = imhist(I)Syntax
[counts, x] = imhist(I, n)Syntax
imhist(...)Counts the elements of the 2-D image I in n bins (default 256, or 2 for a logical image) spread evenly over the range of the class: [0, 1] for double, single and logical images, [intmin, intmax] for integer images. x holds the bin locations (column vector, double) and counts the numbers of elements (column vector, double). With A the width of the class range, bin p (1-based) holds the values v with A(p-1.5)/(n-1) <= v - intmin < A(p-0.5)/(n-1), so every bin is centred on its location. Values outside the class range (double images beyond [0, 1]) count in the first or last bin; NaN is not counted. Without outputs, imhist draws the counts as a stem plot over the class range.
Example
[counts, x] = imhist(uint8([0 1 2 255 128]), 3) % counts = [3; 1; 1], x = [0; 127.5; 255]Example
counts = imhist([0 0.25 0.5 0.75 1], 5)' % [1 1 1 1 1]Example
[c, x] = imhist(logical([1 0 1 1])) % c = [1; 3], x = [0; 1]Differences from MATLAB: no indexed images with a colormap (imhist(X, map)) and no colorbar strip under the plot. N-D input is an error.
These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.