You are here : matlabImage Processingimhist

imhist() - Image Processing

imhist(I) calculates
the histogram for the intensity image I and displays
a plot of the histogram. The number of bins in the histogram is determined
by the image type.imhist(I,n) calculates
the histogram, where n specifies the number of
bins used in the histogram. n also specifies the
length of the colorbar displayed at the bottom of the histogram plot.imhist(X,map) displays
a histogram for the indexed image X. This histogram
shows the distribution of pixel values above a colorbar of the colormap map.
The colormap must be at least as long as the largest index in X.
The histogram has one bin for each entry in the colormap.[counts,binLocations]
= imhist(I) returns the histogram
counts in counts and the bin locations in binLocations so
that stem(binLocations,counts) shows the histogram.
For indexed images, imhist returns the histogram
counts for each colormap entry. The length of counts is
the same as the length of the colormap.example[counts,binLocations]
= imhist(gpuarrayI,___) performs
the histogram calculation on a GPU.  The input image and the return
values are gpuArrays. This syntax requires the Parallel Computing Toolbox™.
When the input image is a gpuArray, imhist does
not automatically display the histogram. To display the histogram,
use stem(binLocations,counts).Code Generation support:
Yes.MATLAB Function Block support:


imhist(I) exampleimhist(I,n)imhist(X,map)[counts,binLocations]
= imhist(I)[counts,binLocations]
= imhist(gpuarrayI,___) example


Calculate HistogramOpen This Example
I = imread('pout.tif');

Calculate Histogram on a GPUCreate array of class uint16.I = gpuArray(imread('pout.tif'));Calculate histogram. Because imhist does
not automatically display the plot of the histogram when run on a
GPU, this example uses stem to plot the histogram.[counts,x] = imhist(I);

Output / Return Value


Alternatives / See Also