ClassesClassesClassesClasses | | | | Operators

class_2dim_unsupclass_2dim_unsupClass2dimUnsupclass_2dim_unsupClass2dimUnsupClass2dimUnsup (Operator)

Name

class_2dim_unsupclass_2dim_unsupClass2dimUnsupclass_2dim_unsupClass2dimUnsupClass2dimUnsup — Segment two images by clustering.

Signature

class_2dim_unsup(Image1, Image2 : Classes : Threshold, NumClasses : )

Herror class_2dim_unsup(const Hobject Image1, const Hobject Image2, Hobject* Classes, const Hlong Threshold, const Hlong NumClasses)

Herror T_class_2dim_unsup(const Hobject Image1, const Hobject Image2, Hobject* Classes, const Htuple Threshold, const Htuple NumClasses)

Herror class_2dim_unsup(Hobject Image1, Hobject Image2, Hobject* Classes, const HTuple& Threshold, const HTuple& NumClasses)

HRegionArray HImage::Class2dimUnsup(const HImage& Image2, const HTuple& Threshold, const HTuple& NumClasses) const

void Class2dimUnsup(const HObject& Image1, const HObject& Image2, HObject* Classes, const HTuple& Threshold, const HTuple& NumClasses)

HRegion HImage::Class2dimUnsup(const HImage& Image2, Hlong Threshold, Hlong NumClasses) const

void HOperatorSetX.Class2dimUnsup(
[in] IHUntypedObjectX* Image1, [in] IHUntypedObjectX* Image2, [out] IHUntypedObjectX*Classes, [in] VARIANT Threshold, [in] VARIANT NumClasses)

IHRegionX* HImageX.Class2dimUnsup(
[in] IHImageX* Image2, [in] Hlong Threshold, [in] Hlong NumClasses)

static void HOperatorSet.Class2dimUnsup(HObject image1, HObject image2, out HObject classes, HTuple threshold, HTuple numClasses)

HRegion HImage.Class2dimUnsup(HImage image2, int threshold, int numClasses)

Description

class_2dim_unsupclass_2dim_unsupClass2dimUnsupclass_2dim_unsupClass2dimUnsupClass2dimUnsup performs a classification with two single-channel images. First, a two-dimensional histogram of the two images is computed (histo_2dimhisto_2dimHisto2dimhisto_2dimHisto2dimHisto2dim). In this histogram, the first maximum is extracted; it serves as the first cluster center. The histogram is computed with the intersection of the domains of both images (see reduce_domainreduce_domainReduceDomainreduce_domainReduceDomainReduceDomain). After this, all pixels in the images that are at most ThresholdThresholdThresholdThresholdThresholdthreshold pixels from the cluster center in the maximum norm, are determined. These pixels form one output region. Next, the pixels thus classified are deleted from the histogram so that they are not taken into account for the next class. In this modified histogram, again the maximum is extracted; it again serves as a cluster center. The above steps are repeated NumClassesNumClassesNumClassesNumClassesNumClassesnumClasses times; thus, NumClassesNumClassesNumClassesNumClassesNumClassesnumClasses output regions result. Only pixels defined in both images are returned.

Attention

Both input images must have the same size.

Parallelization

Parameters

Image1Image1Image1Image1Image1image1 (input_object)  singlechannelimage objectHImageHImageHImageHImageXHobject (byte)

First input image.

Image2Image2Image2Image2Image2image2 (input_object)  singlechannelimage objectHImageHImageHImageHImageXHobject (byte)

Second input image.

ClassesClassesClassesClassesClassesclasses (output_object)  region-array objectHRegionHRegionHRegionArrayHRegionXHobject *

Classification result.

ThresholdThresholdThresholdThresholdThresholdthreshold (input_control)  integer HTupleHTupleHTupleVARIANTHtuple (integer) (int / long) (Hlong) (Hlong) (Hlong) (Hlong)

