HALCON Reference Manual 10.0.2
Table of Contents / Regions / Features ClassesClassesClasses | | | Operators

select_shape_protoselect_shape_protoselect_shape_protoSelectShapeProtoSelectShapeProto (Operator)

Name

select_shape_protoselect_shape_protoselect_shape_protoSelectShapeProtoSelectShapeProto — Choose regions having a certain relation to each other.

Signature

select_shape_proto(Regions, Pattern : SelectedRegions : Feature, Min, Max : )

Herror select_shape_proto(const Hobject Regions, const Hobject Pattern, Hobject* SelectedRegions, const char* Feature, double Min, double Max)

Herror T_select_shape_proto(const Hobject Regions, const Hobject Pattern, Hobject* SelectedRegions, const Htuple Feature, const Htuple Min, const Htuple Max)

Herror select_shape_proto(Hobject Regions, Hobject Pattern, Hobject* SelectedRegions, const HTuple& Feature, const HTuple& Min, const HTuple& Max)

HRegion HRegion::SelectShapeProto(const HRegion& Pattern, const HTuple& Feature, const HTuple& Min, const HTuple& Max) const

HRegionArray HRegionArray::SelectShapeProto(const HRegionArray& Pattern, const HTuple& Feature, const HTuple& Min, const HTuple& Max) const

void HOperatorSetX.SelectShapeProto(
[in] IHUntypedObjectX* Regions, [in] IHUntypedObjectX* Pattern, [out] IHUntypedObjectX*SelectedRegions, [in] VARIANT Feature, [in] VARIANT Min, [in] VARIANT Max)

IHRegionX* HRegionX.SelectShapeProto(
[in] IHRegionX* Pattern, [in] VARIANT Feature, [in] VARIANT Min, [in] VARIANT Max)

static void HOperatorSet.SelectShapeProto(HObject regions, HObject pattern, out HObject selectedRegions, HTuple feature, HTuple min, HTuple max)

HRegion HRegion.SelectShapeProto(HRegion pattern, HTuple feature, HTuple min, HTuple max)

HRegion HRegion.SelectShapeProto(HRegion pattern, string feature, double min, double max)

Description

The operator select_shape_protoselect_shape_protoselect_shape_protoSelectShapeProtoSelectShapeProto selects regions based on certain relations between the regions. Every region from RegionsRegionsRegionsRegionsregions is compared to the union of regions from PatternPatternPatternPatternpattern. The limits (MinMinMinMinmin and MaxMaxMaxMaxmax) are specified absolutely or in percent (0..100), depending on the feature. Possible values for FeatureFeatureFeatureFeaturefeature are:

'distance_dilate'

The minimum distance in the maximum norm from the edge of PatternPatternPatternPatternpattern to the edge of every region from RegionsRegionsRegionsRegionsregions is determined (see distance_rr_min_dildistance_rr_min_dildistance_rr_min_dilDistanceRrMinDilDistanceRrMinDil).

'distance_contour'

The minimum Euclidean distance from the edge of PatternPatternPatternPatternpattern to the edge of every region from RegionsRegionsRegionsRegionsregions is determined. (see distance_rr_mindistance_rr_mindistance_rr_minDistanceRrMinDistanceRrMin).

'distance_center'

The Euclidean distance from the center of PatternPatternPatternPatternpattern to the center of every region from RegionsRegionsRegionsRegionsregions is determined.

'covers'

It is examined how well the region PatternPatternPatternPatternpattern fits into the regions from RegionsRegionsRegionsRegionsregions. If there is no shift so that PatternPatternPatternPatternpattern is a subset of RegionsRegionsRegionsRegionsregions the overlap is 0. If PatternPatternPatternPatternpattern corresponds to the region after a corresponding shift the overlap is 100. Otherwise the area of the opening of RegionsRegionsRegionsRegionsregions with PatternPatternPatternPatternpattern is put into relation with the area of RegionsRegionsRegionsRegionsregions (in percent).

'fits'

It is examined whether PatternPatternPatternPatternpattern can be shifted in such a way that it fits in RegionsRegionsRegionsRegionsregions. If this is possible the corresponding region is copied from RegionsRegionsRegionsRegionsregions. The parameters MinMinMinMinmin and MaxMaxMaxMaxmax are ignored.

'overlaps_abs'

The area of the intersection of PatternPatternPatternPatternpattern and every region in RegionsRegionsRegionsRegionsregions is computed.

'overlaps_rel'

The area of the intersection of PatternPatternPatternPatternpattern and every region in RegionsRegionsRegionsRegionsregions is computed. The relative overlap is the ratio of the area of the intersection and the are of the respective region in RegionsRegionsRegionsRegionsregions (in percent).

Parallelization

Parameters

RegionsRegionsRegionsRegionsregions (input_object)  region(-array) objectHRegionHRegionHRegionXHobject

Regions to be examined.

PatternPatternPatternPatternpattern (input_object)  region(-array) objectHRegionHRegionHRegionXHobject

Region compared to RegionsRegionsRegionsRegionsregions.

SelectedRegionsSelectedRegionsSelectedRegionsSelectedRegionsselectedRegions (output_object)  region(-array) objectHRegionHRegionHRegionXHobject *

Regions fulfilling the condition.

FeatureFeatureFeatureFeaturefeature (input_control)  string(-array) HTupleHTupleVARIANTHtuple (string) (string) (char*) (BSTR) (char*)

Shape features to be checked.

Default value: 'covers' "covers" "covers" "covers" "covers"

