bin_thresholdbin_thresholdBinThresholdBinThresholdbin_threshold (Operator)

Name

bin_thresholdbin_thresholdBinThresholdBinThresholdbin_threshold — Segment an image using an automatically determined threshold.

Warning

bin_thresholdbin_thresholdBinThresholdBinThresholdbin_threshold is obsolete and is only provided for reasons of backward compatibility. The operator will be removed with HALCON 25.05. New applications should use the operator binary_thresholdbinary_thresholdBinaryThresholdBinaryThresholdbinary_threshold instead.

Signature

bin_threshold(Image : Region : : )

Herror bin_threshold(const Hobject Image, Hobject* Region)

Herror T_bin_threshold(const Hobject Image, Hobject* Region)

void BinThreshold(const HObject& Image, HObject* Region)

HRegion HImage::BinThreshold() const

static void HOperatorSet.BinThreshold(HObject image, out HObject region)

HRegion HImage.BinThreshold()

def bin_threshold(image: HObject) -> HObject

Description

bin_thresholdbin_thresholdBinThresholdBinThresholdbin_threshold segments a single-channel gray value image using an automatically determined threshold. 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_thresholdAutoThresholdAutoThresholdauto_threshold. The mask size is enlarged until there is only one minimum in the smoothed histogram. The selected region contains the pixels with gray values from 0 to the minimum or for real images from the smallest value to the respective minimum. This operator is, for example useful for the segmentation of dark characters on a light paper.

Execution Information

Parameters

ImageImageImageimageimage (input_object)  singlechannelimage(-array) objectHImageHObjectHObjectHobject (byte / uint2 / real)

Input image.

RegionRegionRegionregionregion (output_object)  region(-array) objectHRegionHObjectHObjectHobject *

Dark regions of the image.

Example (HDevelop)

read_image (Image, 'letters')
bin_threshold (Image, Seg)
connection (Seg, Connected)

Example (C)

read_image(&Image,"letters");
bin_threshold(Image,&Seg);
connection(Seg,&Connected);
set_shape(WindowHandle,"rectangle1");
set_colored(WindowHandle,6);
disp_region(Connected,WindowHandle);

Example (C++)

#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.SetShape("rectangle1");
  w.SetColored(12);

  image.Display(w);

  HRegionArray reg = image.BinThreshold();
  HRegionArray con = reg.Connection();

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

  return 0;
}

Example (HDevelop)

read_image (Image, 'letters')
bin_threshold (Image, Seg)
connection (Seg, Connected)

Module

Foundation