Threshold (maximum distance to the cluster's center).

Default value: 15

Suggested values: 0, 2, 5, 8, 12, 17, 20, 30, 50, 70

NumClassesNumClassesNumClassesNumClassesNumClassesnumClasses (input_control)  integer HTupleHTupleHTupleVARIANTHtuple (integer) (int / long) (Hlong) (Hlong) (Hlong) (Hlong)

Number of classes (cluster centers).

Default value: 5

Suggested values: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 15, 20, 30, 40, 50

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   colimg (argv[1]),
           green, blue;

  HWindow  w;
  Hlong     nc;

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

  colimg.Display (w);

  HImage        red = colimg.Decompose3 (&green, &blue);
  HRegionArray  seg = red.Class2dimUnsup (green, 15, 5);

  w.SetDraw ("margin");
  w.SetColored (12);
  seg.Display (w);
  w.Click ();

  return (0);
}

Example (C)

read_image(&ColorImage,"patras");
decompose3(ColorImage,&Red,&Green,&Blue);
class_2dim_unsup(Red,Green,&Seg,15,5);
set_colored(WindowHandle,12);
disp_region(Seg,WindowHandle);

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   colimg (argv[1]),
           green, blue;

  HWindow  w;
  Hlong     nc;

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

  colimg.Display (w);

  HImage        red = colimg.Decompose3 (&green, &blue);
  HRegionArray  seg = red.Class2dimUnsup (green, 15, 5);

  w.SetDraw ("margin");
  w.SetColored (12);
  seg.Display (w);
  w.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);
  }

  HImage   colimg (argv[1]),
           green, blue;

  HWindow  w;
  Hlong     nc;

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

  colimg.Display (w);

  HImage        red = colimg.Decompose3 (&green, &blue);
  HRegionArray  seg = red.Class2dimUnsup (green, 15, 5);

  w.SetDraw ("margin");
  w.SetColored (12);
  seg.Display (w);
  w.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);
  }

  HImage   colimg (argv[1]),
           green, blue;

  HWindow  w;
  Hlong     nc;

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

  colimg.Display (w);

  HImage        red = colimg.Decompose3 (&green, &blue);
  HRegionArray  seg = red.Class2dimUnsup (green, 15, 5);

  w.SetDraw ("margin");
  w.SetColored (12);
  seg.Display (w);
  w.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);
  }

  HImage   colimg (argv[1]),
           green, blue;

  HWindow  w;
  Hlong     nc;

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

  colimg.Display (w);

  HImage        red = colimg.Decompose3 (&green, &blue);
  HRegionArray  seg = red.Class2dimUnsup (green, 15, 5);

  w.SetDraw ("margin");
  w.SetColored (12);
  seg.Display (w);
  w.Click ();

  return (0);
}

Result

class_2dim_unsupclass_2dim_unsupClass2dimUnsupclass_2dim_unsupClass2dimUnsupClass2dimUnsup 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

decompose2decompose2Decompose2decompose2Decompose2Decompose2, decompose3decompose3Decompose3decompose3Decompose3Decompose3, median_imagemedian_imageMedianImagemedian_imageMedianImageMedianImage, anisotropic_diffusionanisotropic_diffusionAnisotropicDiffusionanisotropic_diffusionAnisotropicDiffusionAnisotropicDiffusion, reduce_domainreduce_domainReduceDomainreduce_domainReduceDomainReduceDomain

Possible Successors

select_shapeselect_shapeSelectShapeselect_shapeSelectShapeSelectShape, select_grayselect_graySelectGrayselect_graySelectGraySelectGray, connectionconnectionConnectionconnectionConnectionConnection

Alternatives

thresholdthresholdThresholdthresholdThresholdThreshold, histo_2dimhisto_2dimHisto2dimhisto_2dimHisto2dimHisto2dim, class_2dim_supclass_2dim_supClass2dimSupclass_2dim_supClass2dimSupClass2dimSup, class_ndim_normclass_ndim_normClassNdimNormclass_ndim_normClassNdimNormClassNdimNorm, class_ndim_boxclass_ndim_boxClassNdimBoxclass_ndim_boxClassNdimBoxClassNdimBox

Module

Foundation


ClassesClassesClassesClasses | | | | Operators