imhist
Histogram of image data
Syntax
Description
[
calculates the histogram for the
grayscale image counts
,binLocations
]
= imhist(I
)I
. The imhist
function
returns the histogram counts in counts
and the bin
locations in binLocations
. The number of bins in the
histogram is determined by the image type.
[
specifies the number of bins, counts
,binLocations
] = imhist(I
,n
)n
, used to calculate the
histogram.
[
calculates the histogram for the indexed image counts
,binLocations
] = imhist(X
,cmap
)X
with
colormap cmap
. The histogram has one bin for each entry in
the colormap.
Examples
Input Arguments
Output Arguments
Tips
For grayscale images, the
n
bins of the histogram are each half-open intervals of width A/(n−1). In particular, the pth bin is the half-open intervalwhere x is the intensity value. The scale factor A and offset B depend on the data type of the image as follows:
Data Type A B double
1
0
single
1
0
int8
255
128
int16
65,535
32,768
int32
4,294,967,295
2,147,483,648
uint8
255
0
uint16
65,535
0
uint32
4,294,967,295
0
logical
1
0
To display the histogram from
counts
andbinLocations
, use the command
.stem
(binLocations,counts)