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

select_shapeselect_shapeselect_shapeSelectShapeSelectShape (Operator)

Name

select_shapeselect_shapeselect_shapeSelectShapeSelectShape — Choose regions with the aid of shape features.

Signature

select_shape(Regions : SelectedRegions : Features, Operation, Min, Max : )

Herror select_shape(const Hobject Regions, Hobject* SelectedRegions, const char* Features, const char* Operation, double Min, double Max)

Herror T_select_shape(const Hobject Regions, Hobject* SelectedRegions, const Htuple Features, const Htuple Operation, const Htuple Min, const Htuple Max)

Herror select_shape(Hobject Regions, Hobject* SelectedRegions, const HTuple& Features, const HTuple& Operation, const HTuple& Min, const HTuple& Max)

HRegionArray HRegionArray::SelectShape(const HTuple& Features, const HTuple& Operation, const HTuple& Min, const HTuple& Max) const

void HOperatorSetX.SelectShape(
[in] IHUntypedObjectX* Regions, [out] IHUntypedObjectX*SelectedRegions, [in] VARIANT Features, [in] VARIANT Operation, [in] VARIANT Min, [in] VARIANT Max)

IHRegionX* HRegionX.SelectShape(
[in] VARIANT Features, [in] BSTR Operation, [in] VARIANT Min, [in] VARIANT Max)

static void HOperatorSet.SelectShape(HObject regions, out HObject selectedRegions, HTuple features, HTuple operation, HTuple min, HTuple max)

HRegion HRegion.SelectShape(HTuple features, string operation, HTuple min, HTuple max)

HRegion HRegion.SelectShape(string features, string operation, double min, double max)

Description

The operator select_shapeselect_shapeselect_shapeSelectShapeSelectShape chooses regions according to shape. For each input region from RegionsRegionsRegionsRegionsregions the indicated features (FeaturesFeaturesFeaturesFeaturesfeatures) are calculated. If each (OperationOperationOperationOperationoperation = 'and') or at least one (OperationOperationOperationOperationoperation = 'or') of the calculated features is within the default limits (MinMinMinMinmin,MaxMaxMaxMaxmax) the region is adapted into the output (duplicated).

Condition: Min_i <= Feature_i(Object) <= Max_i

Possible values for FeaturesFeaturesFeaturesFeaturesfeatures:

'area':

Area of the object

'row':

Row index of the center

'column':

Column index of the center

'width':

Width of the region

'height':

Height of the region

'row1':

Row index of upper left corner

'column1':

Column index of upper left corner

'row2':

Row index of lower right corner

'column2':

Column index of lower right corner

'circularity':

Circularity (see circularitycircularitycircularityCircularityCircularity)

'compactness':

Compactness (see compactnesscompactnesscompactnessCompactnessCompactness)

'contlength':

Total length of contour (see operator contlengthcontlengthcontlengthContlengthContlength)

'convexity':

Convexity (see convexityconvexityconvexityConvexityConvexity)

'rectangularity':

Rectangularity (see rectangularityrectangularityrectangularityRectangularityRectangularity)

'ra':

Main radius of the equivalent ellipse (see elliptic_axiselliptic_axiselliptic_axisEllipticAxisEllipticAxis)

'rb':

Secondary radius of the equivalent ellipse (see elliptic_axiselliptic_axiselliptic_axisEllipticAxisEllipticAxis)

'phi':

Orientation of the equivalent ellipse (see elliptic_axiselliptic_axiselliptic_axisEllipticAxisEllipticAxis)

'anisometry:'

Anisometry (see eccentricityeccentricityeccentricityEccentricityEccentricity)

'bulkiness:'

Bulkiness (see operator eccentricityeccentricityeccentricityEccentricityEccentricity)

'struct_factor:'

Structur Factor (see operator eccentricityeccentricityeccentricityEccentricityEccentricity)

'outer_radius':

Radius of smallest surrounding circle (see smallest_circlesmallest_circlesmallest_circleSmallestCircleSmallestCircle)

'inner_radius':

Radius of largest inner circle (see inner_circleinner_circleinner_circleInnerCircleInnerCircle)

'inner_width':

Width of the largest axis-parallel rectangle that fits into the region (see inner_rectangle1inner_rectangle1inner_rectangle1InnerRectangle1InnerRectangle1)

'inner_height':

Height of the largest axis-parallel rectangle that fits into the region (see inner_rectangle1inner_rectangle1inner_rectangle1InnerRectangle1InnerRectangle1)

'dist_mean':

Mean distance from the region border to the center (see operator roundnessroundnessroundnessRoundnessRoundness)

