finds line segments in image and returns the coordinates of their endpoints.


uses the threshold t for selecting image lines.


uses the parameter d to control the distinctness of the detected lines.

Details and Options

  • ImageLines returns a list of line segments {p1,p2} where each pi={xi,yi} is expressed in the standard image coordinate system.
  • ImageLines[image,t] finds lines in the image whose normalized strength is larger than the specified threshold t.
  • ImageLines sorts the result based on the normalized strength.
  • In ImageLines[image,t,d], the parameter d controls how close lines are suppressed. If the value is set to zero, all detected lines are returned. With d set to 1, only the strongest line may be returned.
  • The following options can be given:
  • MaxFeaturesAllmaximum number of features to return
    Method"Hough"method to detect lines
  • With a setting MaxFeatures->n, at most n lines with largest normalized strength are returned.
  • Possible line detection methods are:
  • "Hough"lines based on Hough transform (default)
    "RANSAC"lines using the RANSAC algorithm
  • With Method->"Hough", lines are detected by iteratively selecting the strongest peaks in the Hough transform. Using the distinctness parameter, peaks that are within a rectangular range from the already selected peaks are excluded from the set of line candidates.
  • With Method->"RANSAC", lines are detected using random sampling. For each sampling, pixels that are within a distance specified by the distinctness parameter d are used for computing the strength of the line. The pixels on the selected line are not used in the following iterations.
  • By default, ImageLines returns lines that span from border to border. With a setting Method->{"Segmented"->True}, detected lines may be divided into smaller line segments.


open allclose all

Basic Examples  (2)

Detect and visualize straight trajectories in a bubble chamber image:

Click for copyable input

Detect the line going through the foreground pixels:

Click for copyable input

Scope  (2)

Options  (3)

Applications  (3)

Possible Issues  (2)

See Also

Radon  EdgeDetect  GradientFilter  ImageKeypoints  ImageCorners

Introduced in 2010
| Updated in 2014