select_shape select_shape SelectShape SelectShape (Operator)
Name
select_shape select_shape SelectShape SelectShape
— Choose regions with the aid of shape features.
Signature
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 )
void SelectShape (const HObject& Regions , HObject* SelectedRegions , const HTuple& Features , const HTuple& Operation , const HTuple& Min , const HTuple& Max )
HRegion HRegion ::SelectShape (const HTuple& Features , const HString& Operation , const HTuple& Min , const HTuple& Max ) const
HRegion HRegion ::SelectShape (const HString& Features , const HString& Operation , double Min , double Max ) const
HRegion HRegion ::SelectShape (const char* Features , const char* Operation , double Min , double Max ) const
HRegion HRegion ::SelectShape (const wchar_t* Features , const wchar_t* Operation , double Min , double Max ) const
(Windows only)
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_shape select_shape SelectShape SelectShape SelectShape
chooses regions according to
shape. For each input region from Regions Regions Regions Regions regions
the indicated
features (Features Features Features Features features
) are calculated. If each
(Operation Operation Operation Operation operation
= 'and') or at least one (Operation Operation Operation Operation operation
=
'or') of the calculated features is within the default limits
(Min Min Min Min min
,Max Max Max Max max
) the region is adapted into the output
(duplicated).
The parameters Min Min Min Min min
and Max Max Max Max max
can be set to
'min' "min" "min" "min" "min" or 'max' "max" "max" "max" "max" in order to leave bottom and top limits,
respectively, open.
Condition:
For an illustration of these features, please refer to the
documentation of this chapter (Regions / Features ).
Possible values for Features Features Features Features features
:
'area':
Area of the object
'row':
Row index of the center
'column':
Column index of the center
'width':
Width of the region (parallel to the
coordinate axes; see
height_width_ratio height_width_ratio HeightWidthRatio HeightWidthRatio HeightWidthRatio
)
'height':
Height of the region (parallel to the
coordinate axes; see
height_width_ratio height_width_ratio HeightWidthRatio HeightWidthRatio HeightWidthRatio
)
'ratio':
Ratio of the height and width of the region
(parallel to the coordinate axes; see
height_width_ratio height_width_ratio HeightWidthRatio HeightWidthRatio HeightWidthRatio
)
'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 circularity circularity Circularity Circularity Circularity
)
'compactness':
Compactness (see compactness compactness Compactness Compactness Compactness
)
'contlength':
Total length of contour
(see operator contlength contlength Contlength Contlength Contlength
)
'convexity':
Convexity (see convexity convexity Convexity Convexity Convexity
)
'rectangularity':
Rectangularity (see rectangularity rectangularity Rectangularity Rectangularity Rectangularity
)
'ra':
Main radius of the equivalent ellipse
(see elliptic_axis elliptic_axis EllipticAxis EllipticAxis EllipticAxis
)
'rb':
Secondary radius of the equivalent ellipse
(see elliptic_axis elliptic_axis EllipticAxis EllipticAxis EllipticAxis
)
'phi':
Orientation of the equivalent ellipse
(see elliptic_axis elliptic_axis EllipticAxis EllipticAxis EllipticAxis
)
'anisometry:'
Anisometry (see eccentricity eccentricity Eccentricity Eccentricity Eccentricity
)
'bulkiness:'
Bulkiness (see operator eccentricity eccentricity Eccentricity Eccentricity Eccentricity
)
'struct_factor:'
Structur Factor (see operator eccentricity eccentricity Eccentricity Eccentricity Eccentricity
)
'outer_radius':
Radius of smallest surrounding circle
(see smallest_circle smallest_circle SmallestCircle SmallestCircle SmallestCircle
)
'inner_radius':
Radius of largest inner circle
(see inner_circle inner_circle InnerCircle InnerCircle InnerCircle
)
'inner_width':
Width of the largest axis-parallel rectangle that
fits into the region (see inner_rectangle1 inner_rectangle1 InnerRectangle1 InnerRectangle1 InnerRectangle1
)
'inner_height':
Height of the largest axis-parallel rectangle that
fits into the region (see inner_rectangle1 inner_rectangle1 InnerRectangle1 InnerRectangle1 InnerRectangle1
)
'dist_mean':
Mean distance from the region border to the
center (see operator roundness roundness Roundness Roundness Roundness
)
'dist_deviation:'
Deviation of the distance from the region border
from the center (see operator roundness roundness Roundness Roundness Roundness
)
'roundness':
Roundness (see operator roundness roundness Roundness Roundness Roundness
)
'num_sides':
Number of polygon sides (see operator
roundness roundness Roundness Roundness Roundness
)
'connect_num':
Number of connection components
(see operator connect_and_holes connect_and_holes ConnectAndHoles ConnectAndHoles ConnectAndHoles
)
'holes_num':
Number of holes
(see operator connect_and_holes connect_and_holes ConnectAndHoles ConnectAndHoles ConnectAndHoles
)
'area_holes':
Area of the holes of the object
(see operator area_holes area_holes AreaHoles AreaHoles AreaHoles
)
'max_diameter':
Maximum diameter of the region
(see operator diameter_region diameter_region DiameterRegion DiameterRegion DiameterRegion
)
'orientation':
Orientation of the region
(see operator orientation_region orientation_region OrientationRegion OrientationRegion OrientationRegion
)
'euler_number':
Euler number (see operator euler_number euler_number EulerNumber EulerNumber EulerNumber
)
'rect2_phi':
Orientation of the smallest surrounding rectangle
(see operator smallest_rectangle2 smallest_rectangle2 SmallestRectangle2 SmallestRectangle2 SmallestRectangle2
)
'rect2_len1':
Half the length of the smallest surrounding
rectangle (see operator smallest_rectangle2 smallest_rectangle2 SmallestRectangle2 SmallestRectangle2 SmallestRectangle2
)
'rect2_len2':
Half the width of the smallest surrounding
rectangle (see operator smallest_rectangle2 smallest_rectangle2 SmallestRectangle2 SmallestRectangle2 SmallestRectangle2
)
'moments_m11':
Geometric moments of the region
(see operator moments_region_2nd moments_region_2nd MomentsRegion2nd MomentsRegion2nd MomentsRegion2nd
)
'moments_m20':
Geometric moments of the region
(see operator moments_region_2nd moments_region_2nd MomentsRegion2nd MomentsRegion2nd MomentsRegion2nd
)
'moments_m02':
Geometric moments of the region
(see operator moments_region_2nd moments_region_2nd MomentsRegion2nd MomentsRegion2nd MomentsRegion2nd
)
'moments_ia':
Geometric moments of the region
(see operator moments_region_2nd moments_region_2nd MomentsRegion2nd MomentsRegion2nd MomentsRegion2nd
)
'moments_ib':
Geometric moments of the region
(see operator moments_region_2nd moments_region_2nd MomentsRegion2nd MomentsRegion2nd MomentsRegion2nd
)
'moments_m11_invar':
Geometric moments of the region
(see operator moments_region_2nd_invar moments_region_2nd_invar MomentsRegion2ndInvar MomentsRegion2ndInvar MomentsRegion2ndInvar
)
'moments_m20_invar':
Geometric moments of the region
(see operator moments_region_2nd_invar moments_region_2nd_invar MomentsRegion2ndInvar MomentsRegion2ndInvar MomentsRegion2ndInvar
)
'moments_m02_invar':
Geometric moments of the region
(see operator moments_region_2nd_invar moments_region_2nd_invar MomentsRegion2ndInvar MomentsRegion2ndInvar MomentsRegion2ndInvar
)
'moments_phi1':
Geometric moments of the region
(see operator moments_region_2nd_rel_invar moments_region_2nd_rel_invar MomentsRegion2ndRelInvar MomentsRegion2ndRelInvar MomentsRegion2ndRelInvar
)
'moments_phi2':
Geometric moments of the region
(see operator moments_region_2nd_rel_invar moments_region_2nd_rel_invar MomentsRegion2ndRelInvar MomentsRegion2ndRelInvar MomentsRegion2ndRelInvar
)
'moments_m21':
Geometric moments of the region
(see operator moments_region_3rd moments_region_3rd MomentsRegion3rd MomentsRegion3rd MomentsRegion3rd
)
'moments_m12':
Geometric moments of the region
(see operator moments_region_3rd moments_region_3rd MomentsRegion3rd MomentsRegion3rd MomentsRegion3rd
)
'moments_m03':
Geometric moments of the region
(see operator moments_region_3rd moments_region_3rd MomentsRegion3rd MomentsRegion3rd MomentsRegion3rd
)
'moments_m30':
Geometric moments of the region
(see operator moments_region_3rd moments_region_3rd MomentsRegion3rd MomentsRegion3rd MomentsRegion3rd
)
'moments_m21_invar':
Geometric moments of the region
(see operator moments_region_3rd_invar moments_region_3rd_invar MomentsRegion3rdInvar MomentsRegion3rdInvar MomentsRegion3rdInvar
)
'moments_m12_invar':
Geometric moments of the region
(see operator moments_region_3rd_invar moments_region_3rd_invar MomentsRegion3rdInvar MomentsRegion3rdInvar MomentsRegion3rdInvar
)
'moments_m03_invar':
Geometric moments of the region
(see operator moments_region_3rd_invar moments_region_3rd_invar MomentsRegion3rdInvar MomentsRegion3rdInvar MomentsRegion3rdInvar
)
'moments_m30_invar':
Geometric moments of the region
(see operator moments_region_3rd_invar moments_region_3rd_invar MomentsRegion3rdInvar MomentsRegion3rdInvar MomentsRegion3rdInvar
)
'moments_i1':
Geometric moments of the region
(see operator moments_region_central moments_region_central MomentsRegionCentral MomentsRegionCentral MomentsRegionCentral
)
'moments_i2':
Geometric moments of the region
(see operator moments_region_central moments_region_central MomentsRegionCentral MomentsRegionCentral MomentsRegionCentral
)
'moments_i3':
Geometric moments of the region
(see operator moments_region_central moments_region_central MomentsRegionCentral MomentsRegionCentral MomentsRegionCentral
)
'moments_i4':
Geometric moments of the region
(see operator moments_region_central moments_region_central MomentsRegionCentral MomentsRegionCentral MomentsRegionCentral
)
'moments_psi1':
Geometric moments of the region
(see operator moments_region_central_invar moments_region_central_invar MomentsRegionCentralInvar MomentsRegionCentralInvar MomentsRegionCentralInvar
)
'moments_psi2':
Geometric moments of the region
(see operator moments_region_central_invar moments_region_central_invar MomentsRegionCentralInvar MomentsRegionCentralInvar MomentsRegionCentralInvar
)
'moments_psi3':
Geometric moments of the region
(see operator moments_region_central_invar moments_region_central_invar MomentsRegionCentralInvar MomentsRegionCentralInvar MomentsRegionCentralInvar
)
'moments_psi4':
Geometric moments of the region
(see operator moments_region_central_invar moments_region_central_invar MomentsRegionCentralInvar MomentsRegionCentralInvar MomentsRegionCentralInvar
)
If only one feature (Features Features Features Features features
) is used the value of
Operation Operation Operation Operation operation
is meaningless. Several features are processed in
the sequence in which they are entered.
Execution Information
Multithreading type: reentrant (runs in parallel with non-exclusive operators).
Multithreading scope: global (may be called from any thread).
Automatically parallelized on tuple level.
Parameters
Regions Regions Regions Regions regions
(input_object) region-array →
object HRegion HRegion Hobject
Regions to be examined.
SelectedRegions SelectedRegions SelectedRegions SelectedRegions selectedRegions
(output_object) region-array →
object HRegion HRegion Hobject *
Regions fulfilling the condition.
Features Features Features Features features
(input_control) string(-array) →
HTuple HTuple Htuple (string) (string ) (HString ) (char* )
Shape features to be checked.
Default value:
'area'
"area"
"area"
"area"
"area"
List of values: 'anisometry' "anisometry" "anisometry" "anisometry" "anisometry" , 'area' "area" "area" "area" "area" , 'area_holes' "area_holes" "area_holes" "area_holes" "area_holes" , 'bulkiness' "bulkiness" "bulkiness" "bulkiness" "bulkiness" , 'circularity' "circularity" "circularity" "circularity" "circularity" , 'column' "column" "column" "column" "column" , 'column1' "column1" "column1" "column1" "column1" , 'column2' "column2" "column2" "column2" "column2" , 'compactness' "compactness" "compactness" "compactness" "compactness" , 'connect_num' "connect_num" "connect_num" "connect_num" "connect_num" , 'contlength' "contlength" "contlength" "contlength" "contlength" , 'convexity' "convexity" "convexity" "convexity" "convexity" , 'dist_deviation' "dist_deviation" "dist_deviation" "dist_deviation" "dist_deviation" , 'dist_mean' "dist_mean" "dist_mean" "dist_mean" "dist_mean" , 'euler_number' "euler_number" "euler_number" "euler_number" "euler_number" , 'height' "height" "height" "height" "height" , 'holes_num' "holes_num" "holes_num" "holes_num" "holes_num" , 'inner_height' "inner_height" "inner_height" "inner_height" "inner_height" , 'inner_radius' "inner_radius" "inner_radius" "inner_radius" "inner_radius" , 'inner_width' "inner_width" "inner_width" "inner_width" "inner_width" , 'max_diameter' "max_diameter" "max_diameter" "max_diameter" "max_diameter" , '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_ia' "moments_ia" "moments_ia" "moments_ia" "moments_ia" , 'moments_ib' "moments_ib" "moments_ib" "moments_ib" "moments_ib" , 'moments_m02' "moments_m02" "moments_m02" "moments_m02" "moments_m02" , 'moments_m02_invar' "moments_m02_invar" "moments_m02_invar" "moments_m02_invar" "moments_m02_invar" , 'moments_m03' "moments_m03" "moments_m03" "moments_m03" "moments_m03" , 'moments_m03_invar' "moments_m03_invar" "moments_m03_invar" "moments_m03_invar" "moments_m03_invar" , 'moments_m11' "moments_m11" "moments_m11" "moments_m11" "moments_m11" , 'moments_m11_invar' "moments_m11_invar" "moments_m11_invar" "moments_m11_invar" "moments_m11_invar" , 'moments_m12' "moments_m12" "moments_m12" "moments_m12" "moments_m12" , 'moments_m12_invar' "moments_m12_invar" "moments_m12_invar" "moments_m12_invar" "moments_m12_invar" , 'moments_m20' "moments_m20" "moments_m20" "moments_m20" "moments_m20" , 'moments_m20_invar' "moments_m20_invar" "moments_m20_invar" "moments_m20_invar" "moments_m20_invar" , 'moments_m21' "moments_m21" "moments_m21" "moments_m21" "moments_m21" , 'moments_m21_invar' "moments_m21_invar" "moments_m21_invar" "moments_m21_invar" "moments_m21_invar" , 'moments_m30' "moments_m30" "moments_m30" "moments_m30" "moments_m30" , 'moments_m30_invar' "moments_m30_invar" "moments_m30_invar" "moments_m30_invar" "moments_m30_invar" , 'moments_phi1' "moments_phi1" "moments_phi1" "moments_phi1" "moments_phi1" , 'moments_phi2' "moments_phi2" "moments_phi2" "moments_phi2" "moments_phi2" , '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" , 'num_sides' "num_sides" "num_sides" "num_sides" "num_sides" , 'orientation' "orientation" "orientation" "orientation" "orientation" , 'outer_radius' "outer_radius" "outer_radius" "outer_radius" "outer_radius" , 'phi' "phi" "phi" "phi" "phi" , 'ra' "ra" "ra" "ra" "ra" , 'ratio' "ratio" "ratio" "ratio" "ratio" , 'rb' "rb" "rb" "rb" "rb" , 'rect2_len1' "rect2_len1" "rect2_len1" "rect2_len1" "rect2_len1" , 'rect2_len2' "rect2_len2" "rect2_len2" "rect2_len2" "rect2_len2" , 'rect2_phi' "rect2_phi" "rect2_phi" "rect2_phi" "rect2_phi" , 'rectangularity' "rectangularity" "rectangularity" "rectangularity" "rectangularity" , 'roundness' "roundness" "roundness" "roundness" "roundness" , 'row' "row" "row" "row" "row" , 'row1' "row1" "row1" "row1" "row1" , 'row2' "row2" "row2" "row2" "row2" , 'struct_factor' "struct_factor" "struct_factor" "struct_factor" "struct_factor" , 'width' "width" "width" "width" "width"
Operation Operation Operation Operation operation
(input_control) string →
HTuple HTuple Htuple (string) (string ) (HString ) (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"
Min Min Min Min min
(input_control) real(-array) →
HTuple HTuple Htuple (real / integer / string) (double / int / long / string) (double / Hlong / HString) (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
Max Max Max Max max
(input_control) real(-array) →
HTuple HTuple Htuple (real / integer / string) (double / int / long / string) (double / Hlong / HString) (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 Mandrill?
read_image(Image,'monkey')
threshold(Image,Region,128,255)
connection(Region,ConnectedRegions)
select_shape(ConnectedRegions,Eyes,['area','max_diameter'],\
'and',[500,30.0],[1000,50.0])
dev_display(Eyes)
Example (C)
/* Where are the eyes of the Mandrill? */
read_image(&Image,"monkey");
threshold(Image,&Region,128.0,255.0);
connection(Region,&ConnectedRegions);
select_shape(ConnectedRegions,&SelectedRegions,"area","and",500.0,1000.0);
select_shape(SelectedRegions,&Eyes,"max_diameter","and",30.0,50.0);
disp_region(Eyes,WindowHandle);
Example (HDevelop)
* Where are the eyes of the Mandrill?
read_image(Image,'monkey')
threshold(Image,Region,128,255)
connection(Region,ConnectedRegions)
select_shape(ConnectedRegions,Eyes,['area','max_diameter'],\
'and',[500,30.0],[1000,50.0])
dev_display(Eyes)
Example (HDevelop)
* Where are the eyes of the Mandrill?
read_image(Image,'monkey')
threshold(Image,Region,128,255)
connection(Region,ConnectedRegions)
select_shape(ConnectedRegions,Eyes,['area','max_diameter'],\
'and',[500,30.0],[1000,50.0])
dev_display(Eyes)
Example (HDevelop)
* Where are the eyes of the Mandrill?
read_image(Image,'monkey')
threshold(Image,Region,128,255)
connection(Region,ConnectedRegions)
select_shape(ConnectedRegions,Eyes,['area','max_diameter'],\
'and',[500,30.0],[1000,50.0])
dev_display(Eyes)
Result
The operator select_shape select_shape SelectShape SelectShape SelectShape
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>) SetSystem("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>) SetSystem("empty_region_result",<Result>) SetSystem("empty_region_result",<Result>) SetSystem("empty_region_result",<Result>)
. If necessary an
exception is raised.
Possible Predecessors
threshold threshold Threshold Threshold Threshold
,
regiongrowing regiongrowing Regiongrowing Regiongrowing Regiongrowing
,
connection connection Connection Connection Connection
,
runlength_features runlength_features RunlengthFeatures RunlengthFeatures RunlengthFeatures
Possible Successors
select_gray select_gray SelectGray SelectGray SelectGray
,
shape_trans shape_trans ShapeTrans ShapeTrans ShapeTrans
,
reduce_domain reduce_domain ReduceDomain ReduceDomain ReduceDomain
,
count_obj count_obj CountObj CountObj CountObj
Alternatives
select_shape_std select_shape_std SelectShapeStd SelectShapeStd SelectShapeStd
See also
area_center area_center AreaCenter AreaCenter AreaCenter
,
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
,
elliptic_axis elliptic_axis EllipticAxis EllipticAxis EllipticAxis
,
eccentricity eccentricity Eccentricity Eccentricity Eccentricity
,
inner_circle inner_circle InnerCircle InnerCircle InnerCircle
,
smallest_circle smallest_circle SmallestCircle SmallestCircle SmallestCircle
,
smallest_rectangle1 smallest_rectangle1 SmallestRectangle1 SmallestRectangle1 SmallestRectangle1
,
smallest_rectangle2 smallest_rectangle2 SmallestRectangle2 SmallestRectangle2 SmallestRectangle2
,
inner_rectangle1 inner_rectangle1 InnerRectangle1 InnerRectangle1 InnerRectangle1
,
roundness roundness Roundness Roundness Roundness
,
connect_and_holes connect_and_holes ConnectAndHoles ConnectAndHoles ConnectAndHoles
,
area_holes area_holes AreaHoles AreaHoles AreaHoles
,
diameter_region diameter_region DiameterRegion DiameterRegion DiameterRegion
,
orientation_region orientation_region OrientationRegion OrientationRegion OrientationRegion
,
moments_region_2nd moments_region_2nd MomentsRegion2nd MomentsRegion2nd MomentsRegion2nd
,
moments_region_2nd_invar moments_region_2nd_invar MomentsRegion2ndInvar MomentsRegion2ndInvar MomentsRegion2ndInvar
,
moments_region_2nd_rel_invar moments_region_2nd_rel_invar MomentsRegion2ndRelInvar MomentsRegion2ndRelInvar MomentsRegion2ndRelInvar
,
moments_region_3rd moments_region_3rd MomentsRegion3rd MomentsRegion3rd MomentsRegion3rd
,
moments_region_3rd_invar moments_region_3rd_invar MomentsRegion3rdInvar MomentsRegion3rdInvar MomentsRegion3rdInvar
,
moments_region_central moments_region_central MomentsRegionCentral MomentsRegionCentral MomentsRegionCentral
,
moments_region_central_invar moments_region_central_invar MomentsRegionCentralInvar MomentsRegionCentralInvar MomentsRegionCentralInvar
,
select_obj select_obj SelectObj SelectObj SelectObj
Module
Foundation