smallest_circlesmallest_circleSmallestCircleSmallestCirclesmallest_circle (Operator)

Name

smallest_circlesmallest_circleSmallestCircleSmallestCirclesmallest_circle — Smallest surrounding circle of a region.

Signature

smallest_circle(Regions : : : Row, Column, Radius)

Herror smallest_circle(const Hobject Regions, double* Row, double* Column, double* Radius)

Herror T_smallest_circle(const Hobject Regions, Htuple* Row, Htuple* Column, Htuple* Radius)

void SmallestCircle(const HObject& Regions, HTuple* Row, HTuple* Column, HTuple* Radius)

void HRegion::SmallestCircle(HTuple* Row, HTuple* Column, HTuple* Radius) const

void HRegion::SmallestCircle(double* Row, double* Column, double* Radius) const

static void HOperatorSet.SmallestCircle(HObject regions, out HTuple row, out HTuple column, out HTuple radius)

void HRegion.SmallestCircle(out HTuple row, out HTuple column, out HTuple radius)

void HRegion.SmallestCircle(out double row, out double column, out double radius)

def smallest_circle(regions: HObject) -> Tuple[Sequence[float], Sequence[float], Sequence[float]]

def smallest_circle_s(regions: HObject) -> Tuple[float, float, float]

Description

The operator smallest_circlesmallest_circleSmallestCircleSmallestCircleSmallestCirclesmallest_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 (RowRowRowRowrowrow,ColumnColumnColumnColumncolumncolumn) and the radius (RadiusRadiusRadiusRadiusradiusradius) are calculated. The operator 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 operator is selected in such a way that it can be used as input for the operators disp_circledisp_circleDispCircleDispCircleDispCircledisp_circle and gen_circlegen_circleGenCircleGenCircleGenCirclegen_circle.

In the documentation of this chapter (Regions / Features), you can find an image illustrating regions with varying outer and inner radii.

If several regions are passed in RegionsRegionsRegionsRegionsregionsregions 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_systemset_systemSetSystemSetSystemSetSystemset_system).

Attention

Internally, the calculation is based on the center coordinates of the region pixels. To take into account that pixels are not just infinitely small points but have a certain area, the calculated radius is enlarged by 0.5 before it is returned in RadiusRadiusRadiusRadiusradiusradius. This, in most cases, gives acceptable results. However, in the worst case (pixel diagonal) this enlargement is not sufficient. If one wants to ensure that the border of the input region completely lies within the circle, one had to enlarge the radius by instead of 0.5. Consequently, the value returned in RadiusRadiusRadiusRadiusradiusradius must be corrected by . However, this would also be only an upper bound, i.e., the circle with the corrected radius would be slightly too big in most cases.

The smallest surrounding circle of a region. Note that the calculation is based on the center coordinates of the region pixels and that 0.5 is added to the resulting radius.

Execution Information

Parameters

RegionsRegionsRegionsRegionsregionsregions (input_object)  region(-array) objectHRegionHObjectHRegionHobject

Regions to be examined.

RowRowRowRowrowrow (output_control)  circle.center.y(-array) HTupleSequence[float]HTupleHtuple (real) (double) (double) (double)

Line index of the center.

ColumnColumnColumnColumncolumncolumn (output_control)  circle.center.x(-array) HTupleSequence[float]HTupleHtuple (real) (double) (double) (double)

Column index of the center.

RadiusRadiusRadiusRadiusradiusradius (output_control)  circle.radius(-array) HTupleSequence[float]HTupleHtuple (real) (double) (double) (double)

Radius of the surrounding circle.

Assertion: Radius >= 0

Example (HDevelop)

read_image(Image,'fabrik')
regiongrowing(Image,Regions,5,5,6,100)
select_shape(Regions,SelectedRegions,'area','and',100,2000)
smallest_circle(SelectedRegions,Row,Column,Radius)
gen_circle(Circles,Row,Column,Radius)
dev_display (Circles)

Example (C)

read_image(&Image,"fabrik");
regiongrowing(Image,&Regions,5,5,6.0,100);
select_shape(Regions,&SelectedRegions,"area","and",100.0,2000.0);
T_smallest_circle(SelectedRegions,&Row,&Column,&Radius);
T_gen_circle(&Circles,Row,Column,Radius);

Example (HDevelop)

read_image(Image,'fabrik')
regiongrowing(Image,Regions,5,5,6,100)
select_shape(Regions,SelectedRegions,'area','and',100,2000)
smallest_circle(SelectedRegions,Row,Column,Radius)
gen_circle(Circles,Row,Column,Radius)
dev_display (Circles)

Example (HDevelop)

read_image(Image,'fabrik')
regiongrowing(Image,Regions,5,5,6,100)
select_shape(Regions,SelectedRegions,'area','and',100,2000)
smallest_circle(SelectedRegions,Row,Column,Radius)
gen_circle(Circles,Row,Column,Radius)
dev_display (Circles)

Example (HDevelop)

read_image(Image,'fabrik')
regiongrowing(Image,Regions,5,5,6,100)
select_shape(Regions,SelectedRegions,'area','and',100,2000)
smallest_circle(SelectedRegions,Row,Column,Radius)
gen_circle(Circles,Row,Column,Radius)
dev_display (Circles)

Complexity

If F is the area of the region, then the mean runtime complexity is O(sqrt(F).

Result

The operator smallest_circlesmallest_circleSmallestCircleSmallestCircleSmallestCirclesmallest_circle 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>)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>)SetSystem("empty_region_result",<Result>)set_system("empty_region_result",<Result>). If necessary an exception is raised.

Possible Predecessors

thresholdthresholdThresholdThresholdThresholdthreshold, regiongrowingregiongrowingRegiongrowingRegiongrowingRegiongrowingregiongrowing, connectionconnectionConnectionConnectionConnectionconnection, runlength_featuresrunlength_featuresRunlengthFeaturesRunlengthFeaturesRunlengthFeaturesrunlength_features

Possible Successors

gen_circlegen_circleGenCircleGenCircleGenCirclegen_circle, disp_circledisp_circleDispCircleDispCircleDispCircledisp_circle

Alternatives

elliptic_axiselliptic_axisEllipticAxisEllipticAxisEllipticAxiselliptic_axis, smallest_rectangle1smallest_rectangle1SmallestRectangle1SmallestRectangle1SmallestRectangle1smallest_rectangle1, smallest_rectangle2smallest_rectangle2SmallestRectangle2SmallestRectangle2SmallestRectangle2smallest_rectangle2

See also

set_shapeset_shapeSetShapeSetShapeSetShapeset_shape, select_shapeselect_shapeSelectShapeSelectShapeSelectShapeselect_shape, inner_circleinner_circleInnerCircleInnerCircleInnerCircleinner_circle

Module

Foundation