union_adjacent_contours_xld — Compute the union of contours whose end points are close together.
The operator union_adjacent_contours_xld unifies all contours of the input XLD contour array (Contours) 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 UnionContours.
The neighbored endpoints of two contours are connected if the distance between these end points neither exceeds an absolute threshold (MaxDistAbs) nor a relative threshold that is defined by the length of the longer contour multiplied by 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 paires of contours with the same distance, first the contour pair that does not contain the shortest contour is connected.
Finally, by the parameter Mode it is possible to control how to handle the attributes that may come with input contours. For example, the operator edges_sub_pix attaches to every contour point attributes like the local orientation, the edge response, and the edge direction. Choosing the default value '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' has to be passed.
Input XLD contours.
Output XLD contours.
Maximum distance of the contours' end points.
Default value: 10.0
Typical range of values: 0.0 ≤ MaxDistAbs
Maximum distance of the contours' end points in relation to the length of the longer contour.
Default value: 1.0
Typical range of values: 0.0 ≤ MaxDistRel
Mode describing the treatment of the contours' attributes.
Default value: 'attr_keep'
List of values: 'attr_forget', 'attr_keep'
union_collinear_contours_xld, union_collinear_contours_ext_xld, union_cocircular_contours_xld, union_straight_contours_xld, union_cotangential_contours_xld
edges_sub_pix, threshold_sub_pix, gen_polygons_xld, split_contours_xld, select_contours_xld, get_contour_xld, get_contour_attrib_xld