Back to Aurora Vision Library website

You are here: Start » Function Reference » Image » Image Thresholding » ThresholdImage

ThresholdImage


Header: AVL.h
Namespace: avl
Module: FoundationLite

Transforms each pixel value to maximum or minimum depending on whether they belong to the specified range.

Applications: Image binarization when the illumination is constant and uniform.

Syntax

C++
C#
 
void avl::ThresholdImage
(
	const avl::Image& inImage,
	atl::Optional<const avl::Region&> inRoi,
	atl::Optional<float> inMinValue,
	atl::Optional<float> inMaxValue,
	float inFuzziness,
	avl::Image& outMonoImage
)

Parameters

Name Type Range Default Description
Input value inImage const Image& Input image
Input value inRoi Optional<const Region&> NIL Region of interest
Input value inMinValue Optional<float> 128.0f Minimum value of a pixel that is considered foreground (Auto = -INF)
Input value inMaxValue Optional<float> NIL Maximum value of a pixel that is considered foreground (Auto = +INF)
Input value inFuzziness float 0.0 - 0.0f A tolerance for inMin/MaxValue that results in intermediate output values
Output value outMonoImage Image&

Description

The operation transforms each pixel value to the maximum or minimum level thus creating binary image. The result of the transformation depends on the pixel intensity:

  • Pixel values in range (inMinValue, inMaxValue) are transformed to the maximum level.
  • Other pixel values are transformed to the minimum level.

If any of the parameters inMinValue, inMaxValue is not set, it is assumed to be, accordingly, -infinity or infinity.

Parameter inFuzziness (set to 0 by default) allows to perform fuzzy thresholding which linearly interpolates those pixel values that differ by at most inFuzziness from the values inMinValue, inMaxValue; thus creating smooth transition between minimum and maximum values in the resulting image (see Remarks section).

In the multichannel images the operation uses an average of channel values in each pixel, thus the resulting image is always monochromatic.

Hints

  • Define inMinValue to obtain white pixels for bright objects (brighter than the specified value).
  • Define inMaxValue to obtain white pixels for dark objects (darker than the specified value).
  • Use inFuzziness to add some smooth transitions between black and white pixels in the result.

Examples

ThresholdImage performed on the sample image with inMinValue = 80.0, inMaxValue = auto, inFuzziness = 0.0.

ThresholdImage performed on the sample image with inMinValue = 80.0, inMaxValue = auto, inFuzziness = 2.5.

Remarks

When image pixel type is Real, parameter inFuzziness has no influence on the output (is ignored). The reason is strictly mathematical. Namely, there does not exist a smooth transition between -infinity and +infinity values, which are, correspondingly, minimum and maximum levels of pixel brightness.

Hardware Acceleration

This operation is optimized for SSE2 technology for pixels of types: 1xUINT8 (for inFuzziness = 0), 3xUINT8 (for inFuzziness = 0).

This operation is optimized for AVX2 technology for pixels of types: 1xUINT8 (for inFuzziness = 0), 3xUINT8 (for inFuzziness = 0).

This operation is optimized for NEON technology for pixels of types: 1xUINT8 (for inFuzziness = 0), 3xUINT8 (for inFuzziness = 0).

This operation supports automatic parallelization for multicore and multiprocessor systems.

Errors

List of possible exceptions:

Error type Description
DomainError Region exceeds an input image in ThresholdImage.

See Also

  • ThresholdToRegion – Creates a region containing image pixels with values within the specified range.