ClassesClassesClassesClasses | | | | Operators

var_thresholdvar_thresholdVarThresholdvar_thresholdVarThresholdVarThreshold (Operator)

Name

var_thresholdvar_thresholdVarThresholdvar_thresholdVarThresholdVarThreshold — Threshold an image by local mean and standard deviation analysis.

Signature

var_threshold(Image : Region : MaskWidth, MaskHeight, StdDevScale, AbsThreshold, LightDark : )

Herror var_threshold(const Hobject Image, Hobject* Region, const Hlong MaskWidth, const Hlong MaskHeight, double StdDevScale, double AbsThreshold, const char* LightDark)

Herror T_var_threshold(const Hobject Image, Hobject* Region, const Htuple MaskWidth, const Htuple MaskHeight, const Htuple StdDevScale, const Htuple AbsThreshold, const Htuple LightDark)

Herror var_threshold(Hobject Image, Hobject* Region, const HTuple& MaskWidth, const HTuple& MaskHeight, const HTuple& StdDevScale, const HTuple& AbsThreshold, const HTuple& LightDark)

HRegion HImage::VarThreshold(const HTuple& MaskWidth, const HTuple& MaskHeight, const HTuple& StdDevScale, const HTuple& AbsThreshold, const HTuple& LightDark) const

HRegionArray HImageArray::VarThreshold(const HTuple& MaskWidth, const HTuple& MaskHeight, const HTuple& StdDevScale, const HTuple& AbsThreshold, const HTuple& LightDark) const

void VarThreshold(const HObject& Image, HObject* Region, const HTuple& MaskWidth, const HTuple& MaskHeight, const HTuple& StdDevScale, const HTuple& AbsThreshold, const HTuple& LightDark)

HRegion HImage::VarThreshold(Hlong MaskWidth, Hlong MaskHeight, const HTuple& StdDevScale, const HTuple& AbsThreshold, const HString& LightDark) const

HRegion HImage::VarThreshold(Hlong MaskWidth, Hlong MaskHeight, double StdDevScale, double AbsThreshold, const HString& LightDark) const

HRegion HImage::VarThreshold(Hlong MaskWidth, Hlong MaskHeight, double StdDevScale, double AbsThreshold, const char* LightDark) const

void HOperatorSetX.VarThreshold(
[in] IHUntypedObjectX* Image, [out] IHUntypedObjectX*Region, [in] VARIANT MaskWidth, [in] VARIANT MaskHeight, [in] VARIANT StdDevScale, [in] VARIANT AbsThreshold, [in] VARIANT LightDark)

IHRegionX* HImageX.VarThreshold(
[in] Hlong MaskWidth, [in] Hlong MaskHeight, [in] VARIANT StdDevScale, [in] VARIANT AbsThreshold, [in] BSTR LightDark)

static void HOperatorSet.VarThreshold(HObject image, out HObject region, HTuple maskWidth, HTuple maskHeight, HTuple stdDevScale, HTuple absThreshold, HTuple lightDark)

HRegion HImage.VarThreshold(int maskWidth, int maskHeight, HTuple stdDevScale, HTuple absThreshold, string lightDark)

HRegion HImage.VarThreshold(int maskWidth, int maskHeight, double stdDevScale, double absThreshold, string lightDark)

Description

The operator var_thresholdvar_thresholdVarThresholdvar_thresholdVarThresholdVarThreshold selects from the input image ImageImageImageImageImageimage those regions RegionRegionRegionRegionRegionregion in which the pixels fulfill a threshold condition. The threshold is calculated from the mean gray value and the standard deviation in a local window of size MaskWidthMaskWidthMaskWidthMaskWidthMaskWidthmaskWidth x MaskHeightMaskHeightMaskHeightMaskHeightMaskHeightmaskHeight around each pixel (x,y). If MaskWidthMaskWidthMaskWidthMaskWidthMaskWidthmaskWidth or MaskHeightMaskHeightMaskHeightMaskHeightMaskHeightmaskHeight is even, the next larger odd value is used. The mask window should be greater than the image features to be segmented and it should comprise at least three pixels.

Let g(x,y) be the gray value at position (x,y) in the input image ImageImageImageImageImageimage and m(x,y) and d(x,y) the corresponding mean and standard deviation of the gray values in the window around that pixel and

  v(x,y) = max( StdDevScaleStdDevScaleStdDevScaleStdDevScaleStdDevScalestdDevScale * d(x,y),AbsThresholdAbsThresholdAbsThresholdAbsThresholdAbsThresholdabsThreshold)
  for StdDevScaleStdDevScaleStdDevScaleStdDevScaleStdDevScalestdDevScale >= 0

or

  v(x,y) = min( StdDevScaleStdDevScaleStdDevScaleStdDevScaleStdDevScalestdDevScale * d(x,y),AbsThresholdAbsThresholdAbsThresholdAbsThresholdAbsThresholdabsThreshold)
  for $StdDevScaleStdDevScaleStdDevScaleStdDevScaleStdDevScalestdDevScale < 0$.

