select_shape_protoselect_shape_protoSelectShapeProtoSelectShapeProtoselect_shape_proto (Operator)
Name
select_shape_protoselect_shape_protoSelectShapeProtoSelectShapeProtoselect_shape_proto
— Choose regions having a certain relation to each other.
Signature
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)
void SelectShapeProto(const HObject& Regions, const 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
HRegion HRegion::SelectShapeProto(const HRegion& Pattern, const HString& Feature, double Min, double Max) const
HRegion HRegion::SelectShapeProto(const HRegion& Pattern, const char* Feature, double Min, double Max) const
HRegion HRegion::SelectShapeProto(const HRegion& Pattern, const wchar_t* Feature, double Min, double Max) const
(
Windows only)
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)
def select_shape_proto(regions: HObject, pattern: HObject, feature: MaybeSequence[str], min: Union[int, float], max: Union[int, float]) -> HObject
Description
The operator select_shape_protoselect_shape_protoSelectShapeProtoSelectShapeProtoselect_shape_proto
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'"distance_dilate""distance_dilate""distance_dilate""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_dilDistanceRrMinDilDistanceRrMinDildistance_rr_min_dil
).
- 'distance_contour'"distance_contour""distance_contour""distance_contour""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_minDistanceRrMinDistanceRrMindistance_rr_min
).
- 'distance_center'"distance_center""distance_center""distance_center""distance_center"
The Euclidean distance from the center of PatternPatternPatternpatternpattern
to the
center of every region from RegionsRegionsRegionsregionsregions
is determined.
- 'covers'"covers""covers""covers""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'"fits""fits""fits""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'"overlaps_abs""overlaps_abs""overlaps_abs""overlaps_abs"
The area of the intersection of PatternPatternPatternpatternpattern
and every region in
RegionsRegionsRegionsregionsregions
is computed.
- 'overlaps_rel'"overlaps_rel""overlaps_rel""overlaps_rel""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 area of the respective region in
RegionsRegionsRegionsregionsregions
(in percent).
Execution Information
- Multithreading type: reentrant (runs in parallel with non-exclusive operators).
- Multithreading scope: global (may be called from any thread).
- Processed without parallelization.
Parameters
RegionsRegionsRegionsregionsregions
(input_object) region(-array) →
objectHRegionHObjectHObjectHobject
Regions to be examined.
SelectedRegionsSelectedRegionsSelectedRegionsselectedRegionsselected_regions
(output_object) region(-array) →
objectHRegionHObjectHObjectHobject *
Regions fulfilling the condition.
FeatureFeatureFeaturefeaturefeature
(input_control) string(-array) →
HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)
Shape features to be checked.
Default:
'covers'
"covers"
"covers"
"covers"
"covers"
List of values:
'covers'"covers""covers""covers""covers", 'distance_center'"distance_center""distance_center""distance_center""distance_center", 'distance_contour'"distance_contour""distance_contour""distance_contour""distance_contour", 'distance_dilate'"distance_dilate""distance_dilate""distance_dilate""distance_dilate", '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 →
HTupleUnion[int, float]HTupleHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong)
Lower border of feature.
Default:
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
Value range:
0.0
≤
Min
Min
Min
min
min
Minimum increment:
0.001
Recommended increment:
5.0
MaxMaxMaxmaxmax
(input_control) number →
HTupleUnion[int, float]HTupleHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong)
Upper border of the feature.
Default:
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
Value range:
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);
}
Result
The operator select_shape_protoselect_shape_protoSelectShapeProtoSelectShapeProtoselect_shape_proto
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>)SetSystem("no_object_result",<Result>)SetSystem("no_object_result",<Result>)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>)set_system("empty_region_result",<Result>)SetSystem("empty_region_result",<Result>)SetSystem("empty_region_result",<Result>)set_system("empty_region_result",<Result>)
. If necessary an
exception is raised.
Possible Predecessors
connectionconnectionConnectionConnectionconnection
,
draw_regiondraw_regionDrawRegionDrawRegiondraw_region
,
gen_circlegen_circleGenCircleGenCirclegen_circle
,
gen_rectangle1gen_rectangle1GenRectangle1GenRectangle1gen_rectangle1
,
gen_rectangle2gen_rectangle2GenRectangle2GenRectangle2gen_rectangle2
,
gen_ellipsegen_ellipseGenEllipseGenEllipsegen_ellipse
Possible Successors
select_grayselect_graySelectGraySelectGrayselect_gray
,
shape_transshape_transShapeTransShapeTransshape_trans
,
reduce_domainreduce_domainReduceDomainReduceDomainreduce_domain
,
count_objcount_objCountObjCountObjcount_obj
Alternatives
select_shapeselect_shapeSelectShapeSelectShapeselect_shape
See also
openingopeningOpeningOpeningopening
,
erosion1erosion1Erosion1Erosion1erosion1
,
distance_rr_min_dildistance_rr_min_dilDistanceRrMinDilDistanceRrMinDildistance_rr_min_dil
,
distance_rr_mindistance_rr_minDistanceRrMinDistanceRrMindistance_rr_min
Module
Foundation