Skip to content

select_shapeSelectShapeSelectShapeselect_shapeselect_shapeπŸ”—

Short descriptionπŸ”—

select_shapeSelectShapeSelectShapeselect_shapeselect_shape β€” Choose regions with the aid of shape features.

SignatureπŸ”—

select_shape( region Regions, out region SelectedRegions, string Features, string Operation, real Min, real Max )void SelectShape( const HObject& Regions, HObject* SelectedRegions, const HTuple& Features, const HTuple& Operation, const HTuple& Min, const HTuple& Max )static void HOperatorSet.SelectShape( HObject regions, out HObject selectedRegions, HTuple features, HTuple operation, HTuple min, HTuple max )def select_shape( regions: HObject, features: MaybeSequence[str], operation: str, min: MaybeSequence[Union[int, float, str]], max: MaybeSequence[Union[int, float, str]] ) -> HObject

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 )

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)

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_shapeSelectShape chooses regions according to shape. For each input region from Regionsregionsregions the indicated features (Featuresfeaturesfeatures) are calculated. If each (Operationoperationoperation = 'and'"and") or at least one (Operationoperationoperation = 'or'"or") of the calculated features is within the default limits (Minminmin,Maxmaxmax) the region is adapted into the output (duplicated). The parameters Minminmin and Maxmaxmax can be set to 'min'"min" or 'max'"max" in order to leave bottom and top limits, respectively, open.

Condition: \(Min_{i} \leq Feature_{i}(Object) \leq Max_{i}\)

For an illustration of these features, please refer to the documentation of this chapter (Regions / Features).

Possible values for Featuresfeaturesfeatures:

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

Execution informationπŸ”—

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πŸ”—

Regionsregionsregions (input_object) region-array β†’ objectHObjectHRegionHObjectHobject

Regions to be examined.

SelectedRegionsselectedRegionsselected_regions (output_object) region-array β†’ objectHObjectHRegionHObjectHobject *

Regions fulfilling the condition.

Featuresfeaturesfeatures (input_control) string(-array) β†’ (string)HTuple (HString)HTuple (string)MaybeSequence[str]Htuple (char*)

Shape features to be checked.

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

Operationoperationoperation (input_control) string β†’ (string)HTuple (HString)HTuple (string)strHtuple (char*)

Linkage type of the individual features.

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

Minminmin (input_control) real(-array) β†’ (real / integer / string)HTuple (double / Hlong / HString)HTuple (double / int / long / string)MaybeSequence[Union[int, float, str]]Htuple (double / Hlong / char*)

Lower limits of the features or β€˜min’.

Default: 150.0150.0
Value range: 0.0 ≀ Min ≀ 99999.0
Minimum increment: 0.001
Recommended increment: 1.0

Maxmaxmax (input_control) real(-array) β†’ (real / integer / string)HTuple (double / Hlong / HString)HTuple (double / int / long / string)MaybeSequence[Union[int, float, str]]Htuple (double / Hlong / char*)

Upper limits of the features or β€˜max’.

Default: 99999.099999.0
Value range: 0.0 ≀ 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)
(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)\;

ResultπŸ”—

The operator select_shapeSelectShape 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>). The behavior in case of empty region (the region is the empty set) is set via set_system('empty_region_result',<Result>). If necessary an exception is raised.

Combinations with other operatorsπŸ”—

Combinations

Possible predecessors

thresholdThreshold, regiongrowingRegiongrowing, connectionConnection, runlength_featuresRunlengthFeatures

Possible successors

select_graySelectGray, shape_transShapeTrans, reduce_domainReduceDomain, count_objCountObj

Alternatives

select_shape_stdSelectShapeStd

See also

area_centerAreaCenter, circularityCircularity, compactnessCompactness, contlengthContlength, convexityConvexity, rectangularityRectangularity, elliptic_axisEllipticAxis, eccentricityEccentricity, inner_circleInnerCircle, smallest_circleSmallestCircle, smallest_rectangle1SmallestRectangle1, smallest_rectangle2SmallestRectangle2, inner_rectangle1InnerRectangle1, roundnessRoundness, connect_and_holesConnectAndHoles, area_holesAreaHoles, diameter_regionDiameterRegion, orientation_regionOrientationRegion, moments_region_2ndMomentsRegion2nd, moments_region_2nd_invarMomentsRegion2ndInvar, moments_region_2nd_rel_invarMomentsRegion2ndRelInvar, moments_region_3rdMomentsRegion3rd, moments_region_3rd_invarMomentsRegion3rdInvar, moments_region_centralMomentsRegionCentral, moments_region_central_invarMomentsRegionCentralInvar, select_objSelectObj

ModuleπŸ”—

Foundation