class_2dim_supclass_2dim_supClass2dimSupClass2dimSupclass_2dim_sup (Operator)

Name

class_2dim_supclass_2dim_supClass2dimSupClass2dimSupclass_2dim_sup — Segmentieren durch 2-dimensionale Pixelklassifikation.

Signatur

class_2dim_sup(ImageCol, ImageRow, FeatureSpace : RegionClass2Dim : : )

Herror class_2dim_sup(const Hobject ImageCol, const Hobject ImageRow, const Hobject FeatureSpace, Hobject* RegionClass2Dim)

Herror T_class_2dim_sup(const Hobject ImageCol, const Hobject ImageRow, const Hobject FeatureSpace, Hobject* RegionClass2Dim)

void Class2dimSup(const HObject& ImageCol, const HObject& ImageRow, const HObject& FeatureSpace, HObject* RegionClass2Dim)

HRegion HImage::Class2dimSup(const HImage& ImageRow, const HRegion& FeatureSpace) const

static void HOperatorSet.Class2dimSup(HObject imageCol, HObject imageRow, HObject featureSpace, out HObject regionClass2Dim)

HRegion HImage.Class2dimSup(HImage imageRow, HRegion featureSpace)

def class_2dim_sup(image_col: HObject, image_row: HObject, feature_space: HObject) -> HObject

Beschreibung

class_2dim_supclass_2dim_supClass2dimSupClass2dimSupclass_2dim_sup klassifiziert Bildpunkte mit Hilfe von zweikanaligen Bildern und einem zweidimensionalen Merkmalsraum. Für jeden Bildpunkt werden zwei Grauwerte (aus jedem Bild einer) als Merkmale verwendet. Der Merkmalsraum wird durch eine Region repräsentiert. Die Klassifikation wird wie folgt durchgeführt:

Ein Bildpunkt aus der Eingaberegion wird genau dann übernommen, wenn der Punkt , der durch die Grauwerte festgelegt wird, in der Region FeatureSpaceFeatureSpaceFeatureSpacefeatureSpacefeature_space enthalten ist. Dabei ist ein Grauwert aus dem Bild ImageRowImageRowImageRowimageRowimage_row und ein Grauwert aus dem Bild ImageColImageColImageColimageColimage_col.

Sei ein Bildpunkt mit den Koordinaten , der Grauwert an der Position in dem Bild ImageRowImageRowImageRowimageRowimage_row und der Grauwert an der Position in dem Bild ImageColImageColImageColimageColimage_col. Dann wird er in die Ergebnisregion (RegionClass2DimRegionClass2DimRegionClass2DimregionClass2Dimregion_class_2dim) übernommen, falls: wird also als Zeilen- und als Spaltenkoordinate interpretiert.

Für die Erzeugung von FeatureSpaceFeatureSpaceFeatureSpacefeatureSpacefeature_space siehe histo_2dimhisto_2dimHisto2dimHisto2dimhisto_2dim. Der Merkmalsraum kann vor der Anwendung von class_2dim_supclass_2dim_supClass2dimSupClass2dimSupclass_2dim_sup noch mit Regionentransformationen wie rank_regionrank_regionRankRegionRankRegionrank_region, dilation1dilation1Dilation1Dilation1dilation1, shape_transshape_transShapeTransShapeTransshape_trans, elliptic_axiselliptic_axisEllipticAxisEllipticAxiselliptic_axis, etc. bearbeitet werden.

Die Parameter ImageColImageColImageColimageColimage_col und ImageRowImageRowImageRowimageRowimage_row müssen gleich viele Bilder mit jeweils gleicher Größe enthalten. Die Bildpunkte werden aus dem Durchschnitt der beiden Definitionsbereiche entnommen (siehe reduce_domainreduce_domainReduceDomainReduceDomainreduce_domain).

Ausführungsinformationen

Parameter

ImageColImageColImageColimageColimage_col (input_object)  singlechannelimage(-array) objectHImageHObjectHObjectHobject (byte / direction / cyclic / int1)

Bild mit Grauwerten für ersten Kanal.

ImageRowImageRowImageRowimageRowimage_row (input_object)  singlechannelimage(-array) objectHImageHObjectHObjectHobject (byte / direction / cyclic / int1)

Bild mit Grauwerten für zweiten Kanal.

FeatureSpaceFeatureSpaceFeatureSpacefeatureSpacefeature_space (input_object)  region(-array) objectHRegionHObjectHObjectHobject

Region, die den Merkmalsraum festlegt.

RegionClass2DimRegionClass2DimRegionClass2DimregionClass2Dimregion_class_2dim (output_object)  region(-array) objectHRegionHObjectHObjectHobject *

Regionen, die das Klassifikationskriterium erfüllen.

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);
  }

  HRegion   feats, cd2reg;
  HImage    image (argv[1]),
            text1, text2,
            mean1, mean2,
            histo;

  HWindow   win;
  Hlong      nc;

  if ((nc = image.CountChannels ()) != 3)
  {
    cout << argv[1] << " is not a rgb-image " << endl;
    return (-2);
  }

  image.Display (win);

  win.SetColor ("green");
  cout << "Draw the region of interrest " << endl;

  HRegion  region = win.DrawRegion ();

  text1 = image.TextureLaws ("el", 2, 5);
  mean1 = text1.MeanImage (21, 21);
  text2 = mean1.TextureLaws ("es", 2, 5);
  mean2 = text2.MeanImage (21, 21);

  histo = region.Histo2dim (mean1, mean2);
  feats = histo.Threshold (1.0, 1000000.0);

  win.SetDraw ("fill");
  win.SetColor ("red");

  feats.Display (win);

  cout << "Charakteristics area in red" << endl;

  cd2reg = mean1.Class2dimSup (mean2, feats);

  win.SetColor ("blue");
  cd2reg.Display (win);

  cout << "Result of classification in blue " << endl;
  win.Click ();
  return (0);
}

