Skip to content

lines_colorLinesColorLinesColorlines_colorlines_color๐Ÿ”—

Short description๐Ÿ”—

lines_colorLinesColorLinesColorlines_colorlines_color โ€” Detect color lines and their width.

Signature๐Ÿ”—

lines_color( image Image, out xld_cont Lines, number Sigma, number Low, number High, string ExtractWidth, string CompleteJunctions )void LinesColor( const HObject& Image, HObject* Lines, const HTuple& Sigma, const HTuple& Low, const HTuple& High, const HTuple& ExtractWidth, const HTuple& CompleteJunctions )static void HOperatorSet.LinesColor( HObject image, out HObject lines, HTuple sigma, HTuple low, HTuple high, HTuple extractWidth, HTuple completeJunctions )def lines_color( image: HObject, sigma: Union[float, int], low: Union[float, int], high: Union[float, int], extract_width: str, complete_junctions: str ) -> HObject

Herror lines_color( const Hobject Image, Hobject* Lines, double Sigma, double Low, double High, const char* ExtractWidth, const char* CompleteJunctions )

Herror T_lines_color( const Hobject Image, Hobject* Lines, const Htuple Sigma, const Htuple Low, const Htuple High, const Htuple ExtractWidth, const Htuple CompleteJunctions )

HXLDCont HImage::LinesColor( const HTuple& Sigma, const HTuple& Low, const HTuple& High, const HString& ExtractWidth, const HString& CompleteJunctions ) const

HXLDCont HImage::LinesColor( double Sigma, double Low, double High, const HString& ExtractWidth, const HString& CompleteJunctions ) const

HXLDCont HImage::LinesColor( double Sigma, double Low, double High, const char* ExtractWidth, const char* CompleteJunctions ) const

HXLDCont HImage::LinesColor( double Sigma, double Low, double High, const wchar_t* ExtractWidth, const wchar_t* CompleteJunctions ) const (Windows only)

HXLDCont HImage.LinesColor( HTuple sigma, HTuple low, HTuple high, string extractWidth, string completeJunctions )

HXLDCont HImage.LinesColor( double sigma, double low, double high, string extractWidth, string completeJunctions )

Description๐Ÿ”—

lines_colorLinesColor extracts color lines from the input image Imageimageimage and returns the extracted lines as subpixel precise XLD-contours in Lineslineslines. Color lines are defined as dark lines in the amplitude image of the color edge filter (see edges_colorEdgesColor). lines_colorLinesColor always uses the Canny color edge filter. Hence, the required partial derivatives of the image are always computed by convolution with the respective partial derivatives of the Gaussian smoothing masks (see derivate_gaussDerivateGauss). The corresponding smoothing is determined by the parameter Sigmasigmasigma.

By defining color lines as dark lines in the amplitude image, in contrast to lines_gaussLinesGauss, for single-channel images no distinction is made whether the lines are darker or brighter than their surroundings. Furthermore, lines_colorLinesColor also returns staircase lines, i.e., lines for which the gray value of the lines lies between the gray values in the surrounding area to the left and right sides of the line. In multi-channel images, the above definition allows each channel to have a different line type. For example, in a three-channel image the first channel may have a dark line, the second channel a bright line, and the third channel a staircase line at the same position.

If ExtractWidthextractWidthextract_width is set to 'true'"true" the line width is extracted for each line point. Because the line extractor is unable to extract certain junctions because of differential geometric reasons, it tries to extract these by different means if CompleteJunctionscompleteJunctionscomplete_junctions is set to 'true'"true".

lines_colorLinesColor links the line points into lines by using an algorithm similar to a hysteresis threshold operation, which is also used in lines_gaussLinesGauss and edges_color_sub_pixEdgesColorSubPix. Points with an amplitude larger than Highhighhigh are immediately accepted as belonging to a line, while points with an amplitude smaller than Lowlowlow are rejected. All other points are accepted as lines if they are connected to accepted line points (see also lines_gaussLinesGauss). Here, amplitude means the line amplitude of the dark line (see lines_gaussLinesGauss and lines_facetLinesFacet). This value corresponds to the third directional derivative of the smoothed input image in the direction perpendicular to the line.

For the choice of the thresholds Highhighhigh and Lowlowlow one has to keep in mind that the third directional derivative depends on the amplitude and width of the line as well as the choice of Sigmasigmasigma. The value of the third derivative depends linearly on the amplitude, i.e., the larger the amplitude, the larger the response. For the width of the line there is an inverse dependence: The wider the line is, the smaller the response gets. This holds analogously for the dependence on Sigmasigmasigma: The larger Sigmasigmasigma is chosen, the smaller the second derivative will be. This means that for larger smoothing correspondingly smaller values for Highhighhigh and Lowlowlow should be chosen.

The extracted lines are returned in a topologically sound data structure in Lineslineslines. This means that lines are correctly split at junction points.

lines_colorLinesColor defines the following attributes for each line point if ExtractWidthextractWidthextract_width was set to 'false'"false":

  • 'angle'"angle" The angle of the direction perpendicular to the line (oriented such that the normal vectors point to the right side of the line as the line is traversed from start to end point; the angles are given with respect to the row axis of the image.)

  • 'response'"response": The magnitude of the second derivative

