Core Optical, Inc.
HistogramProcessor GetAdaptivelyEqualizedHistogramImageArray Method Industrial Strength, Scientific Grade
Applies the Contrast-Limited Adaptive Histogram Equalization algorithm to the source data and returns an array of pixel values portraying the result. The original data is not altered.

Namespace: PrecisionImage.HistogramProcessing
Assembly: PrecisionImage (in PrecisionImage.dll) Version: (

public byte[] GetAdaptivelyEqualizedHistogramImageArray(
	SourceData sourceData,
	int channel,
	int windowSize,
	float clipping,
	Int32Rect regionOfInterest = null,
	BinaryMask binaryMask = null,
	bool zeroOutMaskArea = true,
	GammaEncoding gammaEncoding = GammaEncoding.None


Type: PrecisionImage SourceData
A SourceData type containing the image data.
Type: OnlineSystem Int32
An OnlineInt32 type indicating the data channel to process.
Type: OnlineSystem Int32
An OnlineInt32 type specifying the dimension (square) of the neighborhood window. If an even number is specified then this value is automatically shifted to the next higher odd number in order to properly center the local analysis window. Avoid a dimension smaller than the root of the histogram resolution (in this case 16). A good starting value is 55.
Type: OnlineSystem Single
A OnlineSingle type indicating the normalized (0.0 - 1.0) clipping value. Smaller values cause greater noise suppression, larger values cause greater contrast enhancement.
regionOfInterest (Optional)
Type: OnlineSystem.Windows Int32Rect
An OnlineInt32Rect type indicating the region of interest. Coordinates are zero-index based. This parameter is optional and defaults to the entire image.
binaryMask (Optional)
Type: PrecisionImage.BinarizationAndMorphology BinaryMask
A BinaryMask type specifying a mask indicating areas of the image to bypass. Masked data points are not altered and do not contribute to the local histogram statistics. This parameter is optional.
zeroOutMaskArea (Optional)
Type: OnlineSystem Boolean
A OnlineBoolean indicating whether to the masked areas are zeroed in the output image. If True, the masked regions of the data appear black. If True, the masked area of the region is inserted unchanged in the resulting image array. This parameter is optional and defaults to True.
gammaEncoding (Optional)
Type: PrecisionImage GammaEncoding
A GammaEncoding enumeration specifying the gamma encoding of the unmasked region. If the unmasked region is to be zeroed out in the resulting image this parameter is ignored. This parameter is optional and defaults to GammaEncoding.None

Return Value

A OnlineArray of type OnlineByte containing the pixel values of the CLAHE-processed data.

OnlineSystem ArgumentNullException Thrown when sourceData is null.
OnlineSystem ArgumentOutOfRangeException Thrown when channel is negative or out of range.
OnlineSystem ArgumentOutOfRangeException Thrown when windowSize is less than or equal to zero.
OnlineSystem ArgumentOutOfRangeException Thrown when the number of rows and/or columns in binaryMask do not match those of sourceData.
OnlineSystem ArgumentOutOfRangeException Thrown when clipping is negative or greater than 1.0.
OnlineSystem ArgumentOutOfRangeException Thrown when regionOfInterest specifies a rectangular region not completely contained within the dimensions of the source data.

Use this method in conjunction with a OnlineWriteableBitmap or other type to generate the Contrast-Limited Adaptive Histogram-Equalized (CLAHE) image of the source data while avoiding the overhead associated with generating a new OnlineBitmapSource object. The returned Byte[] contains the 8-bit pixel values portraying the CLAHE-processed data.

If a region of interest was specified, the returned OnlineArray portrays the processed data of the specified region only. The returned Byte[] has length equal to the product of the region of interest width and height. Otherwise, the returned Byte[] has the same dimensions as the product of the source data rows and columns. The stride of the array (in pixels) is equal to either the region of interest width or source data columns, depending on whether the regionOfInterest parameter was used.

This function can be used with or without a BinaryMask. If a BinaryMask is used, the data underlying any masked region will contribute to the local histogram, but only data points that aren't masked are altered (i.e. masked data points are bypassed but their values still contribute to local histograms). A boolean parmeter is used to specify whether or not the masked data is included in the final image result. If not, regions in the resulting image that correspond to masked areas are portrayed as black.

The CLAHE algorithm is not a well-behaved algorithm in the sense that the clipping strategy does not deal very well with sparse histograms. For this reason the implementation in PrecisionImage.NET is limited to an internal histogram resolution of 8-bit.


See the example for GetEqualizedHistogramImageArray(SourceData, Int32, HistogramResolution, Int32Rect, BinaryMask, Boolean, GammaEncoding) for an illustration of using the returned Array object.
See Also