ClassesClassesClassesClasses | | | | Operators

binary_thresholdbinary_thresholdBinaryThresholdbinary_thresholdBinaryThresholdBinaryThreshold (Operator)

Name

binary_thresholdbinary_thresholdBinaryThresholdbinary_thresholdBinaryThresholdBinaryThreshold — Segment an image using binary thresholding.

Signature

binary_threshold(Image : Region : Method, LightDark : UsedThreshold)

Herror binary_threshold(const Hobject Image, Hobject* Region, const char* Method, const char* LightDark, Hlong* UsedThreshold)

Herror T_binary_threshold(const Hobject Image, Hobject* Region, const Htuple Method, const Htuple LightDark, Htuple* UsedThreshold)

Herror binary_threshold(Hobject Image, Hobject* Region, const HTuple& Method, const HTuple& LightDark, Hlong* UsedThreshold)

Herror binary_threshold(Hobject Image, Hobject* Region, const HTuple& Method, const HTuple& LightDark, HTuple* UsedThreshold)

HRegion HImage::BinaryThreshold(const HTuple& Method, const HTuple& LightDark, Hlong* UsedThreshold) const

HRegionArray HImageArray::BinaryThreshold(const HTuple& Method, const HTuple& LightDark, HTuple* UsedThreshold) const

void BinaryThreshold(const HObject& Image, HObject* Region, const HTuple& Method, const HTuple& LightDark, HTuple* UsedThreshold)

HRegion HImage::BinaryThreshold(const HString& Method, const HString& LightDark, HTuple* UsedThreshold) const

HRegion HImage::BinaryThreshold(const HString& Method, const HString& LightDark, Hlong* UsedThreshold) const

HRegion HImage::BinaryThreshold(const char* Method, const char* LightDark, Hlong* UsedThreshold) const

void HOperatorSetX.BinaryThreshold(
[in] IHUntypedObjectX* Image, [out] IHUntypedObjectX*Region, [in] VARIANT Method, [in] VARIANT LightDark, [out] VARIANT* UsedThreshold)

IHRegionX* HImageX.BinaryThreshold(
[in] BSTR Method, [in] BSTR LightDark, [out] VARIANT* UsedThreshold)

static void HOperatorSet.BinaryThreshold(HObject image, out HObject region, HTuple method, HTuple lightDark, out HTuple usedThreshold)

HRegion HImage.BinaryThreshold(string method, string lightDark, out HTuple usedThreshold)

HRegion HImage.BinaryThreshold(string method, string lightDark, out int usedThreshold)

Description

binary_thresholdbinary_thresholdBinaryThresholdbinary_thresholdBinaryThresholdBinaryThreshold segments a single-channel ImageImageImageImageImageimage using an automatically determined global threshold and returns the segmented region in RegionRegionRegionRegionRegionregion. This is, e.g., useful for the segmentation of characters on a homogeneously illuminated background. binary_thresholdbinary_thresholdBinaryThresholdbinary_thresholdBinaryThresholdBinaryThreshold also returns the used threshold in UsedThresholdUsedThresholdUsedThresholdUsedThresholdUsedThresholdusedThreshold.

The used threshold is determined by the method that is given in MethodMethodMethodMethodMethodmethod. Currently the operator provides the following two methods: 'max_separability'"max_separability""max_separability""max_separability""max_separability""max_separability" and 'smooth_histo'"smooth_histo""smooth_histo""smooth_histo""smooth_histo""smooth_histo". Both methods should only be used for images that have a bimodal histogram.

The method 'smooth_histo'"smooth_histo""smooth_histo""smooth_histo""smooth_histo""smooth_histo" provides the same functionality that has been provided by the operator bin_thresholdbin_thresholdBinThresholdbin_thresholdBinThresholdBinThreshold. The method 'max_separability'"max_separability""max_separability""max_separability""max_separability""max_separability" tends to determine smaller values for UsedThresholdUsedThresholdUsedThresholdUsedThresholdUsedThresholdusedThreshold. Furthermore, it is less sensitive to thin isolated peaks in the histogram that are far from the rest of the spectrum and often, it is faster than 'smooth_histo'"smooth_histo""smooth_histo""smooth_histo""smooth_histo""smooth_histo".

