Histogram of image data

`[`

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`

,`map`

)`X`

with color
map `map`

. The histogram has one bin for each entry in the
color map.

For grayscale images, the

`n`

bins of the histogram are each half-open intervals of width*A*/(*n*−1). In particular, the*p*th bin is the half-open interval$$\frac{A(p-1.5)}{(n-1)}-B\le x<\frac{A(p-0.5)}{(n-1)}-B,$$

where

*x*is the intensity value. The scale factor*A*and offset*B*depend on the type of the image class as follows:double single int8 int16 int32 uint8 uint16 uint32 logical *A*1 1 255 65535 4294967295 255 65535 4294967295 1 *B*0 0 128 32768 2147483648 0 0 0 0 To display the histogram from

`counts`

and`binLocations`

, use the command

.`stem`

(binLocations,counts)