'dist_deviation:'

Deviation of the distance from the region border from the center (see operator roundnessroundnessroundnessRoundnessRoundness)

'roundness':

Roundness (see operator roundnessroundnessroundnessRoundnessRoundness)

'num_sides':

Number of polygon sides (see operator roundnessroundnessroundnessRoundnessRoundness)

'connect_num':

Number of connection components (see operator connect_and_holesconnect_and_holesconnect_and_holesConnectAndHolesConnectAndHoles)

'holes_num':

Number of holes (see operator connect_and_holesconnect_and_holesconnect_and_holesConnectAndHolesConnectAndHoles)

'area_holes':

Area of the holes of the object (see operator area_holesarea_holesarea_holesAreaHolesAreaHoles)

'max_diameter':

Maximum diameter of the region (see operator diameter_regiondiameter_regiondiameter_regionDiameterRegionDiameterRegion)

'orientation':

Orientation of the region (see operator orientation_regionorientation_regionorientation_regionOrientationRegionOrientationRegion)

'euler_number':

Euler number (see operator euler_numbereuler_numbereuler_numberEulerNumberEulerNumber)

'rect2_phi':

Orientation of the smallest surrounding rectangle (see operator smallest_rectangle2smallest_rectangle2smallest_rectangle2SmallestRectangle2SmallestRectangle2)

'rect2_len1':

Half the length of the smallest surrounding rectangle (see operator smallest_rectangle2smallest_rectangle2smallest_rectangle2SmallestRectangle2SmallestRectangle2)

'rect2_len2':

Half the width of the smallest surrounding rectangle (see operator smallest_rectangle2smallest_rectangle2smallest_rectangle2SmallestRectangle2SmallestRectangle2)

'moments_m11':

Geometric moments of the region (see operator moments_region_2ndmoments_region_2ndmoments_region_2ndMomentsRegion2ndMomentsRegion2nd)

'moments_m20':

Geometric moments of the region (see operator moments_region_2ndmoments_region_2ndmoments_region_2ndMomentsRegion2ndMomentsRegion2nd)

'moments_m02':

Geometric moments of the region (see operator moments_region_2ndmoments_region_2ndmoments_region_2ndMomentsRegion2ndMomentsRegion2nd)

'moments_ia':

Geometric moments of the region (see operator moments_region_2ndmoments_region_2ndmoments_region_2ndMomentsRegion2ndMomentsRegion2nd)

'moments_ib':

Geometric moments of the region (see operator moments_region_2ndmoments_region_2ndmoments_region_2ndMomentsRegion2ndMomentsRegion2nd)

'moments_m11_invar':

Geometric moments of the region (see operator moments_region_2nd_invarmoments_region_2nd_invarmoments_region_2nd_invarMomentsRegion2ndInvarMomentsRegion2ndInvar)

'moments_m20_invar':

Geometric moments of the region (see operator moments_region_2nd_invarmoments_region_2nd_invarmoments_region_2nd_invarMomentsRegion2ndInvarMomentsRegion2ndInvar)

'moments_m02_invar':

Geometric moments of the region (see operator moments_region_2nd_invarmoments_region_2nd_invarmoments_region_2nd_invarMomentsRegion2ndInvarMomentsRegion2ndInvar)

'moments_phi1':

Geometric moments of the region (see operator moments_region_2nd_rel_invarmoments_region_2nd_rel_invarmoments_region_2nd_rel_invarMomentsRegion2ndRelInvarMomentsRegion2ndRelInvar)

'moments_phi2':

Geometric moments of the region (see operator moments_region_2nd_rel_invarmoments_region_2nd_rel_invarmoments_region_2nd_rel_invarMomentsRegion2ndRelInvarMomentsRegion2ndRelInvar)

'moments_m21':

Geometric moments of the region (see operator moments_region_3rdmoments_region_3rdmoments_region_3rdMomentsRegion3rdMomentsRegion3rd)

'moments_m12':

Geometric moments of the region (see operator moments_region_3rdmoments_region_3rdmoments_region_3rdMomentsRegion3rdMomentsRegion3rd)

'moments_m03':

Geometric moments of the region (see operator moments_region_3rdmoments_region_3rdmoments_region_3rdMomentsRegion3rdMomentsRegion3rd)

'moments_m30':

Geometric moments of the region (see operator moments_region_3rdmoments_region_3rdmoments_region_3rdMomentsRegion3rdMomentsRegion3rd)

'moments_m21_invar':

Geometric moments of the region (see operator moments_region_3rd_invarmoments_region_3rd_invarmoments_region_3rd_invarMomentsRegion3rdInvarMomentsRegion3rdInvar)

