ClassesClassesClassesClasses | | | | Operators

union_cocircular_contours_xldunion_cocircular_contours_xldUnionCocircularContoursXldunion_cocircular_contours_xldUnionCocircularContoursXldUnionCocircularContoursXld (Operator)

Name

union_cocircular_contours_xldunion_cocircular_contours_xldUnionCocircularContoursXldunion_cocircular_contours_xldUnionCocircularContoursXldUnionCocircularContoursXld — Compute the union of contours that belong to the same circle.

Signature

union_cocircular_contours_xld(Contours : UnionContours : MaxArcAngleDiff, MaxArcOverlap, MaxTangentAngle, MaxDist, MaxRadiusDiff, MaxCenterDist, MergeSmallContours, Iterations : )

Herror union_cocircular_contours_xld(const Hobject Contours, Hobject* UnionContours, double MaxArcAngleDiff, double MaxArcOverlap, double MaxTangentAngle, double MaxDist, double MaxRadiusDiff, double MaxCenterDist, const char* MergeSmallContours, const Hlong Iterations)

Herror T_union_cocircular_contours_xld(const Hobject Contours, Hobject* UnionContours, const Htuple MaxArcAngleDiff, const Htuple MaxArcOverlap, const Htuple MaxTangentAngle, const Htuple MaxDist, const Htuple MaxRadiusDiff, const Htuple MaxCenterDist, const Htuple MergeSmallContours, const Htuple Iterations)

Herror union_cocircular_contours_xld(Hobject Contours, Hobject* UnionContours, const HTuple& MaxArcAngleDiff, const HTuple& MaxArcOverlap, const HTuple& MaxTangentAngle, const HTuple& MaxDist, const HTuple& MaxRadiusDiff, const HTuple& MaxCenterDist, const HTuple& MergeSmallContours, const HTuple& Iterations)

HXLDContArray HXLDContArray::UnionCocircularContoursXld(const HTuple& MaxArcAngleDiff, const HTuple& MaxArcOverlap, const HTuple& MaxTangentAngle, const HTuple& MaxDist, const HTuple& MaxRadiusDiff, const HTuple& MaxCenterDist, const HTuple& MergeSmallContours, const HTuple& Iterations) const

void UnionCocircularContoursXld(const HObject& Contours, HObject* UnionContours, const HTuple& MaxArcAngleDiff, const HTuple& MaxArcOverlap, const HTuple& MaxTangentAngle, const HTuple& MaxDist, const HTuple& MaxRadiusDiff, const HTuple& MaxCenterDist, const HTuple& MergeSmallContours, const HTuple& Iterations)

HXLDCont HXLDCont::UnionCocircularContoursXld(const HTuple& MaxArcAngleDiff, const HTuple& MaxArcOverlap, const HTuple& MaxTangentAngle, const HTuple& MaxDist, const HTuple& MaxRadiusDiff, const HTuple& MaxCenterDist, const HString& MergeSmallContours, Hlong Iterations) const

HXLDCont HXLDCont::UnionCocircularContoursXld(double MaxArcAngleDiff, double MaxArcOverlap, double MaxTangentAngle, double MaxDist, double MaxRadiusDiff, double MaxCenterDist, const HString& MergeSmallContours, Hlong Iterations) const

HXLDCont HXLDCont::UnionCocircularContoursXld(double MaxArcAngleDiff, double MaxArcOverlap, double MaxTangentAngle, double MaxDist, double MaxRadiusDiff, double MaxCenterDist, const char* MergeSmallContours, Hlong Iterations) const

void HOperatorSetX.UnionCocircularContoursXld(
[in] IHUntypedObjectX* Contours, [out] IHUntypedObjectX*UnionContours, [in] VARIANT MaxArcAngleDiff, [in] VARIANT MaxArcOverlap, [in] VARIANT MaxTangentAngle, [in] VARIANT MaxDist, [in] VARIANT MaxRadiusDiff, [in] VARIANT MaxCenterDist, [in] VARIANT MergeSmallContours, [in] VARIANT Iterations)

IHXLDContX* HXLDContX.UnionCocircularContoursXld(
[in] VARIANT MaxArcAngleDiff, [in] VARIANT MaxArcOverlap, [in] VARIANT MaxTangentAngle, [in] VARIANT MaxDist, [in] VARIANT MaxRadiusDiff, [in] VARIANT MaxCenterDist, [in] BSTR MergeSmallContours, [in] Hlong Iterations)