Maximize separability

By selecting MethodMethodMethodMethodMethodmethod = 'max_separability'"max_separability""max_separability""max_separability""max_separability""max_separability", automatic thresholding based on the gray-level histogram according to Otsu (see the paper in References) is invoked. The algorithm first calculates the histogram of the image and then uses statistical moments to find the optimal threshold that divides the pixels into foreground and background and maximizes the separability between these two classes. This method is only available for byte and uint2 images.

Histrogram smoothing

By selecting MethodMethodMethodMethodMethodmethod = 'smooth_histo'"smooth_histo""smooth_histo""smooth_histo""smooth_histo""smooth_histo" binary_thresholdbinary_thresholdBinaryThresholdbinary_thresholdBinaryThresholdBinaryThreshold determines the threshold in the following way: First, the relative histogram of the gray values is determined. Then, relevant minima are extracted from the histogram, which are used as parameters for a thresholding operation. In order to reduce the number of minima, the histogram is smoothed with a Gaussian, as in auto_thresholdauto_thresholdAutoThresholdauto_thresholdAutoThresholdAutoThreshold. The mask size is enlarged until there is only one minimum in the smoothed histogram. Then, the threshold is set to the position of this minimum.

Parallelization

Parameters

ImageImageImageImageImageimage (input_object)  singlechannelimage(-array) objectHImageHImageHImageHImageXHobject (byte / uint2)

Input Image.

RegionRegionRegionRegionRegionregion (output_object)  region(-array) objectHRegionHRegionHRegionHRegionXHobject *

Segmented output region.

MethodMethodMethodMethodMethodmethod (input_control)  string HTupleHTupleHTupleVARIANTHtuple (string) (string) (HString) (char*) (BSTR) (char*)

Segmentation method.

Default value: 'max_separability' "max_separability" "max_separability" "max_separability" "max_separability" "max_separability"

List of values: 'max_separability'"max_separability""max_separability""max_separability""max_separability""max_separability", 'smooth_histo'"smooth_histo""smooth_histo""smooth_histo""smooth_histo""smooth_histo"

LightDarkLightDarkLightDarkLightDarkLightDarklightDark (input_control)  string HTupleHTupleHTupleVARIANTHtuple (string) (string) (HString) (char*) (BSTR) (char*)

Extract foreground or background?

Default value: 'dark' "dark" "dark" "dark" "dark" "dark"

List of values: 'dark'"dark""dark""dark""dark""dark", 'light'"light""light""light""light""light"

UsedThresholdUsedThresholdUsedThresholdUsedThresholdUsedThresholdusedThreshold (output_control)  number(-array) HTupleHTupleHTupleVARIANTHtuple (integer / string) (int / long / string) (Hlong / HString) (Hlong / char*) (Hlong / BSTR) (Hlong / char*)

Used threshold.

Possible Successors

connectionconnectionConnectionconnectionConnectionConnection, select_shapeselect_shapeSelectShapeselect_shapeSelectShapeSelectShape, select_grayselect_graySelectGrayselect_graySelectGraySelectGray

Alternatives

auto_thresholdauto_thresholdAutoThresholdauto_thresholdAutoThresholdAutoThreshold, char_thresholdchar_thresholdCharThresholdchar_thresholdCharThresholdCharThreshold, local_thresholdlocal_thresholdLocalThresholdlocal_thresholdLocalThresholdLocalThreshold

See also

gray_histogray_histoGrayHistogray_histoGrayHistoGrayHisto, thresholdthresholdThresholdthresholdThresholdThreshold

References

N. Otsu, “A threshold selection method from gray level histograms", IEEE Trans. Syst. Man. Cybern., Vol. SMC-9, 62-66 (1979)

Module

Foundation


ClassesClassesClassesClasses | | | | Operators