'moments_m12_invar':

Geometric moments of the region (see operator moments_region_3rd_invarmoments_region_3rd_invarmoments_region_3rd_invarMomentsRegion3rdInvarMomentsRegion3rdInvar)

'moments_m03_invar':

Geometric moments of the region (see operator moments_region_3rd_invarmoments_region_3rd_invarmoments_region_3rd_invarMomentsRegion3rdInvarMomentsRegion3rdInvar)

'moments_m30_invar':

Geometric moments of the region (see operator moments_region_3rd_invarmoments_region_3rd_invarmoments_region_3rd_invarMomentsRegion3rdInvarMomentsRegion3rdInvar)

'moments_i1':

Geometric moments of the region (see operator moments_region_centralmoments_region_centralmoments_region_centralMomentsRegionCentralMomentsRegionCentral)

'moments_i2':

Geometric moments of the region (see operator moments_region_centralmoments_region_centralmoments_region_centralMomentsRegionCentralMomentsRegionCentral)

'moments_i3':

Geometric moments of the region (see operator moments_region_centralmoments_region_centralmoments_region_centralMomentsRegionCentralMomentsRegionCentral)

'moments_i4':

Geometric moments of the region (see operator moments_region_centralmoments_region_centralmoments_region_centralMomentsRegionCentralMomentsRegionCentral)

'moments_psi1':

Geometric moments of the region (see operator moments_region_central_invarmoments_region_central_invarmoments_region_central_invarMomentsRegionCentralInvarMomentsRegionCentralInvar)

'moments_psi2':

Geometric moments of the region (see operator moments_region_central_invarmoments_region_central_invarmoments_region_central_invarMomentsRegionCentralInvarMomentsRegionCentralInvar)

'moments_psi3':

Geometric moments of the region (see operator moments_region_central_invarmoments_region_central_invarmoments_region_central_invarMomentsRegionCentralInvarMomentsRegionCentralInvar)

'moments_psi4':

Geometric moments of the region (see operator moments_region_central_invarmoments_region_central_invarmoments_region_central_invarMomentsRegionCentralInvarMomentsRegionCentralInvar)

If only one feature (FeaturesFeaturesFeaturesFeaturesfeatures) is used the value of OperationOperationOperationOperationoperation is meaningless. Several features are processed in the sequence in which they are entered.

Parallelization

Parameters

RegionsRegionsRegionsRegionsregions (input_object)  region-array objectHRegionHRegionArrayHRegionXHobject

Regions to be examined.

SelectedRegionsSelectedRegionsSelectedRegionsSelectedRegionsselectedRegions (output_object)  region-array objectHRegionHRegionArrayHRegionXHobject *

Regions fulfilling the condition.

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

Shape features to be checked.

Default value: 'area' "area" "area" "area" "area"

