Skip to content

union_straight_contours_xldUnionStraightContoursXldUnionStraightContoursXldunion_straight_contours_xldunion_straight_contours_xldπŸ”—

Short descriptionπŸ”—

union_straight_contours_xldUnionStraightContoursXldUnionStraightContoursXldunion_straight_contours_xldunion_straight_contours_xld β€” Compute the union of neighboring straight contours that have a similar direction.

SignatureπŸ”—

union_straight_contours_xld( xld_cont Contours, out xld_cont UnionContours, real MaxDist, angle.rad MaxDiff, real Percent, string Mode, string Iterations )void UnionStraightContoursXld( const HObject& Contours, HObject* UnionContours, const HTuple& MaxDist, const HTuple& MaxDiff, const HTuple& Percent, const HTuple& Mode, const HTuple& Iterations )static void HOperatorSet.UnionStraightContoursXld( HObject contours, out HObject unionContours, HTuple maxDist, HTuple maxDiff, HTuple percent, HTuple mode, HTuple iterations )def union_straight_contours_xld( contours: HObject, max_dist: float, max_diff: float, percent: float, mode: str, iterations: Union[int, str] ) -> HObject

Herror union_straight_contours_xld( const Hobject Contours, Hobject* UnionContours, double MaxDist, double MaxDiff, double Percent, const char* Mode, const char* Iterations )

Herror T_union_straight_contours_xld( const Hobject Contours, Hobject* UnionContours, const Htuple MaxDist, const Htuple MaxDiff, const Htuple Percent, const Htuple Mode, const Htuple Iterations )

HXLDCont HXLDCont::UnionStraightContoursXld( double MaxDist, double MaxDiff, double Percent, const HString& Mode, const HTuple& Iterations ) const

HXLDCont HXLDCont::UnionStraightContoursXld( double MaxDist, double MaxDiff, double Percent, const HString& Mode, const HString& Iterations ) const

HXLDCont HXLDCont::UnionStraightContoursXld( double MaxDist, double MaxDiff, double Percent, const char* Mode, const char* Iterations ) const

HXLDCont HXLDCont::UnionStraightContoursXld( double MaxDist, double MaxDiff, double Percent, const wchar_t* Mode, const wchar_t* Iterations ) const (Windows only)

HXLDCont HXLDCont.UnionStraightContoursXld( double maxDist, double maxDiff, double percent, string mode, HTuple iterations )

HXLDCont HXLDCont.UnionStraightContoursXld( double maxDist, double maxDiff, double percent, string mode, string iterations )

DescriptionπŸ”—

union_straight_contours_xldUnionStraightContoursXld merges neighboring XLD contours Contourscontourscontours if certain criteria are fulfilled. At each iteration, at most two contours that fulfill the given criteria are merged. The parameter Iterationsiterationsiterations controls how often this step is executed.

Two contours are merged if the shortest distance between their end points (end points are the projections of the contours’ first and last points onto its regression line) is smaller than MaxDistmaxDistmax_dist, and if the difference in direction (i.e., the regression lines’ direction) is smaller than MaxDiffmaxDiffmax_diff (radians).

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

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

If only one of the criteria is fulfilled, the decision on merging can be influenced by the weighting factor Percentpercentpercent, which allows the exceeding of one limit to be balanced by the other value remaining below the limit by the same amount. The end point distance is weighted by Percentpercentpercent, while the directional difference is weighted by 100 - Percent.

This means that two contours are merged if they fulfill the following condition:

\[\begin{eqnarray*} \frac{shortest~distance}{\textrm{MaxDist}}\cdot\textrm{Percent} + \frac{direction~difference}{\textrm{MaxDiff}}\cdot(100-\textrm{Percent}) \le 100\end{eqnarray*}\]

If, for example, two contours have an end point distance of 5.0 and a directional difference of 0.5 (with the limits chosen being MaxDistmaxDistmax_dist = 4.04.0 and MaxDiffmaxDiffmax_diff = 0.6250.625), both values differ from the limits by 25%. By choosing Percentpercentpercent = 6060%, the larger end point distance is weighted more than the smaller directional difference, and thus the contours are not merged. Contrary, if Percentpercentpercent = 4040% is chosen, the contours are merged.

For Percentpercentpercent = 100100%, only the end point distance is taken into account, while for Percentpercentpercent = 00% only the difference of direction is used. If Percentpercentpercent = 5050% both criteria are equally valid.

In case there are parallel contours, there is a danger of merging neighboring contours. If this is to be avoided, Modemodemode = 'noparallel'"noparallel" has to be chosen, while otherwise Modemodemode = 'paralleltoo'"paralleltoo" suffices. For Modemodemode = 'every'"every", contours are merged unconditionally. All other parameters have no influence in this case.

The parameters of the regression line are calculated anew for merged contours.

AttentionπŸ”—

Before contours can be united by union_straight_contours_xldUnionStraightContoursXld, the parameters of the regression lines to the contours must be calculated by calling regress_contours_xldRegressContoursXld.

Furthermore, note that union_straight_contours_xldUnionStraightContoursXld can not compute the union of contours with different contour point attributes. This can be the case if different operators are used for the contour extraction (e.g., lines_gaussLinesGauss and lines_facetLinesFacet). For information on the contour attributes and when they are defined, see the respective operator reference. You can query the point attributes of your contour using query_contour_attribs_xldQueryContourAttribsXld.

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 β†’ objectHObjectHXLDContHObjectHobject

Input XLD contours.

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

Output XLD contours.

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

Maximum distance of the contours’ endpoints.

Default: 5.05.0

MaxDiffmaxDiffmax_diff (input_control) angle.rad β†’ (real)HTuple (double)HTuple (double)floatHtuple (double)

Maximum difference in direction.

Default: 0.50.5

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

Weighting factor for the two selection criteria.

Default: 50.050.0

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

Should parallel contours be taken into account?

Default: 'noparallel'"noparallel"
List of values: 'every', 'noparallel', 'paralleltoo'"every", "noparallel", "paralleltoo"

Iterationsiterationsiterations (input_control) string β†’ (string / integer)HTuple (HString / Hlong)HTuple (string / int / long)Union[int, str]Htuple (char* / Hlong)

Number of iterations or β€˜maximum’.

Default: 'maximum'"maximum"
Suggested values: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 'maximum'1, 2, 3, 4, 5, 6, 7, 8, 9, 10, "maximum"
Value range: 1 ≀ Iterations ≀ 500 (lin)
Minimum increment: 1
Recommended increment: 1

Combinations with other operatorsπŸ”—

Combinations

Possible predecessors

regress_contours_xldRegressContoursXld

Alternatives

union_collinear_contours_xldUnionCollinearContoursXld, union_collinear_contours_ext_xldUnionCollinearContoursExtXld, union_cocircular_contours_xldUnionCocircularContoursXld, union_cotangential_contours_xldUnionCotangentialContoursXld, union_adjacent_contours_xldUnionAdjacentContoursXld

See also

fit_line_contour_xldFitLineContourXld, get_contour_xldGetContourXld, get_contour_attrib_xldGetContourAttribXld, gen_contours_skeleton_xldGenContoursSkeletonXld, lines_gaussLinesGauss, lines_facetLinesFacet, edges_sub_pixEdgesSubPix, get_regress_params_xldGetRegressParamsXld, get_contour_global_attrib_xldGetContourGlobalAttribXld, query_contour_global_attribs_xldQueryContourGlobalAttribsXld

ModuleπŸ”—

Foundation