ClassesClassesClassesClasses | | | | Operators

class_2dim_supclass_2dim_supClass2dimSupclass_2dim_supClass2dimSupClass2dimSup (Operator)

Name

class_2dim_supclass_2dim_supClass2dimSupclass_2dim_supClass2dimSupClass2dimSup — Segment an image using two-dimensional pixel classification.

Signature

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)

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

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

HRegionArray HImageArray::Class2dimSup(const HImageArray& ImageRow, const HRegionArray& FeatureSpace) const

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

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

void HOperatorSetX.Class2dimSup(
[in] IHUntypedObjectX* ImageCol, [in] IHUntypedObjectX* ImageRow, [in] IHUntypedObjectX* FeatureSpace, [out] IHUntypedObjectX*RegionClass2Dim)

IHRegionX* HImageX.Class2dimSup(
[in] IHImageX* ImageRow, [in] IHRegionX* FeatureSpace)

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

HRegion HImage.Class2dimSup(HImage imageRow, HRegion featureSpace)

Description

class_2dim_supclass_2dim_supClass2dimSupclass_2dim_supClass2dimSupClass2dimSup classifies the points in two-channel images using a two-dimensional feature space. For each point, two gray values (one from each image) are used as features. The feature space is represented by the input region. The classification is done as follows:

A point from the input region of an image is accepted if the point (g_{r},g_{c}), which is determined by the respective gray values, is contained in the region FeatureSpaceFeatureSpaceFeatureSpaceFeatureSpaceFeatureSpacefeatureSpace. g_{r} is here a gray value from the image ImageRowImageRowImageRowImageRowImageRowimageRow, while g_{c} is the corresponding gray value from ImageColImageColImageColImageColImageColimageCol.

Let P be a point with the coordinates P=(R,C), g_{r} be the gray value at position (R,C) in the image ImageRowImageRowImageRowImageRowImageRowimageRow, and g_{c} be the gray value at position (R,C) in the image ImageColImageColImageColImageColImageColimageCol. Then the point P is aggregated into the output region if

      (g_r,g_c)  is an element of FeatureSpaceFeatureSpaceFeatureSpaceFeatureSpaceFeatureSpacefeatureSpace

g_{r} is interpreted as row coordinate and g_{c} as column coordinate.

For the generation of FeatureSpaceFeatureSpaceFeatureSpaceFeatureSpaceFeatureSpacefeatureSpace, see histo_2dimhisto_2dimHisto2dimhisto_2dimHisto2dimHisto2dim. The feature space can be modified by applying region transformation operators, such as rank_regionrank_regionRankRegionrank_regionRankRegionRankRegion, dilation1dilation1Dilation1dilation1Dilation1Dilation1, shape_transshape_transShapeTransshape_transShapeTransShapeTrans, elliptic_axiselliptic_axisEllipticAxiselliptic_axisEllipticAxisEllipticAxis, etc., before calling class_2dim_supclass_2dim_supClass2dimSupclass_2dim_supClass2dimSupClass2dimSup.

The parameters ImageColImageColImageColImageColImageColimageCol and ImageRowImageRowImageRowImageRowImageRowimageRow must contain an equal number of images with the same size. The image points are taken from the intersection of the domains of both images (see reduce_domainreduce_domainReduceDomainreduce_domainReduceDomainReduceDomain).

Parallelization

Parameters

ImageColImageColImageColImageColImageColimageCol (input_object)  singlechannelimage(-array) objectHImageHImageHImageHImageXHobject (byte / direction / cyclic / int1)

Input image (first channel).

ImageRowImageRowImageRowImageRowImageRowimageRow (input_object)  singlechannelimage(-array) objectHImageHImageHImageHImageXHobject (byte / direction / cyclic / int1)

Input image (second channel).

FeatureSpaceFeatureSpaceFeatureSpaceFeatureSpaceFeatureSpacefeatureSpace (input_object)  region(-array) objectHRegionHRegionHRegionHRegionXHobject

Region defining the feature space.

RegionClass2DimRegionClass2DimRegionClass2DimRegionClass2DimRegionClass2DimregionClass2Dim (output_object)  region(-array) objectHRegionHRegionHRegionHRegionXHobject *

Classified regions.

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

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

Example (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);
clear_obj(T1);
texture_laws(M1,&T2,"es,",2,5);
mean_image(T2,&M2,21,21);
clear_obj(T2);
/* 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();

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

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

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

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

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

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

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

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

Complexity

Let A be the area of the input region. Then the runtime complexity is O(256^2 + A).

Result

class_2dim_supclass_2dim_supClass2dimSupclass_2dim_supClass2dimSupClass2dimSup 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'"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""empty_region_result", and 'store_empty_region'"store_empty_region""store_empty_region""store_empty_region""store_empty_region""store_empty_region" with set_systemset_systemSetSystemset_systemSetSystemSetSystem. If necessary, an exception is raised.

Possible Predecessors

histo_2dimhisto_2dimHisto2dimhisto_2dimHisto2dimHisto2dim, thresholdthresholdThresholdthresholdThresholdThreshold, draw_regiondraw_regionDrawRegiondraw_regionDrawRegionDrawRegion, dilation1dilation1Dilation1dilation1Dilation1Dilation1, openingopeningOpeningopeningOpeningOpening, shape_transshape_transShapeTransshape_transShapeTransShapeTrans

Possible Successors

connectionconnectionConnectionconnectionConnectionConnection, select_shapeselect_shapeSelectShapeselect_shapeSelectShapeSelectShape, select_grayselect_graySelectGrayselect_graySelectGraySelectGray

Alternatives

class_ndim_normclass_ndim_normClassNdimNormclass_ndim_normClassNdimNormClassNdimNorm, class_ndim_boxclass_ndim_boxClassNdimBoxclass_ndim_boxClassNdimBoxClassNdimBox, thresholdthresholdThresholdthresholdThresholdThreshold

See also

histo_2dimhisto_2dimHisto2dimhisto_2dimHisto2dimHisto2dim

Module

Foundation


ClassesClassesClassesClasses | | | | Operators