Click or drag to resize
CanvasImageComputeHistogram 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.CanvasICanvasImage
sourceRectangle
Type: Windows.FoundationRect
resourceCreator
Type: Microsoft.Graphics.CanvasICanvasResourceCreator
channelSelect
Type: Microsoft.Graphics.Canvas.EffectsEffectChannelSelect
numberOfBins
Type: SystemInt32

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