The standard deviation is used as a measure of noise in the image and scaled by StdDevScaleStdDevScaleStdDevScaleStdDevScaleStdDevScalestdDevScale to reflect the desired sensitivity. The threshold condition is determined by the parameter LightDarkLightDarkLightDarkLightDarkLightDarklightDark:

LightDarkLightDarkLightDarkLightDarkLightDarklightDark = 'light'"light""light""light""light""light":

  g(x,y) >= m(x,y) + v(x,y).

LightDarkLightDarkLightDarkLightDarkLightDarklightDark = 'dark'"dark""dark""dark""dark""dark":

  g(x,y) <= m(x,y) - v(x,y).

LightDarkLightDarkLightDarkLightDarkLightDarklightDark = 'equal'"equal""equal""equal""equal""equal":

  m(x,y) - v(x,y) <= g(x,y)
      <= m(x,y) + v(x,y).

LightDarkLightDarkLightDarkLightDarkLightDarklightDark = 'not_equal'"not_equal""not_equal""not_equal""not_equal""not_equal":

  m(x,y) - v(x,y) > g(x,y)   or   g(x,y) > m(x,y) + v(x,y).

All pixels fulfilling the above condition are aggregated into the resulting region RegionRegionRegionRegionRegionregion.

For the parameter StdDevScaleStdDevScaleStdDevScaleStdDevScaleStdDevScalestdDevScale values between -1.0 and 1.0 are sensible choices, with 0.2 as a suggested value. If the parameter is too high or too low, an empty or full region may be returned. The parameter AbsThresholdAbsThresholdAbsThresholdAbsThresholdAbsThresholdabsThreshold places an additional threshold on StdDevScaleStdDevScaleStdDevScaleStdDevScaleStdDevScalestdDevScale*d(x,y). If StdDevScaleStdDevScaleStdDevScaleStdDevScaleStdDevScalestdDevScale*d(x,y) is below AbsThresholdAbsThresholdAbsThresholdAbsThresholdAbsThresholdabsThreshold for positive values of StdDevScaleStdDevScaleStdDevScaleStdDevScaleStdDevScalestdDevScale or above for negative values StdDevScaleStdDevScaleStdDevScaleStdDevScaleStdDevScalestdDevScale, AbsThresholdAbsThresholdAbsThresholdAbsThresholdAbsThresholdabsThreshold is taken instead.

Parallelization

Parameters

ImageImageImageImageImageimage (input_object)  singlechannelimage(-array) objectHImageHImageHImageHImageXHobject (byte / int2 / int4 / uint2 / real)

Input image.

RegionRegionRegionRegionRegionregion (output_object)  region(-array) objectHRegionHRegionHRegionHRegionXHobject *

Segmented regions.

MaskWidthMaskWidthMaskWidthMaskWidthMaskWidthmaskWidth (input_control)  extent.x HTupleHTupleHTupleVARIANTHtuple (integer) (int / long) (Hlong) (Hlong) (Hlong) (Hlong)

Mask width for mean and deviation calculation.

Default value: 15

Suggested values: 9, 11, 13, 15

Restriction: MaskWidth >= 1

MaskHeightMaskHeightMaskHeightMaskHeightMaskHeightmaskHeight (input_control)  extent.y HTupleHTupleHTupleVARIANTHtuple (integer) (int / long) (Hlong) (Hlong) (Hlong) (Hlong)

Mask height for mean and deviation calculation.

Default value: 15

Suggested values: 9, 11, 13, 15

Restriction: MaskHeight >= 1

StdDevScaleStdDevScaleStdDevScaleStdDevScaleStdDevScalestdDevScale (input_control)  number HTupleHTupleHTupleVARIANTHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong) (double / Hlong) (double / Hlong)

Factor for the standard deviation of the gray values.

Default value: 0.2

Suggested values: -0.2, -0.1, 0.1, 0.2

AbsThresholdAbsThresholdAbsThresholdAbsThresholdAbsThresholdabsThreshold (input_control)  number HTupleHTupleHTupleVARIANTHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong) (double / Hlong) (double / Hlong)

Minimum gray value difference from the mean.

Default value: 2

Suggested values: -2, -1, 0, 1, 2

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

Threshold type.

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

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

Complexity

Let A be the area of the input region, then the runtime is O(A).

Result

var_thresholdvar_thresholdVarThresholdvar_thresholdVarThresholdVarThreshold returns 2 (H_MSG_TRUE) if all parameters are correct. The behavior with respect to the input images and output regions can be determined by setting the values of the flags 'no_object_result', 'empty_region_result', and 'store_empty_region' with set_system. If necessary, an exception is raised.

Alternatives

dyn_thresholddyn_thresholdDynThresholddyn_thresholdDynThresholdDynThreshold, thresholdthresholdThresholdthresholdThresholdThreshold

References

W.Niblack, ”An Introduction to Digital Image Processing”, Page 115-116, Englewood Cliffs, N.J., Prentice Hall, 1986

Module

Foundation


ClassesClassesClassesClasses | | | | Operators