char_thresholdchar_thresholdCharThresholdCharThresholdchar_threshold (Operator)

Name

char_thresholdchar_thresholdCharThresholdCharThresholdchar_threshold — Segmentieren mit Schwellen für Texte.

Signatur

char_threshold(Image, HistoRegion : Characters : Sigma, Percent : Threshold)

Herror char_threshold(const Hobject Image, const Hobject HistoRegion, Hobject* Characters, double Sigma, double Percent, Hlong* Threshold)

Herror T_char_threshold(const Hobject Image, const Hobject HistoRegion, Hobject* Characters, const Htuple Sigma, const Htuple Percent, Htuple* Threshold)

void CharThreshold(const HObject& Image, const HObject& HistoRegion, HObject* Characters, const HTuple& Sigma, const HTuple& Percent, HTuple* Threshold)

HRegion HImage::CharThreshold(const HRegion& HistoRegion, double Sigma, const HTuple& Percent, HTuple* Threshold) const

HRegion HImage::CharThreshold(const HRegion& HistoRegion, double Sigma, double Percent, Hlong* Threshold) const

static void HOperatorSet.CharThreshold(HObject image, HObject histoRegion, out HObject characters, HTuple sigma, HTuple percent, out HTuple threshold)

HRegion HImage.CharThreshold(HRegion histoRegion, double sigma, HTuple percent, out HTuple threshold)

HRegion HImage.CharThreshold(HRegion histoRegion, double sigma, double percent, out int threshold)

def char_threshold(image: HObject, histo_region: HObject, sigma: float, percent: Union[int, float]) -> Tuple[HObject, Sequence[int]]

def char_threshold_s(image: HObject, histo_region: HObject, sigma: float, percent: Union[int, float]) -> Tuple[HObject, int]

Beschreibung

char_thresholdchar_thresholdCharThresholdCharThresholdCharThresholdchar_threshold ist darauf spezialisiert, in einkanaligen Bildern dunkle Schriftzeichen von hellem Hintergrund zu segmentieren. Die Vorgehensweise ist dabei wie folgt: Zuerst wird das Histogramm der Grauwerte des Bildes ImageImageImageImageimageimage für die Punkte der Region HistoRegionHistoRegionHistoRegionHistoRegionhistoRegionhisto_region ermittelt und zur Rauschunterdrückung mit einer Gaußmaske (Parameter SigmaSigmaSigmaSigmasigmasigma) geglättet. In diesem Histogramm kennzeichnet das Maximum den Hintergrund (weißes Papier), während die Schriftzeichen ein kleines lokales Maximum bei niedrigen Grauwerten verursachen. Im Gegensatz zum Operator binary_thresholdbinary_thresholdBinaryThresholdBinaryThresholdBinaryThresholdbinary_threshold (mit MethodMethodMethodMethodmethodmethod='smooth_histo'"smooth_histo""smooth_histo""smooth_histo""smooth_histo""smooth_histo") wird nun nicht nach dem Minimum zwischen den beiden Maxima gesucht; der Schwellenwert wird stattdessen in Relation zum Maximum des Histogramms, also zum Hintergrund, nach folgender Bedingung bestimmt: Histogramm[Schwellenwert] * 100.0 < Histogramm[Maximum] * (100.0 - PercentPercentPercentPercentpercentpercent) Falls z.B. PercentPercentPercentPercentpercentpercent = 95 gewählt wird, sucht der Operator den Grauwert, dessen Häufigkeit höchstens 5 Prozent der maximalen Häufigkeit beträgt. Da char_thresholdchar_thresholdCharThresholdCharThresholdCharThresholdchar_threshold annimmt, dass die Schriftzeichen dunkler sind als der Hintergrund, wird der Schwellenwert links vom Maximum gesucht.

Im Vergleich zu binary_thresholdbinary_thresholdBinaryThresholdBinaryThresholdBinaryThresholdbinary_threshold sollte char_thresholdchar_thresholdCharThresholdCharThresholdCharThresholdchar_threshold dann eingesetzt werden, wenn kein deutliches Minimum zwischen den beiden zu den Schriftzeichen bzw. zum Hintergrund gehörenden Maxima besteht oder die Schriftzeichen gar kein lokales Maximum verursachen. Dies tritt z.B. bei ungleichmäßiger Beleuchtung auf, oder wenn das Bild nur wenige Schriftzeichen enthält.

