Back to FabImage Studio website

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

NormalizeLocalContrast


Module: FoundationBasic

Normalizes local contrast of the image using Wallis filter.

Name Type Range Description
Input value inMonoImage Image Monochromatic input image
Input value inRoi Region* Range of pixels to be processed
Input value inTargetMean Real Target local mean
Input value inTargetVariance Real 0.1 - Target local variance
Input value inUniformnessScale Integer 1 - + Radius of neighbourhood to uniformize
Input value inBrightnessPreserveRatio Real 0.0 - 1.0 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

This filter can throw an exception to report error. Read how to deal with errors in Error Handling.

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.

Complexity Level

This filter is available on Advanced Complexity Level.

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.