List of values: 'area'"area""area""area""area", 'row'"row""row""row""row", 'column'"column""column""column""column", 'width'"width""width""width""width", 'height'"height""height""height""height", 'row1'"row1""row1""row1""row1", 'column1'"column1""column1""column1""column1", 'row2'"row2""row2""row2""row2", 'column2'"column2""column2""column2""column2", 'circularity'"circularity""circularity""circularity""circularity", 'compactness'"compactness""compactness""compactness""compactness", 'contlength'"contlength""contlength""contlength""contlength", 'convexity'"convexity""convexity""convexity""convexity", 'rectangularity'"rectangularity""rectangularity""rectangularity""rectangularity", 'ra'"ra""ra""ra""ra", 'rb'"rb""rb""rb""rb", 'phi'"phi""phi""phi""phi", 'anisometry'"anisometry""anisometry""anisometry""anisometry", 'bulkiness'"bulkiness""bulkiness""bulkiness""bulkiness", 'struct_factor'"struct_factor""struct_factor""struct_factor""struct_factor", 'outer_radius'"outer_radius""outer_radius""outer_radius""outer_radius", 'inner_radius'"inner_radius""inner_radius""inner_radius""inner_radius", 'inner_width'"inner_width""inner_width""inner_width""inner_width", 'inner_height'"inner_height""inner_height""inner_height""inner_height", 'max_diameter'"max_diameter""max_diameter""max_diameter""max_diameter", 'dist_mean'"dist_mean""dist_mean""dist_mean""dist_mean", 'dist_deviation'"dist_deviation""dist_deviation""dist_deviation""dist_deviation", 'roundness'"roundness""roundness""roundness""roundness", 'num_sides'"num_sides""num_sides""num_sides""num_sides", 'orientation'"orientation""orientation""orientation""orientation", 'connect_num'"connect_num""connect_num""connect_num""connect_num", 'holes_num'"holes_num""holes_num""holes_num""holes_num", 'area_holes'"area_holes""area_holes""area_holes""area_holes", 'euler_number'"euler_number""euler_number""euler_number""euler_number", 'rect2_phi'"rect2_phi""rect2_phi""rect2_phi""rect2_phi", 'rect2_len1'"rect2_len1""rect2_len1""rect2_len1""rect2_len1", 'rect2_len2'"rect2_len2""rect2_len2""rect2_len2""rect2_len2", 'moments_m11'"moments_m11""moments_m11""moments_m11""moments_m11", 'moments_m20'"moments_m20""moments_m20""moments_m20""moments_m20", 'moments_m02'"moments_m02""moments_m02""moments_m02""moments_m02", 'moments_ia'"moments_ia""moments_ia""moments_ia""moments_ia", 'moments_ib'"moments_ib""moments_ib""moments_ib""moments_ib", 'moments_m11_invar'"moments_m11_invar""moments_m11_invar""moments_m11_invar""moments_m11_invar", 'moments_m20_invar'"moments_m20_invar""moments_m20_invar""moments_m20_invar""moments_m20_invar", 'moments_m02_invar'"moments_m02_invar""moments_m02_invar""moments_m02_invar""moments_m02_invar", 'moments_phi1'"moments_phi1""moments_phi1""moments_phi1""moments_phi1", 'moments_phi2'"moments_phi2""moments_phi2""moments_phi2""moments_phi2", 'moments_m21'"moments_m21""moments_m21""moments_m21""moments_m21", 'moments_m12'"moments_m12""moments_m12""moments_m12""moments_m12", 'moments_m03'"moments_m03""moments_m03""moments_m03""moments_m03", 'moments_m30'"moments_m30""moments_m30""moments_m30""moments_m30", 'moments_m21_invar'"moments_m21_invar""moments_m21_invar""moments_m21_invar""moments_m21_invar", 'moments_m12_invar'"moments_m12_invar""moments_m12_invar""moments_m12_invar""moments_m12_invar", 'moments_m03_invar'"moments_m03_invar""moments_m03_invar""moments_m03_invar""moments_m03_invar", 'moments_m30_invar'"moments_m30_invar""moments_m30_invar""moments_m30_invar""moments_m30_invar", 'moments_i1'"moments_i1""moments_i1""moments_i1""moments_i1", 'moments_i2'"moments_i2""moments_i2""moments_i2""moments_i2", 'moments_i3'"moments_i3""moments_i3""moments_i3""moments_i3", 'moments_i4'"moments_i4""moments_i4""moments_i4""moments_i4", 'moments_psi1'"moments_psi1""moments_psi1""moments_psi1""moments_psi1", 'moments_psi2'"moments_psi2""moments_psi2""moments_psi2""moments_psi2", 'moments_psi3'"moments_psi3""moments_psi3""moments_psi3""moments_psi3", 'moments_psi4'"moments_psi4""moments_psi4""moments_psi4""moments_psi4"

OperationOperationOperationOperationoperation (input_control)  string HTupleHTupleVARIANTHtuple (string) (string) (char*) (BSTR) (char*)

Linkage type of the individual features.

Default value: 'and' "and" "and" "and" "and"

List of values: 'and'"and""and""and""and", 'or'"or""or""or""or"

MinMinMinMinmin (input_control)  real(-array) HTupleHTupleVARIANTHtuple (real / integer / string) (double / int / long / string) (double / Hlong / char*) (double / Hlong / BSTR) (double / Hlong / char*)

Lower limits of the features or 'min'.

Default value: 150.0

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

Minimum increment: 0.001

Recommended increment: 1.0

MaxMaxMaxMaxmax (input_control)  real(-array) HTupleHTupleVARIANTHtuple (real / integer / string) (double / int / long / string) (double / Hlong / char*) (double / Hlong / BSTR) (double / Hlong / char*)

Upper limits of the features or 'max'.

Default value: 99999.0

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

Minimum increment: 0.001

Recommended increment: 1.0

Restriction: Max >= Min

Example (HDevelop)

* where are the eyes of the ape ?
read_image(Image,'monkey')
threshold(Image,S1,160,255)
connection(S1,S2)
select_shape(S2,Eyes,['area','anisometry'],'and',[500,1.0],[50000,1.7])
disp_region(Eyes,WindowHandle)

Example (C)

