Start » Filter Reference » Image » Image Thresholding » SelectThresholdValue

SelectThresholdValue


Module: FoundationBasic

Selects best threshold value using the image histogram.

Applications

Usually used before a thresholding filter when the image brightness is variable. Use with care.
Name Type Description
Input value
inImage Image Input image
Input value
inRoi Region* Range of pixels to be processed
Input value
inMethod ThresholdSelectionMethod Method used to select the best threshold
Output value
outThresholdValue Real Best threshold separating background pixels from foreground pixels
Diagnostic input
diagThresholdRatings RealArray Contains ratings gained if that threshold would be chosen
Diagnostic input
diagBackgroundPixelsFraction RealArray Fraction of pixels that are darker than the index value
Diagnostic input
diagForegroundPixelsFraction RealArray Fraction of pixels that are brighter than the index value

Requirements

For input inImage only pixel formats are supported: uint8.

Read more about pixel formats in Image documentation.

Description

The operation estimates an intensity threshold value that discriminates foreground pixels from background pixels in inImage.

Note that to provide meaningful results it is required that the image in fact consists of foreground and background components that strongly differ in brightness.

Hints

  • Choose inMethod that works best in your application. None of the methods is perfect, but ClusteringOtsu is the most universal one.

Examples

SelectThresholdValue performed on the sample image (on the left) with inMethod = ClusteringKittler yields outThresholdValue = 189.5. Pixels of the input image brighter than 189.5 are presented on the right.

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 Region exceeds an input image in SelectThresholdValue.
DomainError Not supported inImage pixel format in SelectThresholdValue. Supported formats: UInt8.

Complexity Level

This filter is available on Advanced Complexity Level.

See Also

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