static void HOperatorSet.UnionCocircularContoursXld(HObject contours, out HObject unionContours, HTuple maxArcAngleDiff, HTuple maxArcOverlap, HTuple maxTangentAngle, HTuple maxDist, HTuple maxRadiusDiff, HTuple maxCenterDist, HTuple mergeSmallContours, HTuple iterations)

HXLDCont HXLDCont.UnionCocircularContoursXld(HTuple maxArcAngleDiff, HTuple maxArcOverlap, HTuple maxTangentAngle, HTuple maxDist, HTuple maxRadiusDiff, HTuple maxCenterDist, string mergeSmallContours, int iterations)

HXLDCont HXLDCont.UnionCocircularContoursXld(double maxArcAngleDiff, double maxArcOverlap, double maxTangentAngle, double maxDist, double maxRadiusDiff, double maxCenterDist, string mergeSmallContours, int iterations)

Description

The operator union_cocircular_contours_xldunion_cocircular_contours_xldUnionCocircularContoursXldunion_cocircular_contours_xldUnionCocircularContoursXldUnionCocircularContoursXld merges all contours that belong to the same circle. The result is a set of contours in which contours on the same circle are connected.

The algorithm tries to merge contours by first fitting circles to each contour and then examining the result by means of radius, circle center, and gap on the circular arc. The list of contours is processed in sequence of increasing radii. Contours to which no circle could be fitted are optionally merged in a second pass.

The threshold parameters are used to define whether contours belong to the same circle. All thresholds must be fulfilled simultaneously for two contours to be merged. The parameter MaxArcAngleDiffMaxArcAngleDiffMaxArcAngleDiffMaxArcAngleDiffMaxArcAngleDiffmaxArcAngleDiff defines the maximum angular distance in radians between the end point of one contour and the start point of a second contour on a circle. MaxArcOverlapMaxArcOverlapMaxArcOverlapMaxArcOverlapMaxArcOverlapmaxArcOverlap denotes the maximum angle by which contours may overlap. MaxTangentAngleMaxTangentAngleMaxTangentAngleMaxTangentAngleMaxTangentAnglemaxTangentAngle describes the maximum angle between circle tangents and the connecting line of two contours. MaxDistMaxDistMaxDistMaxDistMaxDistmaxDist denotes the maximum absolute distance in pixels of the end and start points of two contours. MaxRadiusDiffMaxRadiusDiffMaxRadiusDiffMaxRadiusDiffMaxRadiusDiffmaxRadiusDiff is the maximum absolute difference of the radii of circles fitted to the contours. MaxCenterDistMaxCenterDistMaxCenterDistMaxCenterDistMaxCenterDistmaxCenterDist is the limit of the Euclidian distance of the circle centers.

If the parameter MergeSmallContoursMergeSmallContoursMergeSmallContoursMergeSmallContoursMergeSmallContoursmergeSmallContours is set to 'true'"true""true""true""true""true", contours without fitted circles are also merged. For a small contour to match, each point of the contour needs to have a distance to the circle center which differs from the radius by not more then MaxRadiusDiffMaxRadiusDiffMaxRadiusDiffMaxRadiusDiffMaxRadiusDiffmaxRadiusDiff. The angle between a line between two consecutive points on the contour and the circle tangent must be within MaxTangentAngleMaxTangentAngleMaxTangentAngleMaxTangentAngleMaxTangentAnglemaxTangentAngle. Additionally, the condition for MaxDistMaxDistMaxDistMaxDistMaxDistmaxDist must be fulfilled.

For each possible merge of two contours a cost is calculated by summing up the distances corresponding to the different threshold values. For comparability, the distances are scaled by the thresholds to a value between 0.0 and 1.0. If two or more contour start points match to the same end point of another contour, the contour with the lower cost is merged.

Merging of contours leads to new circle parameters. Therefore, an iteration can lead to further merges. The parameter IterationsIterationsIterationsIterationsIterationsiterations controls the number of iterations. More than two iterations are seldom needed.

You should make sure that the input contours can be approximated by lines and circular arcs, for example by preprocessing them with split_contours_xldsplit_contours_xldSplitContoursXldsplit_contours_xldSplitContoursXldSplitContoursXld.

Attention

Note that already closed contours are not considered for a union anymore. That is, even if a contour and the already closed contour share the same circle, they are returned as separate contours.

Parallelization

Parameters

ContoursContoursContoursContoursContourscontours (input_object)  xld_cont-array objectHXLDContHXLDContHXLDContArrayHXLDContXHobject

Contours to be merged.

UnionContoursUnionContoursUnionContoursUnionContoursUnionContoursunionContours (output_object)  xld_cont-array objectHXLDContHXLDContHXLDContArrayHXLDContXHobject *

Merged contours.