/* where are the eyes of the ape ? */
read_image(&Image,"monkey");
threshold(Image,&S1,128.0,255.0);
connection(S1,&S2);
select_shape(S2,&S3,"area","and",500.0,50000.0);
select_shape(S3,&Eyes,"anisometry","and",1.0,1.7);
disp_region(Eyes,WindowHandle);

Example (C++)

#include "HIOStream.h"
#if !defined(USE_IOSTREAM_H)
using namespace std;
#endif
#include "HalconCpp.h"
using namespace Halcon;

int main ()
{
  HImage        img ("monkey");
  HWindow       w;

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

  seg.Display (w);
  w.Click ();

  return(0);
}

Example (HDevelop)

* where are the eyes of the ape ?
read_image(Image,'monkey')
threshold(Image,S1,160,255)
connection(S1,S2)
select_shape(S2,Eyes,['area','anisometry'],'and',[500,1.0],[50000,1.7])
disp_region(Eyes,WindowHandle)

Example (HDevelop)

* where are the eyes of the ape ?
read_image(Image,'monkey')
threshold(Image,S1,160,255)
connection(S1,S2)
select_shape(S2,Eyes,['area','anisometry'],'and',[500,1.0],[50000,1.7])
disp_region(Eyes,WindowHandle)

Result

The operator select_shapeselect_shapeselect_shapeSelectShapeSelectShape returns the value 2 (H_MSG_TRUE) if the input is not empty. The behavior in case of empty input (no input objects 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

thresholdthresholdthresholdThresholdThreshold, regiongrowingregiongrowingregiongrowingRegiongrowingRegiongrowing, connectionconnectionconnectionConnectionConnection, runlength_featuresrunlength_featuresrunlength_featuresRunlengthFeaturesRunlengthFeatures

Possible Successors

select_shapeselect_shapeselect_shapeSelectShapeSelectShape, select_grayselect_grayselect_graySelectGraySelectGray, shape_transshape_transshape_transShapeTransShapeTrans, reduce_domainreduce_domainreduce_domainReduceDomainReduceDomain, count_objcount_objcount_objCountObjCountObj

Alternatives

select_shape_stdselect_shape_stdselect_shape_stdSelectShapeStdSelectShapeStd

See also

area_centerarea_centerarea_centerAreaCenterAreaCenter, circularitycircularitycircularityCircularityCircularity, compactnesscompactnesscompactnessCompactnessCompactness, contlengthcontlengthcontlengthContlengthContlength, convexityconvexityconvexityConvexityConvexity, rectangularityrectangularityrectangularityRectangularityRectangularity, elliptic_axiselliptic_axiselliptic_axisEllipticAxisEllipticAxis, eccentricityeccentricityeccentricityEccentricityEccentricity, inner_circleinner_circleinner_circleInnerCircleInnerCircle, smallest_circlesmallest_circlesmallest_circleSmallestCircleSmallestCircle, smallest_rectangle1smallest_rectangle1smallest_rectangle1SmallestRectangle1SmallestRectangle1, smallest_rectangle2smallest_rectangle2smallest_rectangle2SmallestRectangle2SmallestRectangle2, inner_rectangle1inner_rectangle1inner_rectangle1InnerRectangle1InnerRectangle1, roundnessroundnessroundnessRoundnessRoundness, connect_and_holesconnect_and_holesconnect_and_holesConnectAndHolesConnectAndHoles, area_holesarea_holesarea_holesAreaHolesAreaHoles, diameter_regiondiameter_regiondiameter_regionDiameterRegionDiameterRegion, orientation_regionorientation_regionorientation_regionOrientationRegionOrientationRegion, moments_region_2ndmoments_region_2ndmoments_region_2ndMomentsRegion2ndMomentsRegion2nd, moments_region_2nd_invarmoments_region_2nd_invarmoments_region_2nd_invarMomentsRegion2ndInvarMomentsRegion2ndInvar, moments_region_2nd_rel_invarmoments_region_2nd_rel_invarmoments_region_2nd_rel_invarMomentsRegion2ndRelInvarMomentsRegion2ndRelInvar, moments_region_3rdmoments_region_3rdmoments_region_3rdMomentsRegion3rdMomentsRegion3rd, moments_region_3rd_invarmoments_region_3rd_invarmoments_region_3rd_invarMomentsRegion3rdInvarMomentsRegion3rdInvar, moments_region_centralmoments_region_centralmoments_region_centralMomentsRegionCentralMomentsRegionCentral, moments_region_central_invarmoments_region_central_invarmoments_region_central_invarMomentsRegionCentralInvarMomentsRegionCentralInvar, select_objselect_objselect_objSelectObjSelectObj

Module

Foundation


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