ClassesClassesClassesClasses | | | | Operators

auto_thresholdauto_thresholdAutoThresholdauto_thresholdAutoThresholdAutoThreshold (Operator)

Name

auto_thresholdauto_thresholdAutoThresholdauto_thresholdAutoThresholdAutoThreshold — Segment an image using thresholds determined from its histogram.

Signature

auto_threshold(Image : Regions : Sigma : )

Herror auto_threshold(const Hobject Image, Hobject* Regions, double Sigma)

Herror T_auto_threshold(const Hobject Image, Hobject* Regions, const Htuple Sigma)

Herror auto_threshold(Hobject Image, Hobject* Regions, const HTuple& Sigma)

HRegionArray HImage::AutoThreshold(const HTuple& Sigma) const

HRegionArray HImageArray::AutoThreshold(const HTuple& Sigma) const

void AutoThreshold(const HObject& Image, HObject* Regions, const HTuple& Sigma)

HRegion HImage::AutoThreshold(const HTuple& Sigma) const

HRegion HImage::AutoThreshold(double Sigma) const

void HOperatorSetX.AutoThreshold(
[in] IHUntypedObjectX* Image, [out] IHUntypedObjectX*Regions, [in] VARIANT Sigma)

IHRegionX* HImageX.AutoThreshold([in] VARIANT Sigma)

static void HOperatorSet.AutoThreshold(HObject image, out HObject regions, HTuple sigma)

HRegion HImage.AutoThreshold(HTuple sigma)

HRegion HImage.AutoThreshold(double sigma)

Description

auto_thresholdauto_thresholdAutoThresholdauto_thresholdAutoThresholdAutoThreshold segments a single-channel image using multiple thresholding. First, the absolute histogram of the gray values is determined. Then, relevant minima are extracted from the histogram, which are used successively as parameters for a thresholding operation. The thresholds used for byte images are 0, 255, and all minima extracted from the histogram (after the histogram has been smoothed with a Gaussian filter with standard deviation SigmaSigmaSigmaSigmaSigmasigma). For each gray value interval one region is generated. Thus, the number of regions is the number of minima + 1. For uint2 images, the above procedure is used analogously. However, here the highest threshold is 65535. Furthermore, for uint2 images the value of SigmaSigmaSigmaSigmaSigmasigma (virtually) refers to a histogram with 256 values, although internally histograms with a higher resolution are used. This is done to facilitate switching between image types without having to change the parameter SigmaSigmaSigmaSigmaSigmasigma. For float images the thresholds are the minimum and maximum gray value in the image and all minima extracted from the histogram. Here, the scaling of the parameter SigmaSigmaSigmaSigmaSigmasigma refers to the original gray values of the image. The larger the value of SigmaSigmaSigmaSigmaSigmasigma is chosen, the fewer regions will be extracted. This operator is useful if the regions to be extracted exhibit similar gray values (homogeneous regions).

Parallelization

Parameters

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

Input image.

RegionsRegionsRegionsRegionsRegionsregions (output_object)  region-array objectHRegionHRegionHRegionArrayHRegionXHobject *

Regions with gray values within the automatically determined intervals.

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

Sigma for the Gaussian smoothing of the histogram.

Default value: 2.0

Suggested values: 0.0, 0.5, 1.0, 2.0, 3.0, 4.0, 5.0

Typical range of values: 0.0 ≤ Sigma Sigma Sigma Sigma Sigma sigma ≤ 100.0 (lin)

Minimum increment: 0.01

Recommended increment: 0.3

Restriction: Sigma >= 0.0

Example (HDevelop)

read_image (Image, 'fabrik')
median_image (Image, Median, 'circle', 3, 'mirrored')
auto_threshold (Median, Seg, 2.0)
connection (Seg, Connected)

Example (C)

read_image(&Image,"fabrik");
median_image(Image,&Median,"circle",3,"mirrored");
auto_threshold(Median,&Seg,2.0);
connection(Seg,&Connected);
set_colored(WindowHandle,12);
disp_obj(Connected,WindowHandle);

Example (HDevelop)

read_image (Image, 'fabrik')
median_image (Image, Median, 'circle', 3, 'mirrored')
auto_threshold (Median, Seg, 2.0)
connection (Seg, Connected)

Example (C++ (HALCON 5.0-10.0))

#include "HIOStream.h"
#if !defined(USE_IOSTREAM_H)
using namespace std;
#endif
#include "HalconCpp.h"
using namespace Halcon;

int main (int argc, char *argv[])
{
  if (argc != 2)
  {
    cout << "Usage : " << argv[0] << " 'image' " << endl;
    return -1;
  }

  HImage       image(argv[1]);
  HImage       med;
  HWindow      w;

  w.SetDraw("margin");
  w.SetColored(12);

  image.Display (w);

  med = image.MedianImage("circle", 3, "mirrored");
  med.Display(w);

  HRegionArray reg = med.AutoThreshold(2.0);
  HRegionArray con = reg.Connection();

  cout << "Display image after AutoThreshold segmentation " << endl;
  con.Display(w);
  w.Click();

  return 0;
}

Example (HDevelop)

read_image (Image, 'fabrik')
median_image (Image, Median, 'circle', 3, 'mirrored')
auto_threshold (Median, Seg, 2.0)
connection (Seg, Connected)

Example (HDevelop)

read_image (Image, 'fabrik')
median_image (Image, Median, 'circle', 3, 'mirrored')
auto_threshold (Median, Seg, 2.0)
connection (Seg, Connected)

Possible Predecessors

anisotropic_diffusionanisotropic_diffusionAnisotropicDiffusionanisotropic_diffusionAnisotropicDiffusionAnisotropicDiffusion, median_imagemedian_imageMedianImagemedian_imageMedianImageMedianImage, illuminateilluminateIlluminateilluminateIlluminateIlluminate

Possible Successors

connectionconnectionConnectionconnectionConnectionConnection, select_shapeselect_shapeSelectShapeselect_shapeSelectShapeSelectShape, select_grayselect_graySelectGrayselect_graySelectGraySelectGray

Alternatives

binary_thresholdbinary_thresholdBinaryThresholdbinary_thresholdBinaryThresholdBinaryThreshold, char_thresholdchar_thresholdCharThresholdchar_thresholdCharThresholdCharThreshold

See also

gray_histogray_histoGrayHistogray_histoGrayHistoGrayHisto, gray_histo_absgray_histo_absGrayHistoAbsgray_histo_absGrayHistoAbsGrayHistoAbs, histo_to_threshhisto_to_threshHistoToThreshhisto_to_threshHistoToThreshHistoToThresh, smooth_funct_1d_gausssmooth_funct_1d_gaussSmoothFunct1dGausssmooth_funct_1d_gaussSmoothFunct1dGaussSmoothFunct1dGauss, thresholdthresholdThresholdthresholdThresholdThreshold

Module

Foundation


ClassesClassesClassesClasses | | | | Operators