List of values: 'distance_center'"distance_center""distance_center""distance_center""distance_center", 'distance_dilate'"distance_dilate""distance_dilate""distance_dilate""distance_dilate", 'distance_contour'"distance_contour""distance_contour""distance_contour""distance_contour", 'covers'"covers""covers""covers""covers", 'fits'"fits""fits""fits""fits", 'overlaps_abs'"overlaps_abs""overlaps_abs""overlaps_abs""overlaps_abs", 'overlaps_rel'"overlaps_rel""overlaps_rel""overlaps_rel""overlaps_rel"

MinMinMinMinmin (input_control)  number HTupleHTupleVARIANTHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong) (double / Hlong)

Lower border of feature.

Default value: 50.0

Suggested values: 0.0, 1.0, 5.0, 10.0, 20.0, 30.0, 50.0, 60.0, 70.0, 80.0, 90.0, 95.0, 99.0, 100.0, 200.0, 400.0

Typical range of values: 0.0 ≤ Min Min Min Min min

Minimum increment: 0.001

Recommended increment: 5.0

MaxMaxMaxMaxmax (input_control)  number HTupleHTupleVARIANTHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong) (double / Hlong)

Upper border of the feature.

Default value: 100.0

Suggested values: 0.0, 10.0, 20.0, 30.0, 50.0, 60.0, 70.0, 80.0, 90.0, 95.0, 99.0, 100.0, 200.0, 300.0, 400.0

Typical range of values: 0.0 ≤ Max Max Max Max max

Minimum increment: 0.001

Recommended increment: 5.0

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] << " <radius of circle>" << endl;
    exit (1);
  }

  double   rad = atof (argv[1]);
  HImage   img ("monkey");
  HWindow  w;

  img.Display (w);

  HRegion       circ = HRegion::GenCircle (100, 100, rad);
  HRegionArray  reg  = img.Regiongrowing (3, 3, 5, 0);
  HRegionArray  seg  = reg.SelectShapeProto (circ, "fits", 0, 0);

  w.SetColor  ("red");
  seg.Display (w);
  w.Click ();
  return(0);
}

Example (C)

regiongrowing(Image,&Seg,3,3,5.0,0);
gen_circle(&C,100.0,100.0,MinRadius);
select_shape_proto(Seg,C,"fits",0.0,0.0);

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] << " <radius of circle>" << endl;
    exit (1);
  }

  double   rad = atof (argv[1]);
  HImage   img ("monkey");
  HWindow  w;

  img.Display (w);

  HRegion       circ = HRegion::GenCircle (100, 100, rad);
  HRegionArray  reg  = img.Regiongrowing (3, 3, 5, 0);
  HRegionArray  seg  = reg.SelectShapeProto (circ, "fits", 0, 0);

  w.SetColor  ("red");
  seg.Display (w);
  w.Click ();
  return(0);
}

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] << " <radius of circle>" << endl;
    exit (1);
  }

  double   rad = atof (argv[1]);
  HImage   img ("monkey");
  HWindow  w;

  img.Display (w);

  HRegion       circ = HRegion::GenCircle (100, 100, rad);
  HRegionArray  reg  = img.Regiongrowing (3, 3, 5, 0);
  HRegionArray  seg  = reg.SelectShapeProto (circ, "fits", 0, 0);

  w.SetColor  ("red");
  seg.Display (w);
  w.Click ();
  return(0);
}

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] << " <radius of circle>" << endl;
    exit (1);
  }

  double   rad = atof (argv[1]);
  HImage   img ("monkey");
  HWindow  w;

  img.Display (w);

  HRegion       circ = HRegion::GenCircle (100, 100, rad);
  HRegionArray  reg  = img.Regiongrowing (3, 3, 5, 0);
  HRegionArray  seg  = reg.SelectShapeProto (circ, "fits", 0, 0);

  w.SetColor  ("red");
  seg.Display (w);
  w.Click ();
  return(0);
}

Result

The operator select_shape_protoselect_shape_protoselect_shape_protoSelectShapeProtoSelectShapeProto returns the value 2 (H_MSG_TRUE) if the input is not empty. The behavior in case of empty input (no input regions available) is set via the operator set_system('no_object_result',<Result>)set_system("no_object_result",<Result>)set_system("no_object_result",<Result>)SetSystem("no_object_result",<Result>)SetSystem("no_object_result",<Result>). The behavior in case of empty region (the region is the empty set) is set via set_system('empty_region_result',<Result>)set_system("empty_region_result",<Result>)set_system("empty_region_result",<Result>)SetSystem("empty_region_result",<Result>)SetSystem("empty_region_result",<Result>). If necessary an exception is raised.

Possible Predecessors

connectionconnectionconnectionConnectionConnection, draw_regiondraw_regiondraw_regionDrawRegionDrawRegion, gen_circlegen_circlegen_circleGenCircleGenCircle, gen_rectangle1gen_rectangle1gen_rectangle1GenRectangle1GenRectangle1, gen_rectangle2gen_rectangle2gen_rectangle2GenRectangle2GenRectangle2, gen_ellipsegen_ellipsegen_ellipseGenEllipseGenEllipse

Possible Successors

select_grayselect_grayselect_graySelectGraySelectGray, shape_transshape_transshape_transShapeTransShapeTrans, reduce_domainreduce_domainreduce_domainReduceDomainReduceDomain, count_objcount_objcount_objCountObjCountObj

Alternatives

select_shapeselect_shapeselect_shapeSelectShapeSelectShape

See also

openingopeningopeningOpeningOpening, erosion1erosion1erosion1Erosion1Erosion1, distance_rr_min_dildistance_rr_min_dildistance_rr_min_dilDistanceRrMinDilDistanceRrMinDil, distance_rr_mindistance_rr_mindistance_rr_minDistanceRrMinDistanceRrMin

Module

Foundation


Table of Contents / Regions / Features ClassesClassesClasses | | | Operators
HALCON Reference Manual 10.0.2 Copyright © 1996-2011 MVTec Software GmbH