Ausführungsinformationen

Parameter

ImageImageImageImageimageimage (input_object)  singlechannelimage(-array) objectHImageHObjectHImageHobject (byte)

Eingabebild.

HistoRegionHistoRegionHistoRegionHistoRegionhistoRegionhisto_region (input_object)  region objectHRegionHObjectHRegionHobject

Region, in der das Histogramm berechnet wird.

CharactersCharactersCharactersCharacterscharacterscharacters (output_object)  region(-array) objectHRegionHObjectHRegionHobject *

Dunkle Bereiche des Bildes (Buchstaben).

SigmaSigmaSigmaSigmasigmasigma (input_control)  number HTuplefloatHTupleHtuple (real) (double) (double) (double)

Sigma für Glättung des Histogramms.

Defaultwert: 2.0

Wertevorschläge: 0.0, 0.5, 1.0, 2.0, 3.0, 4.0, 5.0

Typischer Wertebereich: 0.0 ≤ Sigma Sigma Sigma Sigma sigma sigma ≤ 50.0 (lin)

Minimale Schrittweite: 0.01

Empfohlene Schrittweite: 0.2

PercentPercentPercentPercentpercentpercent (input_control)  number HTupleUnion[int, float]HTupleHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong)

Prozentwert für Grauwertunterschied.

Defaultwert: 95

Wertevorschläge: 90, 92, 95, 96, 97, 98, 99, 99.5, 100

Typischer Wertebereich: 0.0 ≤ Percent Percent Percent Percent percent percent ≤ 100.0 (lin)

Minimale Schrittweite: 0.1

Empfohlene Schrittweite: 0.5

ThresholdThresholdThresholdThresholdthresholdthreshold (output_control)  integer(-array) HTupleSequence[int]HTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Verwendeter Schwellenwert.

Beispiel (HDevelop)

read_image (Image, 'letters')
char_threshold (Image, Image, Seg, 0.0, 5.0, Threshold)
connection (Seg, Connected)

Beispiel (C)

read_image(&Image,"letters");
char_threshold(Image,Image,&Seg,0.0,5.0,&Threshold);
connection(Seg,&Connected);
set_colored(WindowHandle,12);
set_shape(WindowHandle,"rectangle1");
disp_region(Connected,WindowHandle);

Beispiel (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]);
  HWindow      w;
  HTuple       threshold;

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

  image.Display(w);

  HRegionArray reg = image.CharThreshold(image,0,5,&threshold);
  HRegionArray con = reg.Connection();

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

  return 0;
}

Beispiel (HDevelop)

read_image (Image, 'letters')
char_threshold (Image, Image, Seg, 0.0, 5.0, Threshold)
connection (Seg, Connected)

Beispiel (HDevelop)

read_image (Image, 'letters')
char_threshold (Image, Image, Seg, 0.0, 5.0, Threshold)
connection (Seg, Connected)

Vorgänger

anisotropic_diffusionanisotropic_diffusionAnisotropicDiffusionAnisotropicDiffusionAnisotropicDiffusionanisotropic_diffusion, median_imagemedian_imageMedianImageMedianImageMedianImagemedian_image, illuminateilluminateIlluminateIlluminateIlluminateilluminate

Nachfolger

connectionconnectionConnectionConnectionConnectionconnection, select_shapeselect_shapeSelectShapeSelectShapeSelectShapeselect_shape, select_grayselect_graySelectGraySelectGraySelectGrayselect_gray

Alternativen

binary_thresholdbinary_thresholdBinaryThresholdBinaryThresholdBinaryThresholdbinary_threshold, auto_thresholdauto_thresholdAutoThresholdAutoThresholdAutoThresholdauto_threshold, gray_histogray_histoGrayHistoGrayHistoGrayHistogray_histo, smooth_funct_1d_gausssmooth_funct_1d_gaussSmoothFunct1dGaussSmoothFunct1dGaussSmoothFunct1dGausssmooth_funct_1d_gauss, thresholdthresholdThresholdThresholdThresholdthreshold

Modul

Foundation