Back to Aurora Vision Library website

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

ThresholdImage_Color


Header: AVL.h
Namespace: avl
Module: FoundationPro

Transforms each pixel value to maximum or minimum depending on the distance from a given color.

Applications: Color analysis with a given reference color.

Syntax

C++
C#
 
void avl::ThresholdImage_Color
(
	const avl::Image& inImage,
	atl::Optional<const avl::Region&> inRoi,
	const avl::Pixel& inRgbColor,
	float inChromaAmount,
	float inMaxDifference,
	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 inRgbColor const Pixel& Color to compare the image to
Input value inChromaAmount float 0.0 - 1.0 0.7f Proportion of chromatic information in distance computation
Input value inMaxDifference float 0.0 - 5.0f Maximum difference between image pixel and model color
Input value inFuzziness float 0.0 - 0.0f A tolerance for computed difference that results in intermediate output values
Output value outMonoImage Image&

Requirements

For input inImage only pixel formats are supported: 1⨯uint8, 2⨯uint8, 3⨯uint8, 4⨯uint8.

Read more about pixel formats in Image documentation.

Hints

  • Define the reference color by setting the inRgbColor input.
  • Increase inChromaAmount to make the function less sensitive to changes in brightness. Decrease it to make brightness more important.
  • Set inMaxDifference experimentally to a value that best separates the foreground and background pixels.
  • Use inFuzziness to add some smooth transitions between black and white pixels in the result.

Examples

ThresholdImage_Color performed on a sample image with inRgbColor = (192, 34, 22), inChromaAmount = 1.0, inMaxDifference = 48.

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 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_Color.
DomainError Not supported inImage pixel format in ThresholdImage_Color. Supported formats: 1xUInt8, 2xUInt8, 3xUInt8, 4xUInt8.

See Also

  • ColorDistanceImage – Compares each pixel with the specified color using chromatic and non-chromatic information.