Back to Adaptive Vision Library website

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

ThresholdImage_Relative


Header: AVL.h
Namespace: avl
Module: FoundationBasic

Thresholds an image with a different threshold value for each pixel (inBaseImage(x, y) + inValue).

Syntax

C++
C#
 
void avl::ThresholdImage_Relative
(
	const avl::Image& inImage,
	atl::Optional<const avl::Region&> inRoi,
	const avl::Image& inBaseImage,
	atl::Optional<float> inMinRelativeValue,
	atl::Optional<float> inMaxRelativeValue,
	float inFuzziness,
	avl::Image& outMonoImage
)

Parameters

Name Type Range Default Description
inImage const Image& Input image
inRoi Optional<const Region&> NIL Region of interest
inBaseImage const Image& Pixels of this image are subtracted from inImage before thresholding
inMinRelativeValue Optional<float> 128.0f Minimum relative value of a pixel that is considered foreground (Auto = -INF)
inMaxRelativeValue Optional<float> NIL Maximum relative value of a pixel that is considered foreground (Auto = +INF)
inFuzziness float 0.0 - 0.0f A tolerance for inMin/MaxRelativeValue that results in intermediate output values
outMonoImage Image&

Description

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

  • Pixels that are brighter than corresponding pixels of inBaseImage by at least inMinRelativeValue and at most inMaxRelativeValue are transformed to the maximum level.
  • Other pixel values are transformed to the minimum level.

If any of the parameters inMinRelativeValue, inMaxRelativeValue 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 border intensities; 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.

Examples

A sample image used as inImage.

A sample image used as inBaseImage.

ThresholdImage_Relative performed with inMinRelativeValue = 0.0, inMaxRelativeValue = auto, inFuzziness = 0.0.

ThresholdImage_Relative performed with inMinRelativeValue = 0.0, inMaxRelativeValue = auto, inFuzziness = 10.0.

Remarks

When image pixel type is Real, parameter inFuzziness has no influence on the output (input 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, 3xUINT8.

This operation is optimized for AVX2 technology for pixels of types: 1xUINT8, 3xUINT8.

This operation supports automatic parallelization for multicore and multiprocessor systems.

Errors

List of possible exceptions:

Error type Description
DomainError Image formats are not the same in ThresholdImage_Relative.
DomainError Image sizes are not equal in ThresholdImage_Relative.
DomainError Region exceeds an input image in ThresholdImage_Relative.

See Also

  • ThresholdToRegion_Relative – Thresholds an image with a different threshold value for each pixel (inBaseImage(x, y) + inValue).