You are here: Start » AVL.NET » Function Reference » Image » Image Enhancement » AVL.NormalizeLocalContrast

AVL.NormalizeLocalContrast

Normalizes local contrast of the image using Wallis filter.

Namespace:AvlNet
Assembly:AVL.NET.dll

Syntax

C++
C#
 
public static void NormalizeLocalContrast
(
	AvlNet.Image inMonoImage,
	float inTargetMean,
	float inTargetVariance,
	int inUniformnessScale,
	float inBrightnessPreserveRatio,
	AvlNet.Image outImage
)

Parameters

Name Type Range Default Description
inMonoImageAvlNet.ImageMonochromatic input image.
inTargetMeanfloat128.0fTarget local mean. Default value: 128.0f.
inTargetVariancefloat<0.1f, INF>90.0fTarget local variance. Default value: 90.0f.
inUniformnessScaleint<1, +INF>10Radius of neighbourhood to uniformize. Default value: 10.
inBrightnessPreserveRatiofloat<0.0f, 1.0f>0.1fHow much of original brightness to be kept. Default value: 0.1f.
outImageAvlNet.ImageOutput image.

Description

This filter resaturates every pixel of monochromatic image inMonoImage so that its neighbourhood matches approximately average of inTargetMean and variance of inTargetVariance using Wallis algorithm.

Parameter inUniformnessScale determines the radius of the neighbourhood.

Parameter inBrightnessPreserveRatio determines how much of the original brightness is kept on the resulting image.

New value of pixel is given by:

\[ P_{new} = A\ P_{old} + B \]

where

\[A = \frac{Var_{new} }{\frac{90}{CFC} + Var_{loc} } \] \[B = Mean_{new}(1 - BPR) + Mean_{loc}(BPR - A) \]

and

  • \(Dev_{loc}\) and \(Mean_{loc}\) are local deviation and mean respectively, taken from the square neighbourhood of radius inUniformnessScale
  • \(Dev_{new}\) and \(Mean_{new}\) are target deviation and mean respectively, inTargetVariance and inTargetMean
  • CFC is Contrast Force Constant, set to \(0.9\)
  • BPR is inBrightnessPreserveRatio

Examples

Example image

Output of NormalizeLocalContrast filter

Previous image with NormalizeImage filter applied to it

Remarks

After the filter is run on the image, the neighbourhoods of pixels do not have desired variance and average. First reason for that is presence of constants BPR and CFC. Second reason is that forcing matching given average would require solving system of as many linear equations as there are pixels on the image.

Errors

List of possible exceptions:

Error type Description
DomainError Mono image expected on input in NormalizeLocalContrast.
DomainError Region exceeds an input image in NormalizeLocalContrast.
DomainError Not supported inMonoImage pixel format in NormalizeLocalContrast. Supported formats: 1xUInt8, 1xInt8, 1xUInt16, 1xInt16, 1xInt32, 1xReal.

Function Overrides

See also