CanvasImageComputeHistogram Method |
Namespace: Microsoft.Graphics.Canvas
public static float[] ComputeHistogram( ICanvasImage image, Rect sourceRectangle, ICanvasResourceCreator resourceCreator, EffectChannelSelect channelSelect, int numberOfBins )
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).