If ExtractWidthextractWidthextract_width was set to 'true'"true", additionally the following attributes are defined:

  • 'width_left'"width_left": The line width to the left of the line

  • 'width_right'"width_right": The line width to the right of the line

Use get_contour_attrib_xldGetContourAttribXld to obtain attribute values. See the operator reference of get_contour_attrib_xldGetContourAttribXld for further information about contour attributes.

Attention๐Ÿ”—

In general, but in particular if the line width is to be extracted, \(\textrm{Sigma} \ge w/\sqrt{3}\) should be selected, where \(w\) is the width (half the diameter) of the lines in the image. As the lowest allowable value \(\textrm{Sigma} \ge w/2.5\) must be selected. If, for example, lines with a width of 4 pixels (diameter 8 pixels) are to be extracted, \(\textrm{Sigma} \ge 2.3\) should be selected. If it is expected that staircase lines are present in at least one channel, and if such lines should be extracted, in addition to the above restriction, \(\textrm{Sigma} \le w\) should be selected. This is necessary because staircase lines turn into normal step edges for large amounts of smoothing, and therefore no longer appear as dark lines in the amplitude image of the color edge filter.

Note that filter operators may return unexpected results if an image with a reduced domain is used as input. Please refer to the chapter Filters.

Execution information๐Ÿ”—

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Automatically parallelized on internal data level.

Parameters๐Ÿ”—

Imageimageimage (input_object) (multichannel-)image โ†’ object (byte / uint2)HObject (byte / uint2)HImage (byte / uint2)HObject (byte / uint2)Hobject (byte / uint2)

Input image.

Lineslineslines (output_object) xld_cont-array โ†’ objectHObjectHXLDContHObjectHobject *

Extracted lines.

Sigmasigmasigma (input_control) number โ†’ (real / integer)HTuple (double / Hlong)HTuple (double / int / long)Union[float, int]Htuple (double / Hlong)

Amount of Gaussian smoothing to be applied.

Default: 1.51.5
Suggested values: 1, 1.2, 1.5, 1.8, 2, 2.5, 3, 4, 51, 1.2, 1.5, 1.8, 2, 2.5, 3, 4, 5
Recommended increment: 0.1
Restriction: Sigma > 0.0

Lowlowlow (input_control) number โ†’ (real / integer)HTuple (double / Hlong)HTuple (double / int / long)Union[float, int]Htuple (double / Hlong)

Lower threshold for the hysteresis threshold operation.

Default: 33
Suggested values: 0, 0.5, 1, 2, 3, 4, 5, 8, 100, 0.5, 1, 2, 3, 4, 5, 8, 10
Value range: 0 โ‰ค Low
Recommended increment: 0.5

Highhighhigh (input_control) number โ†’ (real / integer)HTuple (double / Hlong)HTuple (double / int / long)Union[float, int]Htuple (double / Hlong)

Upper threshold for the hysteresis threshold operation.

Default: 88
Suggested values: 0, 0.5, 1, 2, 3, 4, 5, 8, 10, 12, 15, 18, 20, 250, 0.5, 1, 2, 3, 4, 5, 8, 10, 12, 15, 18, 20, 25
Value range: 0 โ‰ค High
Recommended increment: 0.5
Restriction: High >= Low

ExtractWidthextractWidthextract_width (input_control) string โ†’ (string)HTuple (HString)HTuple (string)strHtuple (char*)

Should the line width be extracted?

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

CompleteJunctionscompleteJunctionscomplete_junctions (input_control) string โ†’ (string)HTuple (HString)HTuple (string)strHtuple (char*)

Should junctions be added where they cannot be extracted?

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

Complexity๐Ÿ”—

The amount of temporary memory required is dependent on the height \(H\) of the domain of Imageimageimage.

Result๐Ÿ”—

lines_colorLinesColor returns 2 (H_MSG_TRUE) if all parameters are correct and no error occurs during execution. If the input is empty the behavior can be set via set_system(::'no_object_result',<Result>:). If necessary, an exception is raised.

Combinations with other operators๐Ÿ”—

Combinations

Possible successors

gen_polygons_xldGenPolygonsXld

Alternatives

lines_gaussLinesGauss, lines_facetLinesFacet

See also

edges_colorEdgesColor, edges_color_sub_pixEdgesColorSubPix

References๐Ÿ”—

C. Steger: โ€œSubpixel-Precise Extraction of Lines and Edgesโ€; International Archives of Photogrammetry and Remote Sensing, vol. XXXIII, part B3; pp. 141-156; 2000.

C. Steger: โ€œAn Unbiased Detector of Curvilinear Structuresโ€; IEEE Transactions on Pattern Analysis and Machine Intelligence; vol. 20, no. 2; pp. 113-125; 1998.

C. Steger: ``Unbiased Extraction of Curvilinear Structures from 2D and 3D Imagesโ€™โ€˜; Herbert Utz Verlag, Mรผnchen; 1998.

Module๐Ÿ”—

2D Metrology