MaxArcAngleDiffMaxArcAngleDiffMaxArcAngleDiffMaxArcAngleDiffMaxArcAngleDiffmaxArcAngleDiff (input_control)  angle.rad HTupleHTupleHTupleVARIANTHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong) (double / Hlong) (double / Hlong)

Maximum angular distance of two circular arcs.

Default value: 0.5

Suggested values: 0.25, 0.5, 0.75, 1.0

MaxArcOverlapMaxArcOverlapMaxArcOverlapMaxArcOverlapMaxArcOverlapmaxArcOverlap (input_control)  angle.rad HTupleHTupleHTupleVARIANTHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong) (double / Hlong) (double / Hlong)

Maximum overlap of two circular arcs.

Default value: 0.1

Suggested values: 0.0, 0.1, 0.2

MaxTangentAngleMaxTangentAngleMaxTangentAngleMaxTangentAngleMaxTangentAnglemaxTangentAngle (input_control)  angle.rad HTupleHTupleHTupleVARIANTHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong) (double / Hlong) (double / Hlong)

Maximum angle between the connecting line and the tangents of circular arcs.

Default value: 0.2

Suggested values: 0.1, 0.2, 0.3, 0.4, 0.5

MaxDistMaxDistMaxDistMaxDistMaxDistmaxDist (input_control)  number HTupleHTupleHTupleVARIANTHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong) (double / Hlong) (double / Hlong)

Maximum length of the gap between two circular arcs in pixels.

Default value: 30

Suggested values: 10, 30, 50, 70

MaxRadiusDiffMaxRadiusDiffMaxRadiusDiffMaxRadiusDiffMaxRadiusDiffmaxRadiusDiff (input_control)  number HTupleHTupleHTupleVARIANTHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong) (double / Hlong) (double / Hlong)

Maximum radius difference of the circles fitted to two arcs.

Default value: 10

Suggested values: 10, 20, 30

MaxCenterDistMaxCenterDistMaxCenterDistMaxCenterDistMaxCenterDistmaxCenterDist (input_control)  number HTupleHTupleHTupleVARIANTHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong) (double / Hlong) (double / Hlong)

Maximum center distance of the circles fitted to two arcs.

Default value: 10

Suggested values: 10, 20, 30

MergeSmallContoursMergeSmallContoursMergeSmallContoursMergeSmallContoursMergeSmallContoursmergeSmallContours (input_control)  string HTupleHTupleHTupleVARIANTHtuple (string) (string) (HString) (char*) (BSTR) (char*)

Determine whether small contours without fitted circles should also be merged.

Default value: 'true' "true" "true" "true" "true" "true"

List of values: 'false'"false""false""false""false""false", 'true'"true""true""true""true""true"

IterationsIterationsIterationsIterationsIterationsiterations (input_control)  integer HTupleHTupleHTupleVARIANTHtuple (integer) (int / long) (Hlong) (Hlong) (Hlong) (Hlong)

Number of iterations.

Default value: 1

Suggested values: 1, 2

Complexity

O(n^2) for n contours.

Result

union_cocircular_contours_xldunion_cocircular_contours_xldUnionCocircularContoursXldunion_cocircular_contours_xldUnionCocircularContoursXldUnionCocircularContoursXld returns 2 (H_MSG_TRUE) if all parameters are correct.

Possible Predecessors

split_contours_xldsplit_contours_xldSplitContoursXldsplit_contours_xldSplitContoursXldSplitContoursXld, select_contours_xldselect_contours_xldSelectContoursXldselect_contours_xldSelectContoursXldSelectContoursXld

Alternatives

union_collinear_contours_xldunion_collinear_contours_xldUnionCollinearContoursXldunion_collinear_contours_xldUnionCollinearContoursXldUnionCollinearContoursXld, union_cotangential_contours_xldunion_cotangential_contours_xldUnionCotangentialContoursXldunion_cotangential_contours_xldUnionCotangentialContoursXldUnionCotangentialContoursXld, union_straight_contours_xldunion_straight_contours_xldUnionStraightContoursXldunion_straight_contours_xldUnionStraightContoursXldUnionStraightContoursXld, union_adjacent_contours_xldunion_adjacent_contours_xldUnionAdjacentContoursXldunion_adjacent_contours_xldUnionAdjacentContoursXldUnionAdjacentContoursXld, union_collinear_contours_ext_xldunion_collinear_contours_ext_xldUnionCollinearContoursExtXldunion_collinear_contours_ext_xldUnionCollinearContoursExtXldUnionCollinearContoursExtXld

Module

Foundation


ClassesClassesClassesClasses | | | | Operators