({{, (RefLink[ImageLevels, paclet:ref/ImageLevels])[image] 
gives a list of pixel values and counts for each channel in image. }, {, (RefLink[ImageLevels, paclet:ref/ImageLevels])[image,bspec]
bins pixel values using bin specification bspec.}, {, (RefLink[ImageLevels, paclet:ref/ImageLevels])[image,bspec,range]
gives counts for bins in the given range.}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[ImageLevels, paclet:ref/ImageLevels]) returns a list of levels for each channel in the form {{(Subscript[lev, 1]),(Subscript[k, 1])},{(Subscript[lev, 2]),(Subscript[k, 2])},…}, where (Subscript[k, i]) counts the values satisfying (Subscript[lev, i])≤x<(Subscript[lev, i+1]), except for the last bin, which uses (Subscript[lev, i])≤x≤(Subscript[lev, i+1]).

Binary images have the form {{0,(Subscript[n, 0])},{1,(Subscript[n, 1])}}.

(RefLink[ImageLevels, paclet:ref/ImageLevels]) works with arbitrary grayscale and multichannel 2D and 3D images.

The binning specification bspec, which by default uses 256 levels, can be any of the following:

The range can be of the following forms:

The following defaults are used for range, depending on the image color space. The ranges are chosen to include the subspace of the "RGB" color space.

The following options can be specified:

Possible settings for (RefLink[Method, paclet:ref/Method]) include:

OpenersPrimaryExamplesSection(Spacer1)Examples  (11)

OpenersExampleSection0(Spacer1)Basic Examples  (3)

Count the number of pixels in each of 10 intensity levels:

ImageLevels[,10]

Levels of an RGB image:

ImageLevels[,10]

Intensity levels of a 3D image:

ImageLevels[, 10]

OpenersExampleSection1(Spacer1)Scope  (5)

Levels of a binary image:

ImageLevels[]

Levels of an image in the range 0 to 255:

ImageLevels[,"Byte"]//Short

Levels for a random image that has intensity values outside the normal range from 0 to 1:

ImageLevels[Image[RandomReal[{-2,3},{10,10}]],10,All]

Explicit data range setting:

ImageLevels[Image[RandomReal[{-2,3},{10,10}]],10,{-2,3}]

Tally of all levels in a random image:

ImageLevels[Image[RandomInteger[{0,255},{10,10}]],All]

OpenersExampleSection2(Spacer1)Options  (1)

OpenersExampleSubsection0(Spacer1)Method  (1)

By default, pixel values outside the normal range are included:

ImageLevels[Image[{{-0.2,0.0,0.2,0.4,0.6,0.8,1.0,1.2}}], 5]

Exclude values outside the normal range:

ImageLevels[Image[{{-0.2,0.0,0.2,0.4,0.6,0.8,1.0,1.2}}], 5,Method->"ExcludeOutOfRange"]

OpenersExampleSection3(Spacer1)Applications  (1)

Plot levels of a random image with a Laplacian distribution of pixel values:

ImageLevels[RandomImage[LaplaceDistribution[0,.2],{100,100}],50,{-1,1}]//ListLinePlot

OpenersExampleSection5(Spacer1)Possible Issues  (1)

A tally of all levels in an image returns a result with non-uniform distribution of bins:

ImageLevels[Image[RandomInteger[{0,255},{10,10}]],All]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[ImageHistogram, paclet:ref/ImageHistogram])  ▪  (RefLink[ImageAdjust, paclet:ref/ImageAdjust])  ▪  (RefLink[ColorQuantize, paclet:ref/ColorQuantize])  ▪  (RefLink[Binarize, paclet:ref/Binarize])  ▪  (RefLink[ImageData, paclet:ref/ImageData])  ▪  (RefLink[HistogramList, paclet:ref/HistogramList])  ▪  (RefLink[BinCounts, paclet:ref/BinCounts])  ▪  (RefLink[Tally, paclet:ref/Tally])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Image Processing, paclet:tutorial/ImageProcessing])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Color Processing, paclet:guide/ColorProcessing])}, {▪(RefLinkPlain[Image Representation, paclet:guide/ImageRepresentation])}, {▪(RefLinkPlain[Computational Photography, paclet:guide/ComputationalPhotography])}})}})