Back to Aurora Vision Library website

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

NormalizeImage


Header: AVL.h
Namespace: avl
Module: FoundationLite

Rescales an image linearly, so that its minimum becomes inNewMinimum and the maximum of the remaining pixels becomes inNewMaximum.

Applications: Aims at better using the image's dynamic range to represent an interesting subset of pixel values.

Syntax

C++
C#
 
void avl::NormalizeImage
(
	const avl::Image& inImage,
	atl::Optional<const avl::Region&> inRoi,
	float inNewMinimum,
	float inNewMaximum,
	float inSaturateBrightestFraction,
	float inSaturateDarkestFraction,
	atl::Optional<float> inMinValue,
	atl::Optional<float> inMaxValue,
	avl::Image& outImage,
	float& outA,
	float& outB,
	avl::Region& diagLinearNormalizedRegion
)

Parameters

Name Type Range Default Description
Input value inImage const Image& Input image
Input value inRoi Optional<const Region&> NIL Range of pixels to be processed
Input value inNewMinimum float 0.0f Desired minimum value of the resulting image
Input value inNewMaximum float 255.0f Desired maximum value of the resulting image
Input value inSaturateBrightestFraction float 0.0 - 1.0 0.0f Fraction of the brightest pixels skipped during normalization
Input value inSaturateDarkestFraction float 0.0 - 1.0 0.0f Fraction of the darkest pixels skipped during normalization
Input value inMinValue Optional<float> NIL Pixels darker than that value will be skipped during normalization
Input value inMaxValue Optional<float> NIL Pixels brighter than that value will be skipped during normalization
Output value outImage Image& Rescaled image
Output value outA float& Multiplicative parameter of the applied linear transformation of pixel values
Output value outB float& Additive parameter of the applied linear transformation of pixel values
Diagnostic input diagLinearNormalizedRegion Region& Region of image that has been linearly normalized

Description

This filter linearly scales the pixel values of an image in order to make the histogram span the desired range of values.

The operation computes the parameters \(A\), \(B\) of the linear transform that scales the image values to the desired range and applies the transform computing the results as follows:

\[ \begin{aligned} outImage[i,j] &= inImage[i,j] \times A + B \\ outA &= A \\ outB &= B \end{aligned} \]

The inSaturateBrightestFraction and inSaturateDarkestFraction parameters can be used to make image normalization independent from salt and pepper noise. The normalization skips a chosen fraction of the brightest and the darkest pixels during counting \(A\) and \(B\). The brightest and darkest pixels are set to inNewMaximum and inNewMinimum respectively, while the rest of the image is linearly scaled. A region of the linear scaling is available on diagLinearNormalizedRegion diagnostic output. For example, setting inSaturateBrightestFraction to 0.01 causes skipping 1 percent of the brightest pixels during counting \(A\) and \(B\). Please note that the inSaturateBrightestFraction and inSaturateDarkestFraction parameters can be non-zero only for images with UInt8, Int8, UInt16 or Int16 pixel type.

Examples

NormalizeImage run on example image.

Errors

List of possible exceptions:

Error type Description
DomainError Empty image on input in NormalizeImage.
DomainError Region exceeds an input image in NormalizeImage.
DomainError The inSaturationFraction inputs cannot be used for images with this pixel type in NormalizeImage.
DomainError The sum of inSaturateBrightestFraction and inSaturateDarkestFraction can't be greater than 1 in NormalizeImage.

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.