Back to Adaptive Vision Library website

You are here: Start » Function Reference » Image Enhancement » NormalizeLocalContrast

NormalizeLocalContrast


Normalizes local contrast of the image using Wallis filter.

Syntax

C++
C#
 
void avl::NormalizeLocalContrast
(
	const avl::Image& inMonoImage,
	const atl::Optional<avl::Region>& inRoi,
	const float inTargetMean,
	const float inTargetVariance,
	const int inUniformnessScale,
	const float inBrightnessPreserveRatio,
	avl::Image& outImage
)

Parameters

Name Type Range Default Description
inMonoImage const Image& Monochromatic input image
inRoi const Optional<Region>& NIL Range of pixels to be processed
inTargetMean const float 128.0f Target local mean
inTargetVariance const float 0.1 - 90.0f Target local variance
inUniformnessScale const int 1 - + 10 Radius of neighbourhood to uniformize
inBrightnessPreserveRatio const float 0.0 - 1.0 0.1f How much of original brightness to be kept
outImage Image& Output 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

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

and

  • \(Dev_{loc}\) and \(Mean_{loc}\) are local deviation and mean respectively, taken from the square neighbourhood of radius inUniformnessScale
  • 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

Error type Description
DomainError Image depth must be 1 in NormalizeLocalContrast filter