主要内容

imhist

Histogram of image data

Description

[计数,binLocations] = imhist(I)calculates the histogram for the grayscale imageI。这imhistfunction returns the histogram counts in计数和垃圾箱位置binLocations。这number of bins in the histogram is determined by the image type.

[计数,binLocations] = imhist(I,n)specifies the number of bins,n, used to calculate the histogram.

[计数,binLocations] = imhist(X,cmap)calculates the histogram for the indexed imageXwith colormapcmap。这直方图has one bin for each entry in the colormap.

example

imhist(___)显示直方图的曲线图。如果输入图像是索引图像,则直方图显示了Colormap的颜色栏上方的像素值的分布cmap

Examples

collapse all

Read a grayscale image into the workspace.

I = imread('pout.tif');

Display a histogram of the image. SinceIis grayscale, by default the histogram will have 256 bins.

imhist(I)

Figure contains 2 axes objects. Axes object 1 contains an object of type stem. Axes object 2 contains 2 objects of type image, line.

加载3-D数据集。

loadmristack

Display the histogram of the data. Since the image is grayscale,imhistuses 256 bins by default.

imhist(mristack)

Figure contains 2 axes objects. Axes object 1 contains an object of type stem. Axes object 2 contains 2 objects of type image, line.

Input Arguments

collapse all

灰度图像,指定为任何维度的数字数组。如果图像具有数据类型single或者double, then values must be in the range [0, 1]. IfIhas values outside the range [0, 1], then you can use therescale.function to rescale values to the expected range.

数据类型s:single|double|int8|INT16|int32|uint8|uint16|uint32|logical

被指定为正整数的箱数。如果Iis a grayscale image, thenimhistuses a default value of 256 bins. IfIis a binary image, thenimhist使用两个垃圾箱。

Example:50

数据类型s:single|double|int8|INT16|int32|int64|uint8|uint16|uint32|uint64

索引图像,指定为任何维度的数字数组。

数据类型s:single|double|uint8|uint16|logical

Colormap associated with indexed imageX, specified as ac-by-3 numeric matrix with values in the range [0, 1]. Each row is a three-element RGB triplet that specifies the red, green, and blue components of a single color of the colormap.这colormap must be at least as long as the largest index inX

数据类型s:double

Output Arguments

collapse all

直方图计数,返回为数字数组。如果针对索引图像计算直方图,则X,然后是长度计数与Colormap的长度相同,cmap

Bin locations, returned as a numeric array.

尖端

  • For grayscale images, then直方图的垃圾箱是宽度的半开放间隔A/(n-1)。In particular, thepthbin is the half-open interval

    A ( p 1.5 ) ( n 1 ) B x < A ( p 0.5 ) ( n 1 ) B ,

    wherexis the intensity value. The scale factorA和偏移B依赖于图像类的类型如下:

    数据类型 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计数binLocations,使用命令stem(宾馆,计数)

Extended Capabilities

See Also

||

在R2006A之前介绍