Skip to content

union_adjacent_contours_xldunion_adjacent_contours_xldUnionAdjacentContoursXldUnionAdjacentContoursXldunion_adjacent_contours_xldunion_adjacent_contours_xldπŸ”—

Short descriptionπŸ”—

union_adjacent_contours_xldunion_adjacent_contours_xldUnionAdjacentContoursXldUnionAdjacentContoursXldunion_adjacent_contours_xldunion_adjacent_contours_xld β€” Compute the union of contours whose end points are close together.

SignatureπŸ”—

union_adjacent_contours_xld( xld_cont Contours, out xld_cont UnionContours, real MaxDistAbs, real MaxDistRel, string Mode )union_adjacent_contours_xld( Contours : UnionContours : MaxDistAbs, MaxDistRel, Mode : )void UnionAdjacentContoursXld( const HObject& Contours, HObject* UnionContours, const HTuple& MaxDistAbs, const HTuple& MaxDistRel, const HTuple& Mode )static void HOperatorSet.UnionAdjacentContoursXld( HObject contours, out HObject unionContours, HTuple maxDistAbs, HTuple maxDistRel, HTuple mode )def union_adjacent_contours_xld( contours: HObject, max_dist_abs: float, max_dist_rel: float, mode: str ) -> HObject

Herror union_adjacent_contours_xld( const Hobject Contours, Hobject* UnionContours, double MaxDistAbs, double MaxDistRel, const char* Mode )

Herror T_union_adjacent_contours_xld( const Hobject Contours, Hobject* UnionContours, const Htuple MaxDistAbs, const Htuple MaxDistRel, const Htuple Mode )

HXLDCont HXLDCont::UnionAdjacentContoursXld( double MaxDistAbs, double MaxDistRel, const HString& Mode ) const

HXLDCont HXLDCont::UnionAdjacentContoursXld( double MaxDistAbs, double MaxDistRel, const char* Mode ) const

HXLDCont HXLDCont::UnionAdjacentContoursXld( double MaxDistAbs, double MaxDistRel, const wchar_t* Mode ) const (Windows only)

HXLDCont HXLDCont.UnionAdjacentContoursXld( double maxDistAbs, double maxDistRel, string mode )

DescriptionπŸ”—

The operator union_adjacent_contours_xldUnionAdjacentContoursXld unifies all contours of the input XLD contour array (Contourscontourscontours) whose end points are close together. The unified contour consists of the concatenation of the contour points of the input contours. If necessary, the order of these input contour points is flipped, so that the end points of the contours that have to be connected are direct neighbors in the resulting point list. This operation is repeated until there are no more unconnected adjacent contours left. As a result all the contours that are newly created by unification, as well as the input contours that could not be connected with any other contour, are returned in UnionContoursunionContoursunion_contours.

Parameters

The parameters MaxDistAbsmaxDistAbsmax_dist_abs and MaxDistRelmaxDistRelmax_dist_rel are used to define the conditions for the proximity of two contours. In principle, the measures for these parameters depend on the order in which each pair of contours is evaluated, i.e., which contour is used as reference contour that is to be joined with the second contour. To avoid this dependency, the respective measures are evaluated in both directions and the order of contours is chosen that results in the smaller value for these measures. Note that in the illustrations below, the contour on the left is always used as the reference contour. The parameter Modemodemode controls the handling of the attributes of the input contours.

  • MaxDistAbsmaxDistAbsmax_dist_abs The parameter MaxDistAbsmaxDistAbsmax_dist_abs defines the maximum accepted absolute distance between the two contours. The distance is measured along the regression line of the reference contour. Thus, it is the length of the projection of the gap between the two contours onto the regression line of the reference contour.

    \(a \leq \textrm{MaxDistAbs}\)

  • MaxDistRelmaxDistRelmax_dist_rel The parameter MaxDistRelmaxDistRelmax_dist_rel defines the maximum accepted relative distance between the two contours. The relative distance is calculated by dividing the distance a (see the description of the parameter MaxDistAbsmaxDistAbsmax_dist_abs) by the length b of the reference contour.

    \(\frac{a}{b} \leq \textrm{MaxDistRel}\)

    The order for connecting adjacent contours depends mainly on the distance of the neighbored end points: the contours with the smallest distance are connected first. If there are two pairs of contours with the same distance, first the contour pair that does not contain the shortest contour is connected.

  • Modemodemode

    Finally, by the parameter Modemodemode it is possible to control how to handle the attributes that may come with input contours. For example, the operator edges_sub_pixEdgesSubPix attaches to every contour point attributes like the local orientation, the edge response, and the edge direction. Choosing the default value 'attr_keep'"attr_keep", all attributes are copied to the output, and - if a contour has to be flipped for connecting it with another one - they are adapted to the new orientation. With a great number of input contours, however, it may be sensible to ignore the attributes for performance reasons, if they are not needed for further calculations. For this the value 'attr_forget'"attr_forget" has to be passed.

Execution informationπŸ”—

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πŸ”—

Contourscontourscontours (input_object) xld_cont-array β†’ objectobjectHObjectHXLDContHObjectHobject

Input XLD contours.

UnionContoursunionContoursunion_contours (output_object) xld_cont-array β†’ objectobjectHObjectHXLDContHObjectHobject *

Output XLD contours.

MaxDistAbsmaxDistAbsmax_dist_abs (input_control) real β†’ (real)(real)HTuple (double)HTuple (double)floatHtuple (double)

Maximum distance of the contours’ end points.

Default: 10.010.0
Value range: 0.0 ≀ MaxDistAbs

MaxDistRelmaxDistRelmax_dist_rel (input_control) real β†’ (real)(real)HTuple (double)HTuple (double)floatHtuple (double)

Maximum distance of the contours’ end points in relation to the length of the longer contour.

Default: 1.01.0
Value range: 0.0 ≀ MaxDistRel

Modemodemode (input_control) string β†’ (string)(string)HTuple (HString)HTuple (string)strHtuple (char*)

Mode describing the treatment of the contours’ attributes.

Default: 'attr_keep'"attr_keep"
List of values: 'attr_forget', 'attr_keep'"attr_forget", "attr_keep"

Combinations with other operatorsπŸ”—

Combinations

Possible predecessors

split_contours_xldSplitContoursXld, select_contours_xldSelectContoursXld

Alternatives

union_collinear_contours_xldUnionCollinearContoursXld, union_collinear_contours_ext_xldUnionCollinearContoursExtXld, union_cocircular_contours_xldUnionCocircularContoursXld, union_straight_contours_xldUnionStraightContoursXld, union_cotangential_contours_xldUnionCotangentialContoursXld

See also

edges_sub_pixEdgesSubPix, threshold_sub_pixThresholdSubPix, gen_polygons_xldGenPolygonsXld, split_contours_xldSplitContoursXld, select_contours_xldSelectContoursXld, get_contour_xldGetContourXld, get_contour_attrib_xldGetContourAttribXld

ModuleπŸ”—

Foundation