({{, (RefLink[ImageHistogram, paclet:ref/ImageHistogram])[image] 
plots a histogram of the pixel levels for each channel in image.}, {, (RefLink[ImageHistogram, paclet:ref/ImageHistogram])[image,bspec]
uses bin specification bspec.}, {, (RefLink[ImageHistogram, paclet:ref/ImageHistogram])[image,bspec,range]
plots the histogram of the pixel values in the given range.}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[ImageHistogram, paclet:ref/ImageHistogram]) yields a graphical image, represented as a (RefLink[Graphics, paclet:ref/Graphics]) object.

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

For RGB images, (RefLink[ImageHistogram, paclet:ref/ImageHistogram]) by default displays the channels using red, green, and blue.

Binning specification bspec can be any of the following:

By default, for binary images two bins are used; otherwise, 128 bins are used.

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.

(RefLink[ImageHistogram, paclet:ref/ImageHistogram]) accepts options of (RefLink[ListPlot, paclet:ref/ListPlot]), with the following additions and changes:

Possible settings for (RefLink[Appearance, paclet:ref/Appearance]) are:

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

OpenersPrimaryExamplesSection(Spacer1)Examples  (28)

OpenersExampleSection0(Spacer1)Basic Examples  (3)

Histogram of an RGB image:

ImageHistogram[]

Histogram of a grayscale image:

ImageHistogram[]

Histogram of a 3D volume:

ImageHistogram[]

OpenersExampleSection1(Spacer1)Scope  (6)

Specify the number of levels:

ImageHistogram[,32]

Histogram of a grayscale image showing all distinct levels:

ImageHistogram[,All]

Use range specification (RefLink[All, paclet:ref/All]) to plot the histogram from the minimum to maximum value in the image:

ImageHistogram[,32,All]

Histogram of a binary image:

ImageHistogram[]

Use a range specification that includes negative values for plotting the histogram:

ImageHistogram[LaplacianGaussianFilter[,3],Automatic,{-.2,.2},FrameTicks->{True,False}]

Histogram of a CMYK image:

ImageHistogram[,32,Appearance->"Separated"]

OpenersExampleSection2(Spacer1)Options  (12)

OpenersExampleSubsection0(Spacer1)Appearance  (2)

Use additive colors to represent overlapping regions of histograms of an RGB image:

i=;

ImageHistogram[i,Appearance-> "Transparent"]

Show separate histograms for each color channel:

ImageHistogram[i,Appearance->"Separated"]

Stack the color channels vertically:

ImageHistogram[i,Appearance-> "Stacked"]

For non-RGB images, default plotting colors are used for all appearances:

i=ColorConvert[,"LAB"];

Transparent histogram of a Lab image:

ImageHistogram[i,Appearance->"Transparent"]

Stacked histogram:

ImageHistogram[i,Appearance->"Stacked"]

Separated histogram:

ImageHistogram[i,Appearance->"Separated"]

OpenersExampleSubsection1(Spacer1)FrameTicks  (1)

By default, frame ticks are displayed on the x axis only:

i=;

ImageHistogram[i]

Show frame ticks for both axes:

ImageHistogram[i,FrameTicks->True]

Show frame ticks for only the x axis:

ImageHistogram[i,FrameTicks->{True,False}]

Specify frame tick spacings:

ImageHistogram[i,FrameTicks->{{Range[0,800,200],None},{Range[0,1,.1],None}}]

Specify particular frame ticks to be shown on the histogram:

ImageHistogram[i,FrameTicks->{{None,None},{{.7,.8,.9},None}}]

OpenersExampleSubsection2(Spacer1)InterpolationOrder  (2)

By default, the histogram is plotted with interpolation of order 0:

ImageHistogram[,40,Appearance->"Stacked"]

Create a smooth histogram of an image:

ImageHistogram[,40,Appearance->"Stacked",InterpolationOrder->3]

OpenersExampleSubsection3(Spacer1)Joined  (1)

Render histogram using a stem plot:

i=;

ImageHistogram[i,16,Joined->False,Appearance->"Transparent"]

Use a disjoint histogram:

ImageHistogram[i,16,Appearance->"Separated",Joined->False]

OpenersExampleSubsection4(Spacer1)Method  (1)

Control how pixels outside of the histogram range are counted and displayed:

ImageHistogram[,38,{0.4,0.7},Method->#]&/@{"IncludeOutOfRange","ExcludeOutOfRange"}

OpenersExampleSubsection6(Spacer1)PlotRange  (1)

Use (RefLink[PlotRange, paclet:ref/PlotRange])->(RefLink[Automatic, paclet:ref/Automatic]) for automatically determining the plot range:

i=;

ImageHistogram[i,PlotRange->Automatic]

(RefLink[PlotRange, paclet:ref/PlotRange])->(RefLink[All, paclet:ref/All]) includes the entire histogram:

ImageHistogram[i,PlotRange->All]

Modify the plot range to better visualize the distribution of higher intensities:

ImageHistogram[i,PlotRange->{0,100},Frame->False,Axes->True]

OpenersExampleSubsection7(Spacer1)PlotTheme  (3)

Use a theme minimum styling:

ImageHistogram[,PlotTheme->"Minimal"]

Add horizontal grid lines to the plot:

ImageHistogram[,PlotTheme->"Minimal",GridLines->{None,Automatic}]

Use a theme with dark background in a high-contrast color scheme:

ImageHistogram[,PlotTheme->"Marketing"]

OpenersExampleSubsection8(Spacer1)Ticks  (1)

By default, no ticks are displayed:

i=;

Show ticks for both axes:

ImageHistogram[i,Frame->False,Axes->True,Ticks->True]

Show ticks for only the x axis:

ImageHistogram[i,Frame->False,Axes->{True,False},Ticks->{True,False}]

Specify tick spacings:

ImageHistogram[i,Frame->False,Axes->True,Ticks->{Range[0,1,.1],Range[0,800,200]}]

Specify particular ticks to be shown on the histogram:

ImageHistogram[i,Frame->False,Axes->{True,False},Ticks->{{.7,.8,.9},None}]

OpenersExampleSection3(Spacer1)Applications  (1)

Use the image histograms to estimate a suitable threshold:

i=;

Select threshold value using visual inspection of histograms:

ImageHistogram[i,Frame->False,Axes->True,Ticks->True,Epilog->{Red,Line[{{0.7,0},{0.7,900}}]}]

Binarize image using selected threshold:

Binarize[i,0.7]

OpenersExampleSection4(Spacer1)Properties & Relations  (3)

Image histogram can also be computed using (RefLink[Histogram, paclet:ref/Histogram]); however, it is slower:

AbsoluteTiming[ImageHistogram[,60,Joined->False]]

AbsoluteTiming[Histogram[Flatten/@ImageData[,Interleaving->False],60]]

Find the histogram distribution of an image:

dist=HistogramDistribution[Flatten[ImageData[]]]

Plot[PDF[dist,x],{x,0,1},Filling->Bottom]

(RefLink[ImageHistogram, paclet:ref/ImageHistogram]) blends alpha channel with black:

i=;

ImageHistogram[i]

Blend with black before computing the histogram:

ImageHistogram[RemoveAlphaChannel[i,Black]]

Blend with white:

ImageHistogram[RemoveAlphaChannel[i,White]]

Drop the alpha channel:

ImageHistogram[RemoveAlphaChannel[i]]

OpenersExampleSection5(Spacer1)Possible Issues  (1)

Histograms with varying bin widths cannot be displayed using the "Stacked" appearance:

ImageHistogram[,30,All,Appearance->"Stacked"]

Use a different appearance:

ImageHistogram[,30,All,Appearance->"Transparent"]

OpenersExampleSection6(Spacer1)Interactive Examples  (1)

Interactive histogram of an RGB image:

Manipulate[ImageHistogram[,n,{left,right},Method->clip,Joined->join,Appearance->m],{{n,128},1,256,1},{{left,0},-1,1.5},{{right,1},-0.5,1.5},{clip,{"IncludeOutOfRange","ExcludeOutOfRange"}},{join,{True,False}},{{m,"RGB","Appearance"},{"Transparent","RGB","Stacked","Separated"}}]

OpenersExampleSection7(Spacer1)Neat Examples  (1)

Histogram of an image that is made progressively darker:

list=NestList[Darker,,4]

ImageHistogram[ColorCombine[list],30]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[ImageLevels, paclet:ref/ImageLevels])  ▪  (RefLink[ImageAdjust, paclet:ref/ImageAdjust])  ▪  (RefLink[ImageData, paclet:ref/ImageData])  ▪  (RefLink[Histogram, paclet:ref/Histogram])  ▪  (RefLink[HistogramTransform, paclet:ref/HistogramTransform])}})}})

({{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[Image Processing & Analysis, paclet:guide/ImageProcessing])}, {▪(RefLinkPlain[3D Images, paclet:guide/3DImages])}, {▪(RefLinkPlain[Image Computation for Microscopy, paclet:guide/ImageComputationForMicroscopy])}, {▪(RefLinkPlain[Computational Photography, paclet:guide/ComputationalPhotography])}})}})