Beispiel (C)

read_image(&Image,"combine");
open_window(0,0,-1,-1,0,"visible","",&WindowHandle);
disp_image(Image,WindowHandle);
fwrite_string("draw region of interest with the mouse");
fnew_line();
set_color(WindowHandle,"green");
draw_region(&Testreg,draw_region);
/* Texture transformation for 2-dimensional charachteristic */
texture_laws(Image,&T1,"el",2,5);
mean_image(T1,&M1,21,21);
texture_laws(M1,&T2,"es,",2,5);
mean_image(T2,&M2,21,21);
/* 2-dimensinal histogram of the test region */
histo_2dim(Testreg,M1,M2,&Histo);
/* All points occuring at least once */
threshold(Histo,&FeatureSpace,1.0,100000.0);
set_draw(WindowHandle,"fill");
set_color(WindowHandle,"red");
disp_region(FeatureSpace,WindowHandle);
fwrite_string("Characteristics area in red");
fnew_line();
/* Segmentation */
class_2dim_sup(M1,M2,FeatureSpace,&RegionClass2Dim);
set_color(WindowHandle,"blue");
disp_region(RegionClass2Dim,WindowHandle);
fwrite_string("Result of classification in blue");
fnew_line();

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);
  }

  HRegion   feats, cd2reg;
  HImage    image (argv[1]),
            text1, text2,
            mean1, mean2,
            histo;

  HWindow   win;
  Hlong      nc;

  if ((nc = image.CountChannels ()) != 3)
  {
    cout << argv[1] << " is not a rgb-image " << endl;
    return (-2);
  }

  image.Display (win);

  win.SetColor ("green");
  cout << "Draw the region of interrest " << endl;

  HRegion  region = win.DrawRegion ();

  text1 = image.TextureLaws ("el", 2, 5);
  mean1 = text1.MeanImage (21, 21);
  text2 = mean1.TextureLaws ("es", 2, 5);
  mean2 = text2.MeanImage (21, 21);

  histo = region.Histo2dim (mean1, mean2);
  feats = histo.Threshold (1.0, 1000000.0);

  win.SetDraw ("fill");
  win.SetColor ("red");

  feats.Display (win);

  cout << "Charakteristics area in red" << endl;

  cd2reg = mean1.Class2dimSup (mean2, feats);

  win.SetColor ("blue");
  cd2reg.Display (win);

  cout << "Result of classification in blue " << endl;
  win.Click ();
  return (0);
}

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);
  }

  HRegion   feats, cd2reg;
  HImage    image (argv[1]),
            text1, text2,
            mean1, mean2,
            histo;

  HWindow   win;
  Hlong      nc;

  if ((nc = image.CountChannels ()) != 3)
  {
    cout << argv[1] << " is not a rgb-image " << endl;
    return (-2);
  }

  image.Display (win);

  win.SetColor ("green");
  cout << "Draw the region of interrest " << endl;

  HRegion  region = win.DrawRegion ();

  text1 = image.TextureLaws ("el", 2, 5);
  mean1 = text1.MeanImage (21, 21);
  text2 = mean1.TextureLaws ("es", 2, 5);
  mean2 = text2.MeanImage (21, 21);

  histo = region.Histo2dim (mean1, mean2);
  feats = histo.Threshold (1.0, 1000000.0);

  win.SetDraw ("fill");
  win.SetColor ("red");

  feats.Display (win);

  cout << "Charakteristics area in red" << endl;

  cd2reg = mean1.Class2dimSup (mean2, feats);

  win.SetColor ("blue");
  cd2reg.Display (win);

  cout << "Result of classification in blue " << endl;
  win.Click ();
  return (0);
}

Komplexität

Sei A die Fläche der Eingaberegion dann ist die Laufzeitkomplexität O(256^2 + A).

Ergebnis

class_2dim_supclass_2dim_supClass2dimSupClass2dimSupclass_2dim_sup liefert den Wert 2 ( H_MSG_TRUE) . Falls alle Parameter korrekt sind für das Verhalten bzgl. der Eingabebilder und Ausgaberegionen sind die Flags 'no_object_result'"no_object_result""no_object_result""no_object_result""no_object_result", 'empty_region_result'"empty_region_result""empty_region_result""empty_region_result""empty_region_result" und 'store_empty_region'"store_empty_region""store_empty_region""store_empty_region""store_empty_region" einstellbar (siehe set_systemset_systemSetSystemSetSystemset_system). Gegebenenfalls wird eine Fehlerbehandlung durchgeführt.

Vorgänger

histo_2dimhisto_2dimHisto2dimHisto2dimhisto_2dim, thresholdthresholdThresholdThresholdthreshold, draw_regiondraw_regionDrawRegionDrawRegiondraw_region, dilation1dilation1Dilation1Dilation1dilation1, openingopeningOpeningOpeningopening, shape_transshape_transShapeTransShapeTransshape_trans

Nachfolger

connectionconnectionConnectionConnectionconnection, select_shapeselect_shapeSelectShapeSelectShapeselect_shape, select_grayselect_graySelectGraySelectGrayselect_gray

Alternativen

class_ndim_normclass_ndim_normClassNdimNormClassNdimNormclass_ndim_norm, thresholdthresholdThresholdThresholdthreshold

Siehe auch

histo_2dimhisto_2dimHisto2dimHisto2dimhisto_2dim

Modul

Foundation