Back to Aurora Vision Library website

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

NormalizeLocalContrast


Header: AVL.h
Namespace: avl
Module: FoundationBasic

Normalizes local contrast of the image using Wallis filter.

Syntax

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

Parameters

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

Requirements

For input inMonoImage only pixel formats are supported: 1⨯uint8, 1⨯int8, 1⨯uint16, 1⨯int16, 1⨯int32, 1⨯real.

Read more about pixel formats in Image documentation.

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.

See Also

  • RescalePixels – Applies linear transformation to pixel values.
  • ResaturateImage – Sets pixels below the low value to minimum, above the high value to maximum, and interpolates the rest.
  • AddToImage – Adds a scalar value to each pixel.
  • NormalizeImage – Rescales an image linearly, so that its minimum becomes inNewMinimum and the maximum of the remaining pixels becomes inNewMaximum.