lines_colorlines_colorLinesColorLinesColor (Operator)


lines_colorlines_colorLinesColorLinesColor — Detect color lines and their width.


lines_color(Image : Lines : Sigma, Low, High, ExtractWidth, CompleteJunctions : )

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)

void LinesColor(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)

static void HOperatorSet.LinesColor(HObject image, out HObject lines, HTuple sigma, HTuple low, HTuple high, HTuple extractWidth, HTuple completeJunctions)

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)


lines_colorlines_colorLinesColorLinesColorLinesColor extracts color lines from the input image ImageImageImageImageimage and returns the extracted lines as subpixel precise XLD-contours in LinesLinesLinesLineslines. Color lines are defined as dark lines in the amplitude image of the color edge filter (see edges_coloredges_colorEdgesColorEdgesColorEdgesColor). lines_colorlines_colorLinesColorLinesColorLinesColor 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_gaussderivate_gaussDerivateGaussDerivateGaussDerivateGauss). The corresponding smoothing is determined by the parameter SigmaSigmaSigmaSigmasigma.

By defining color lines as dark lines in the amplitude image, in contrast to lines_gausslines_gaussLinesGaussLinesGaussLinesGauss, for single-channel images no distinction is made whether the lines are darker or brighter than their surroundings. Furthermore, lines_colorlines_colorLinesColorLinesColorLinesColor 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 ExtractWidthExtractWidthExtractWidthExtractWidthextractWidth is set to 'true'"true""true""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 CompleteJunctionsCompleteJunctionsCompleteJunctionsCompleteJunctionscompleteJunctions is set to 'true'"true""true""true""true".

lines_colorlines_colorLinesColorLinesColorLinesColor links the line points into lines by using an algorithm similar to a hysteresis threshold operation, which is also used in lines_gausslines_gaussLinesGaussLinesGaussLinesGauss and edges_color_sub_pixedges_color_sub_pixEdgesColorSubPixEdgesColorSubPixEdgesColorSubPix. Points with an amplitude larger than HighHighHighHighhigh are immediately accepted as belonging to a line, while points with an amplitude smaller than LowLowLowLowlow are rejected. All other points are accepted as lines if they are connected to accepted line points (see also lines_gausslines_gaussLinesGaussLinesGaussLinesGauss). Here, amplitude means the line amplitude of the dark line (see lines_gausslines_gaussLinesGaussLinesGaussLinesGauss and lines_facetlines_facetLinesFacetLinesFacetLinesFacet). 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 HighHighHighHighhigh and LowLowLowLowlow 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 SigmaSigmaSigmaSigmasigma. 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 SigmaSigmaSigmaSigmasigma: The larger SigmaSigmaSigmaSigmasigma is chosen, the smaller the second derivative will be. This means that for larger smoothing correspondingly smaller values for HighHighHighHighhigh and LowLowLowLowlow should be chosen.

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

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


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.)


The magnitude of the second derivative

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


The line width to the left of the line


The line width to the right of the line

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


In general, but in particular if the line width is to be extracted, should be selected, where w is the width (half the diameter) of the lines in the image. As the lowest allowable value must be selected. If, for example, lines with a width of 4 pixels (diameter 8 pixels) are to be extracted, 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, 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


ImageImageImageImageimage (input_object)  (multichannel-)image objectHImageHImageHobject (byte / uint2)

Input image.

LinesLinesLinesLineslines (output_object)  xld_cont-array objectHXLDContHXLDContHobject *

Extracted lines.

SigmaSigmaSigmaSigmasigma (input_control)  number HTupleHTupleHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong)

Amount of Gaussian smoothing to be applied.

Default value: 1.5

Suggested values: 1, 1.2, 1.5, 1.8, 2, 2.5, 3, 4, 5

Typical range of values: 0.7 ≤ Sigma Sigma Sigma Sigma sigma ≤ 20

Recommended increment: 0.1

LowLowLowLowlow (input_control)  number HTupleHTupleHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong)

Lower threshold for the hysteresis threshold operation.

Default value: 3

Suggested values: 0, 0.5, 1, 2, 3, 4, 5, 8, 10

Typical range of values: 0 ≤ Low Low Low Low low

Recommended increment: 0.5

Restriction: Low >= 0

HighHighHighHighhigh (input_control)  number HTupleHTupleHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong)

Upper threshold for the hysteresis threshold operation.

Default value: 8

Suggested values: 0, 0.5, 1, 2, 3, 4, 5, 8, 10, 12, 15, 18, 20, 25

Typical range of values: 0 ≤ High High High High high

Recommended increment: 0.5

Restriction: High >= 0 && High >= Low

ExtractWidthExtractWidthExtractWidthExtractWidthextractWidth (input_control)  string HTupleHTupleHtuple (string) (string) (HString) (char*)

Should the line width be extracted?

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

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

CompleteJunctionsCompleteJunctionsCompleteJunctionsCompleteJunctionscompleteJunctions (input_control)  string HTupleHTupleHtuple (string) (string) (HString) (char*)

Should junctions be added where they cannot be extracted?

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

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


The amount of temporary memory required is dependent on the height H of the domain of ImageImageImageImageimage.


lines_colorlines_colorLinesColorLinesColorLinesColor 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>:)set_system("no_object_result",<Result>)SetSystem("no_object_result",<Result>)SetSystem("no_object_result",<Result>)SetSystem("no_object_result",<Result>). If necessary, an exception is raised.

Possible Successors



lines_gausslines_gaussLinesGaussLinesGaussLinesGauss, lines_facetlines_facetLinesFacetLinesFacetLinesFacet

See also

edges_coloredges_colorEdgesColorEdgesColorEdgesColor, edges_color_sub_pixedges_color_sub_pixEdgesColorSubPixEdgesColorSubPixEdgesColorSubPix


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.


2D Metrology