Smallest surrounding circle of a region.
The operator ::smallest_circle determines the smallest surrounding circle of a region, i.e. the circle with the smallest area of all circles containing the region. For this circle the center (Row,Column) and the radius (Radius) are calculated. The procedure is applied when, for example, the location and size of circular objects (e.g. coins) which, however, are not homogeneous inside or have broken edges due to bad segmentation, has to be determined. The output of the procedure is selected in such a way that it can be used as input for the HALCON procedures ::disp_circle and ::gen_circle.
If several regions are passed in Regions corresponding tuples are returned as output parameter. In case of empty region all parameters have the value 0.0 if no other behavior was set (see ::set_system).
|
Regions (input_object) |
region(-array) -> Hobject: HRegion(Array) |
| Regions to be examined. | |
|
Row (output_control) |
circle.center.y(-array) -> (HTuple.) double * |
| Line index of the center. | |
|
Column (output_control) |
circle.center.x(-array) -> (HTuple.) double * |
| Column index of the center. | |
|
Radius (output_control) |
circle.radius(-array) -> (HTuple.) double * |
| Radius of the surrounding circle. | |
| Assertion: Radius >= 0 | |
#include <iostream.h>
#include "HalconCpp.h"
int main (int argc, char *argv[])
{
Tuple row, col, rad;
HImage img (argv[1]);
HWindow w;
img.Display (w);
HRegionArray reg = img.Regiongrowing (5, 5, 6.0, 100);
HRegionArray seg = reg.SelectShape ("area", "and", 100.0, 1000.0);
row = seg.SmallestCircle (&col, &rad);
HRegionArray circ = HRegionArray::GenCircle (row, col, rad);
w.SetDraw ("margin");
w.SetColor ("green"); reg.Display (w);
w.SetColor ("blue"); seg.Display (w);
w.SetColor ("red"); circ.Display (w);
w.Click ();
return(0);
}
If F is the area of the region and N is the number of supporting points of the convex hull, the mean runtime complexity is O(F + N^3).
The operator ::smallest_circle returns the value 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>). 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
::elliptic_axis, ::smallest_rectangle1, ::smallest_rectangle2
::set_shape, ::select_shape, ::inner_circle
Region processing