Click or drag to resize
CanvasImage.ComputeHistogram Method
Generates a histogram from one color channel of the specified image.

Namespace:  Microsoft.Graphics.Canvas
Assembly:  Microsoft.Graphics.Canvas (in Microsoft.Graphics.Canvas.dll) Version: 0.0.0.0
Syntax
C#
public static float[] ComputeHistogram(
	ICanvasImage image,
	Rect sourceRectangle,
	ICanvasResourceCreator resourceCreator,
	EffectChannelSelect channelSelect,
	int numberOfBins
)

Parameters

image
Type: Microsoft.Graphics.Canvas.ICanvasImage
sourceRectangle
Type: Windows.Foundation.Rect
resourceCreator
Type: Microsoft.Graphics.Canvas.ICanvasResourceCreator
channelSelect
Type: Microsoft.Graphics.Canvas.Effects.EffectChannelSelect
numberOfBins
Type: System.Int32

Return Value

Type:Single[]
Remarks

The range 0-1 is divided over the specified number of bins, then the number of color values falling into each bin are counted. Color values outside this range are clamped. The range of a particular bin depends on the number of bins.

The number of bins can be from 2 to 1024.

The histogram is always evaluated at default (96) DPI. If you want to measure some other pixel density, scale the input image (using Transform2DEffect) before passing it to ComputeHistogram.

The source image is assumed to be in premultiplied alpha format, but this method operates on straight alpha values, so the input colors will be unpremultiplied before computing the histogram.

ComputeHistogram requires a GPU that supports DirectCompute. To check whether this is available, call IsHistogramSupported(CanvasDevice).

See Also