Choose regions with the aid of shape features.
The operator ::select_shape chooses regions according to shape. For each input region from Regions the indicated features (Features) are calculated. If each (Operation = 'and') or at least one (Operation = 'or') of the calculated features is within the default limits (Min,Max) the region is adapted into the output (duplicated).
Condition: Min_i <= Feature_i(Object) <= Max_i
Possible values for Features:
'area' Area of the object
'row' Line index of the center
'column' Column index of the center
'width' Width of the region
'height' Height of the region
'row1' Line index of upper left corner
'column1' Column index of upper left corner
'row2' Line index of lower right corner
'column2' Column index of lower right corner
'circularity' Roundness (see procedure ::circularity)
'compactness' Compactness (see procedure ::compactness)
'contlength' total length of contour (see procedure
::contlength)
'convexity' Convexity (see procedure ::convexity)
'ra' Main radius (see procedure ::elliptic_axis)
'rb' Secondary radius (see procedure ::elliptic_axis)
'phi' Orientation (see procedure ::elliptic_axis)
'anisometry' Anisometry (see procedure ::eccentricity)
'outer_radius' Radius of smallest surrounding circle
'inner_radius' Radius of largest inner circle
'roundness' Roundness (see procedure ::roundness)
'num_sides' Number of polygon sides (see procedure
::roundness)
If only one feature (Features) is used the value of Operation is meaningless. Several features are processed in the sequence in which they are entered.
|
Regions (input_object) |
region-array -> Hobject: HRegionArray |
| Regions to be examined. | |
|
SelectedRegions (output_object) |
region-array -> Hobject * : HRegionArray |
| Regions fulfilling the condition. | |
|
Features (input_control) |
string(-array) -> HTuple.char * |
| Shape features to be checked. | |
| Default value: 'area' | |
| List of values: 'area', 'row', 'column', 'width', 'height', 'row1', 'column1', 'row2', 'column2', 'circularity', 'compactness', 'contlength', 'convexity', 'ra', 'rb', 'phi', 'anisometry', 'outer_radius', 'inner_radius', 'roundness', 'num_sides' | |
|
Operation (input_control) |
string -> HTuple.char * |
| Linkage type of the individual features. | |
| Default value: 'and' | |
| List of values: 'and', 'or' | |
|
Min (input_control) |
real(-array) -> HTuple.double / long / char * |
| Lower limits of the features or 'min'. | |
| Default value: 150.0 | |
| Typical range of values: 0.0 <= Min <= 99999.0 | |
| Minimum increment: 0.001 | |
|
Recommended increment: 1.0 | |
|
Max (input_control) |
real(-array) -> HTuple.double / long / char * |
| Upper limits of the features or 'max'. | |
| Default value: 99999.0 | |
| Typical range of values: 0.0 <= Max <= 99999.0 | |
| Minimum increment: 0.001 | |
|
Recommended increment: 1.0 | |
| Restriction: Max >= Min | |
#include <iostream.h>
#include "HalconCpp.h"
int main ()
{
HImage img ("affe");
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);
}
The operator ::select_shape returns the value 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 handling is raised.
::threshold, ::regiongrowing, ::connection, ::runlength_features
::select_shape, ::select_gray, ::shape_trans, ::reduce_domain, ::count_obj
::circularity, ::compactness, ::contlength, ::convexity, ::elliptic_axis, ::eccentricity, ::inner_circle, ::smallest_circle, ::smallest_rectangle1, ::smallest_rectangle2, ::select_obj, ::roundness
Region processing