LSD: A Fast Line Segment Detector with a False Detection Control

10
1 LSD: A Line Segment Detector Rafael Grompone von Gioi, J´ er´ emie Jakubowicz, Jean-Michel Morel, and Gregory Randall Abstract— We propose a linear-time line segment detector that gives accurate results, a controlled number of false detections, and requires no parameter tuning. This algorithm is tested and compared to state-of-the-art algorithms on a wide set of natural images. Index Terms— Line segment detection, NFA, Helmholtz prin- ciple, a contrario detection. I. I NTRODUCTION L INE segments give important information about the geo- metric content of images. First, because most human-made objects are made of flat surfaces; second, because many shapes accept an economic description in terms of straight lines. Line segments can be used as low-level features to extract information from images or can serve as a basic tool to analyze and detect more elaborated shapes. As features, they can help in several problems such as stereo analysis [10], crack detection in materials [13], image compression [9] and satellite image indexation [14]. Ideally one would like to have an algorithm that accurately detects the line segments present in an image, without false detection, and without the need to manually tune parameters for each image or group of images. To evaluate how far the line segment detector (LSD) presented in this paper goes in that direction, all experiments will be made with the same parameters regardless of the different image origin, scene and resolution. Line segment detection is an old and recurrent problem in computer vision. Standard methods first apply Canny’s detector [3] followed by a Hough transform [1] extracting all lines that contain a number of edge points exceeding a threshold. These lines are thereafter cut into line segments by using gap and length thresholds. The Hough transform method has serious drawbacks. First, because textured regions that have a high edge density can cause many false detections (see the slanted lines on the tree of Fig. 1). Ignoring the orientation of the edge points, such algorithms obtain line segments with aberrant direction. Second, because setting thresholds is a fundamental problem for all detection methods. Using fixed thresholds can lead to a significant number of false positives or false negatives (see Fig. 1). Another classic method, also starting from edge points, chains edge points into curves and cuts them into line segments by a straightness criterion [8]. A standard chaining method is due to Etemadi [7]. This method is parameterless and usually gives accurate results. Also, it is one of the few algorithms that simultaneously detect line segments and arcs 1 . Nevertheless, the result is not completely satisfactory, as illustrated in Fig. 1. Many detected straight and small edge curves are false positives: here comes again the fundamental threshold problem. Rafael Grompone von Gioi, J´ er´ emie Jakubowicz and Jean-Michel Morel are with CMLA, ENS Cachan, CNRS, UniverSud, 61 Avenue du Pr´ esident Wilson, F-94230 Cachan. Rafael Grompone von Gioi and Gregory Randall are with the IIE, Universidad de la Rep´ ublica, Uruguay. 1 The detected arcs are not shown on Fig. 1 Original image, 400 × 400 Canny edge points Hough transform method, 35s Etemadi’s method, 0.6s Burns et al. method, 0.7s Desolneux et al. method, 4m16s Multisegment detection, 10m56s LSD, 0.4s Fig. 1. A comparison of various line segment detection methods. The processing times on an Apple PowerBook G4 1.5 GHz are indicated. The Hough transform, the Etemadi and the Burns methods detect many irrelevant small line segments on the tree. Desolneux et al. controls the false detections but gives an inaccurate interpretation when aligned line segments are present. The multisegment detector gives a good result, but in prohibitive time. LSD gives a similar result in linear time.

Transcript of LSD: A Fast Line Segment Detector with a False Detection Control

1

LSD: A Line Segment DetectorRafael Grompone von Gioi, Jeremie Jakubowicz, Jean-Michel Morel, and Gregory Randall

Abstract— We propose a linear-time line segment detector thatgives accurate results, a controlled number of false detections,and requires no parameter tuning. This algorithm is tested andcompared to state-of-the-art algorithms on a wide set of naturalimages.

Index Terms— Line segment detection, NFA, Helmholtz prin-ciple, a contrario detection.

I. I NTRODUCTION

L INE segments give important information about the geo-metric content of images. First, because most human-made

objects are made of flat surfaces; second, because many shapesaccept an economic description in terms of straight lines. Linesegments can be used as low-level features to extract informationfrom images or can serve as a basic tool to analyze and detectmore elaborated shapes. As features, they can help in severalproblems such as stereo analysis [10], crack detection in materials[13], image compression [9] and satellite image indexation[14].

Ideally one would like to have an algorithm that accuratelydetects the line segments present in an image, without falsedetection, and without the need to manually tune parametersfor each image or group of images. To evaluate how far theline segment detector (LSD) presented in this paper goes in thatdirection, all experiments will be made with the same parametersregardless of the different image origin, scene and resolution.

Line segment detection is an old and recurrent problem incomputer vision. Standard methods first apply Canny’s detector[3] followed by a Hough transform [1] extracting all lines thatcontain a number of edge points exceeding a threshold. Theselines are thereafter cut into line segments by using gap and lengththresholds. The Hough transform method has serious drawbacks.First, because textured regions that have a high edge densitycan cause many false detections (see the slanted lines on thetree of Fig. 1). Ignoring the orientation of the edge points,such algorithms obtain line segments with aberrant direction.Second, because setting thresholds is a fundamental problemfor all detection methods. Using fixed thresholds can lead toasignificant number of false positives or false negatives (see Fig. 1).

Another classic method, also starting from edge points, chainsedge points into curves and cuts them into line segments bya straightness criterion [8]. A standard chaining method isdueto Etemadi [7]. This method is parameterless and usually givesaccurate results. Also, it is one of the few algorithms thatsimultaneously detect line segments and arcs1. Nevertheless, theresult is not completely satisfactory, as illustrated in Fig. 1. Manydetected straight and small edge curves are false positives: herecomes again the fundamental threshold problem.

Rafael Grompone von Gioi, Jeremie Jakubowicz and Jean-Michel Morelare with CMLA, ENS Cachan, CNRS, UniverSud, 61 Avenue du PresidentWilson, F-94230 Cachan. Rafael Grompone von Gioi and Gregory Randallare with the IIE, Universidad de la Republica, Uruguay.

1The detected arcs are not shown on Fig. 1

Original image,400 × 400 Canny edge points

Hough transform method, 35s Etemadi’s method, 0.6s

Burns et al. method, 0.7s Desolneux et al. method, 4m16s

Multisegment detection, 10m56s LSD, 0.4s

Fig. 1. A comparison of various line segment detection methods. Theprocessing times on an Apple PowerBook G4 1.5 GHz are indicated. TheHough transform, the Etemadi and the Burns methods detect many irrelevantsmall line segments on the tree. Desolneux et al. controls the false detectionsbut gives an inaccurate interpretation when aligned line segments are present.The multisegment detector gives a good result, but in prohibitive time. LSDgives a similar result in linear time.

2

Burns, Hanson and Riseman [2] introduced a linear-time linesegment detection method with a key new idea. Their algorithmdoes not start with edge points, and actually ignores gradientmagnitudes, using only gradient orientations. This algorithm wasimproved by Kahn, Kitchen and Riseman, [11], [12]. The linesegments given by this algorithm are well localized, but thethreshold problem is still there. The foliage of the tree in Fig. 1could be described as a texture, as an object, but certainly not as aset of line segments. The examination of these methods suggeststhat a selection criterion should be added as a final step.

The threshold question was thoroughly analyzed in Desolneux,Moisan and Morel [5]. Their line segment detection methodcontrols the number of false positives. The method counts thenumber of aligned points (points with gradient direction ap-proximately orthogonal to the line segment), and finds the linesegments as outliers in a non-structured,a contrario model. Thismethod is based on a general perception principle, the Helmholtzprinciple [6], according to which an observed geometric structureis perceptually meaningful when its expectation in noise islessthan 1. Applying the Helmholtz principle guarantees the lack offalse positives in the weak sense that, on average, only one falsedetection would be made in a white noise image of the samesize as the analyzed image. It also guarantees no false negative,if a line segment that could arise in noise is considered as atrue negative. The Desolneux et al. method has been extensivelytested and does find the lines in the image where alignmentsare present (no false negative). It has few false positives,asguaranteed by the method. Unfortunately, it often misinterpretsarrays of aligned line segments (see for example the windowsinFig. 1). A detailed analysis of this default was performed, and asatisfactory solution found, in [15], [17]. The solution involvesa more sophisticated use of the Helmholtz principle computingand comparing the meaningfulness of all possible arrays ofsegments (multisegments) on each line. The misinterpretationsof the Desolneux et al. method were corrected, giving an muchmore accurate line segment detector (see Fig. 1). Unfortunately,the Desolneux et al. and the multisegment detectors are exhaustivealgorithms. The Desolneux et al. method tests every possibleline segment in the image and has anO(N4) complexity, whereN is the image perimeter. The multisegment has anO(N5)

complexity. Thus, these detectors are doomed to be used on off-line applications only.

The aim of this paper is to present a linear-time algorithmthat cumulates most of the advantages of the previous algorithmswithout their drawbacks. The Burns et al. line segment finder, thatmade a breakthrough in the extraction of the line segments, will beimproved and combined with a validation criterion inspiredfromDesolneux et al. The result is a linear-time Line Segment Detector(LSD) that requires no parameter tuning and gives accurate results(see Fig. 1).

In Section II and III we present an improved version of theBurns et al. algorithm that provides the line segment candidates.Section IV describes the validation criterion. Section V gives aglobal picture of the algorithm and discusses its most importantproperties. Section VI discusses the experimental resultsandSection VII concludes the paper.

II. L INE-SUPPORTREGIONS

In contrast to classic edge detectors, the Burns et al. methoddefines a line segment as an image region, theline-support region,

namely straight regions whose points share roughly the sameimage gradient angle. Such line segments are roughly orientedalong the average gradient direction. The Burns et al. algorithmextracts line segments in three steps:

1) Partition the image intoline-support regions by groupingconnected pixels that share the same gradient angle up to acertain tolerance.

2) Find the line segment that best approximates each line-support region.

3) Validate or not each line segment based on the informationin the line-support region.

Considering that this method was a real breakthrough, the pro-posed algorithm shares the core ideas of steps 1 and 2, but differson the details. Step 3 is, however, completely different andbasedon the Desolneux et al.a contrario method. Our version of step 1is described in this section and steps 2 and 3 will be describedin the following two sections.

Fig. 2. Growing process of a region of aligned points. The level-lineorientation field (orthogonal to the gradient orientation field) is representedby dashes. Marked pixels are the ones forming the region. From left to right:first, second and third iterations, and final result.

Our version of step 1 is a region growing algorithm. Fig. 2illustrates the procedure. Each region starts with just onepixeland the region angle set to the level-line angle at that pixel(orthogonal to the gradient angle). Then, the pixels adjacent2 tothe region are tested; the ones with level-line orientationequal tothe region angle up to a certain precision3 are added to the region.At each iteration the region angle is updated to the mean level-lineorientation of the region’s pixels. The process is repeateduntil nonew point can be added. The pseudo-code Algorithm 1 gives moredetails. Seed pixels with larger gradient magnitude are tested first4

as they are more likely to belong to straight edges. When a pixelis added to a region it is marked and never visited again. Thiskey property makes the algorithm greedy and therefore linear.

Whenever a large and well contrasted straight edge is presentin the image, the algorithm will find the same line-support regionwhatever the starting point. In contrast, the result may depend onthe starting point when a non-straight curve is being approximatedby line segments (for example when a circle is present in theimage). In this case the obtained decomposition of a circle intoline segments would be as good as any other. The fact thatconnected regions with common orientation would almost alwayscoincide with straight edges is a surprising empirical discoverydue to Burns et al. We mentioned the case of curves as a harmlessfirst counterexample. Since the antiquity, smooth curves have beenhandled as concatenations of (small) straight segments.

2We use 8-connected pixel neighborhood.3We use a 22.5 degree tolerance. The relevance of this parameter and how

to set it will be commented in Section V.4Sorting algorithms have a typicalO(N log N) complexity. Ordering the

pixels by strict gradient magnitude value would be computationally tooexpensive. Instead, a pseudo-ordering is done: pixels are classified into afinite number of bins according to their gradient magnitude value; then thepixels from higher bins are visited first and pixels in the lower bins later.

3

Algorithm 1 : REGIONGROW

input : An image I; a starting pixel(x, y); an angletoleranceτ ; an imageStatus where pixels used byother regions are marked.

output: A list Region of pixels.

Region← (x, y);1

θregion ← LevelLineAngle(x, y);2

Sx ← cos(θregion);3

Sy ← sin(θregion);4

foreach pixel P in Region do5

foreach P neighbor of P and Status(P ) 6= Used do6

if Diff( LevelLineAngle(P ), θregion ) < τ then7

Add P to Region;8

Status(P )← Used;9

Sx ← Sx + cos(LevelLineAngle(P ));10

Sy ← Sy + sin(LevelLineAngle(P ));11

θregion ← arctan(Sy/Sx);12

end13

end14

end15

III. R ECTANGULAR APPROXIMATION OFREGIONS

Prior to the validation step, the line-support region (a setof pixels) must be associated with a line segment (actually,arectangle). A line segment is determined by its endpoints andits width; or equivalently, its center, angle, length and width. Itsrectangular approximation as shown in Fig. 3 includes all oftheseparameters.

Center

Rectangle’s Angle

Width

Direction

Length

Fig. 3. Line segments are characterized by a rectangle determined by itscenter point, angle, length and width.

The first idea that comes to mind is to use the mean level-line angle as the main direction for the line segment. Thisprocedure can lead to an erroneous line angle estimation when thebackground shows a slow intensity variation, see [16]. In LSD (theidea was first proposed by Kahn et al. in [11], [12]) the centerof mass is used to select the center of the rectangle, and thefirst inertia axis to select the rectangle orientation. The gradientmagnitude is used as the pixel’s mass. Points with large gradientnorm correspond better to the observed edges. Then, the lengthand the width are chosen in such a way as to cover the line-support region. Fig. 4 shows an example of the result.

Fig. 4. Example of a rectangular approximation of a line-support region.Left: Image. Middle: One of the line-support regions. Right: Rectangularapproximation superposed to the line-support region.

IV. L INE SEGMENT VALIDATION

The two key points of the Desolneux et al. [5] approach arethe use of gradient orientation and a new framework to dealwith parameter setting. Their method is illustrated in Fig.5. Thegradient of the input image is computed and only the level-line orientation is kept. In Fig. 5 this information is codifiedby angle of the dashes. Given a line segment, the number ofaligned points, i.e., points having the level-line orientation equalto the line segment angle, is counted up to a certain tolerance τ .All potential line segments on the image must be tested; thosethat satisfy a threshold criterion based on their lengthl and theirnumber of aligned pointsk are kept as valid detections.

τ

4 ali

gned

poin

ts

Fig. 5. Left: One line segment shown over the level-line orientation field(orthogonal to the gradient orientation field). Right: The number of alignedpoints up to an angular toleranceτ is counted for each line segment. The linesegment shown has4 aligned points among7.

On natural images the gray-level transition correspondingtoedges can be many pixels thick. This happens, for example, withthe straight boundary of an out of focus object. In that case,theDesolneux et al. algorithm gives many parallel detections andit’s a lot of effort to go back to a correct interpretation [6]. Todeal with this problem,rectangles (line segments with a certainwidth) will be used instead of line segments. Fig. 6 illustrates theconcept.

In the Desolneux et al.a contrario approach, detection istreated as a simplified hypothesis testing problem. Indeed,inthe classic decision framework, two probabilistic models arerequired: one for the background and one for the objects to bedetected. In thea contrario approach, the objects are directlydetected as outliers to the background model. In addition, thebackground model is reduced to the simplest of all, namely whitenoise. As Desolneux et al. showed, a suitable background modelis just one in which all gradient angles are independent anduniformly distributed. They showed that this is the case foraGaussian white noise image. More formally, an imageX under

4

Fig. 6. One rectangle shown over the level-line orientationfield (orthogonalto the gradient orientation field). The rectangle has 9 aligned points out of20.

the background modelH0 is a random image (defined on the gridΓ = [1, N ]× [1, M ] ⊂ Z

2) such that:

1) ∀m ∈ Γ, Angle(∇X(m)) is uniformly distributed over[0, 2π];

2) The family{Angle(∇X(m))}m∈Γ is composed of indepen-dent random variables.

This is indeed a good model for flat zones of images whichusually present, due to the acquisition process, a white noisedistribution. But more important, this model represents wellisotropic zones, while straight edges are exactly the opposite:highly anisotropic zones. Thus in practice a set of pixels willnot be accepted as a line segment if it could have been formedby an isotropic process. A good example is shown on Fig. 1. Thefoliage of the tree is far from being a white noise process, butit is an isotropic structure; as a consequence, no line segment isdetected there.

There are as many statistical testsTr to be performed aspotential rectanglesr in the image. In anN × N image, thereareN4 potential oriented line segments, starting and ending on apoint of the gridΓ. If we acceptN (to give an order of magnitude)possible width values for the rectangle, this number goes uptoN5 potential tests.

Each test relies on the statisticsk(r, x) which is the number ofaligned points in the rectangler and imagex. The detection stepis as follows: RejectH0 if k(r, x) ≥ kr, acceptH0 otherwise.For this test, non-H0 will also be denoted byHr, i.e., rectangledetection. Thus, we are led to the question of fixing a thresholdkr for each rectangler. Following Desolneux et al.,kr must befixed in a way that guarantees a control of the expected numberof false alarms underH0. We define the Number of False Alarmsof a rectangler ∈ R and an imagex, as

NFA(r, x) = #R · PH0[k(r, X) ≥ k(r, x)],

where x is the observed image,X is a random image underH0 and #R is the number of potential rectangles in the image,the number estimated before. The smallerNFA(r), the moremeaningfulr is, i.e., the less likely it is to appear in an imagedrawn under theH0 model. RejectingH0 if and only if NFA(r) ≤

ε gives what we callε-meaningful rectangles.The method is justified by the following proposition:

PropositionEH0

X

r∈R

1NFA(r,X)≤ε ≤ ε.

In other terms, the expected number of detections under the back-ground model is less thanε. Thus, in agreement with Helmholtzprinciple, only very few detections (ε) could have arisen just bychance.

Computations can be done explicitly. If the angle toleranceτ

is set toτ = πp, the probability (underH0) that a given pointhas its level-line aligned with a rectangle isp. Since the gradientis independent at different image points underH0, k(r) followsa binomial law with parametersn(r) and p, wheren(r) is thetotal number of points in the rectangle. Using the number of testsestimated before we can write

NFA(r) = N5 · b`

n(r), k(r), p´

,

whereb(n, k, p) =Pn

i=k

`ni

´

pi(1−p)n−i stands for the binomialtail.

The dependence of the method onε is very weak (actuallylogarithmic), see [5]. In practice, as advised by Desolneuxet al.,one can fixε = 1 once for all. This corresponds to accept,on average, one false positive detection per image on the non-structured model. It also guarantees that all discarded segmentare indeed likely to appear in noise (no false negatives in thatsense).

V. THE COMPLETELSD ALGORITHM

A. Details of the algorithm

Algorithm 2 shows a pseudo code for the complete algorithm.The subroutineGrad computes the image gradient and givesthree outputs: the level-line angles, the gradient magnitude, andan ordered list of pixels. The parameterρ is a threshold: pointswith gradient magnitude smaller thatρ are not considered. Thisparameter will be discussed later in section V-B. To construct thelist, the pixels are classified into bins according to their gradientmagnitude; the list starts with the pixels belonging to the bin withhigh gradient and ends with the pixels belonging to the bin withlow gradient. The list is roughly ordered in decreasing gradientmagnitude order.

Algorithm 2 : LSD: LINE SEGMENT DETECTOR

input : An image I, parametersρ, τ and ε.output: A list out of rectangles.

( LLAngles, GradMod, OrderedListPixels)← Grad(I, ρ);1

Status(allpixels)← NotUsed;2

foreach pixel P in OrderedListPixels do3

if Status(P ) = NotUsed then4

region← RegionGrow(P, τ, Status);5

rect← RectApprox(region);6

nfa← NFA(rect);7

nfa← ImproveRect(rect);8

if nfa < ε then9

Add rect to out;10

Status(region)← Used;11

else12

Status(region)← NotIni;13

end14

end15

end16

The list of pixels is used to give a priority to pixels as seedsin the search of line-support regions. The first pixels in thelistare the ones with higher gradient magnitude, because they aremore likely to belong to edges. Starting from this pixel, thealgorithm described in Section II,RegionGrow, is used to obtain

5

a line-support region. Then, the algorithm described in Section III,RectApprox, gives a rectangle approximation of the region andthe method described in Section IV computes the line segment’sNFA.

In our context, the best rectangular approximation of a line-support region is the one that gives the smallerNFA value.The routineImproveRect tries several perturbations to the initialapproximation in order to get a better approximation. This step isnot significant for large and well contrasted line segments,but itextends the detection limit for small and noisy ones. The testedperturbations are variations in width and lateral position. Thejustification is that the width of the line segments is the worstestimated parameter on the first rectangular approximation, butalso a very influential one; an error that makes the rectangleonepixel thicker adds a large number of non-aligned points, as manyas the length of the line segment. This can increase theNFA

value, rising the non-detection risk.The first computation of theNFA value is done using the

probability p (that one point is aligned by chance) equal top = τ

π , where τ is the tolerance used to get the line-supportregion. But the observed level-line angles could be much moreprecise, resulting in a betterNFA value. Starting fromp = τ

π ,ImproveRect also tries dyadic precision levels, covering thepractical range ofp values5. With a finer precision some pointsmay stop from being aligned, sok(r) may diminish; the balancebetween a smallerp and a smallerk(r) can increase or decrase theNFA value depending on the case. The best one is kept. Noticethat this loop eliminatesp as a method parameter.

Status is used to keep track of pixels used or tested by line-support regions, as explained in Section II. However, a thirdpossible state is added:NotIni , which is assigned to pixels ina line-support region that did not qualified as a detection. Thiswill prevent them from being used as seed points for new regionsbut will allow to use them if a neighbor region grows into them.In some cases this helps improving the search, see [16].

B. Internal parameters

There are three parameters involved in LSD:ρ, τ and ε.ρ is a threshold on the gradient magnitude: pixels with small

gradient are not considered. The reason is to cope with thequantization of the image intensity values. Desolneux et al.showed in [4] that gray level quantification produces errorsinthe gradient orientation angle. This error is negligible whengradient magnitude is large, but can be dominant for a smallgradient magnitude. It can create patterns and therefore spuriousdetections. A side effect of the thresholdρ is a speed improvementby reducing the number of considered pixels.

The criterion we use to setρ is to leave out points where theangle error is larger than the angle tolerance. Letu denote theimage andu the quantized one. Thenu = u + n and

∇u = ∇u +∇n,

wheren is the quantization noise. In [4] is shown that the errorof the image gradient angle can be bound by

|angle error| ≤ arcsin

q

|∇u|

«

,

5Five dyadic precision steps are considered before adjusting the rectanglewidth, and again, five dyadic precision steps afterwards. Thus, precisions fromp = 1

8to p = 1

8192are tested. In practice, a precision withp ≤ 1

256is rarely

obtained.

where q is a bound to |∇n|, see Fig. 7. Imposing that|angle error| ≤ τ one obtains

ρ =q

sin τ.

For example, on images quantized to gray values in0, 1, 2, . . . , 255, |∇n| can be bounded byq = 2 (the worst case iswhen adjacent points gets errors of +1 and -1). Ifτ is set to 22.5degree (which corresponds to 8 different angle bins) the thresholdto the gradient angle isρ = 5.2.

angle error

∇u

∇n

Fig. 7. Relation between image noise and gradient angle error.

τ is the angle tolerance used in the search for line-supportregions. A small value is more restrictive, leading to an over-partition of line segments. A large value results in large regionsand in the merging of unrelated ones. When a well contrastedand large enough line segment is present in the image, the line-support region obtained depends little on this parameter (and therectangle approximation even less, as a result of the use of thegradient magnitude weighting). In critical size regions orwhenmuch noise is present this parameter is more important.

Burns et al. proposed in [2] to use a 22.5 degree angle,that corresponds to eight different angle bins. Independently, wearrived at the same value as the one that gives the best results.There is no theory behind this parameter value, but it is supportedby the results on thousands of images.

Note thatτ is also used to set the first angle tolerance used inthe NFA computation. All the practical range of values ofp arealso tested. As a result,τ has no influence in the validation stepnor in the theoretic definition of line segments.

Finally, as already stated in Section IV, the detection parameterε is not a critical one; one can safely set its value to 1 once forall. This means that on average one casual detection per image isacceptable.

All in all, LSD can be used without parameter tuning, and allof the above parameters considered internal parameters. This factis supported by tests on thousands of images of very differentkinds and origins.

C. Complexity of the algorithm

The computation of the gradient magnitude and angle is pro-portional to the number of pixels. Pixels are pseudo-ordered bya classification into bins, operation that can be done in lineartime. The computational time of the line-support region findingalgorithm is proportional to the number of visited pixels. If therewere no overlap between regions, this number would be equal tothe total number of pixels in the regions plus the border pixels ofeach one. TheNotIni condition allows for some overlap betweenregions. This overlap is equivalent to having thicker frontiersbetween regions. Thus, the number of visited pixels remainsproportional to the total number of pixels of the image. The restof the processing can be divided into two kind of tasks. Thefirst kind, e.g., summing the region mass or counting aligned

6

points, are proportional to the total number of pixels involvedin all regions. The second kind, e.g., computing inertia momentsor computing theNFA value from the number of aligned points,are proportional to the number of regions. Both the total numberof pixels involved and the number of regions are at most equalto the number of pixels. All in all, LSD has an execution timeproportional to the number of pixels in the image.

VI. EXPERIMENTS

The processing time for a512×512 image is a fraction of a sec-ond. This permitted to test the algorithm on thousands of images,images of different kinds, origins, sizes, and noise levels; sometests were also performed on videos. It should be emphasizedthatall the experiments were done without tuning any parameter at all.See [16] for a deeper analysis of the experiments. More results,including some videos and a demo version of the algorithm canbe found athttp://iie.fing.edu.uy/∼jirafa/lsd. Theresults shown in this paper were obtained on some of the mostchallenging images.

0

20

40

60

80

100

0 5e+06 1e+07 1.5e+07 2e+07 2.5e+07

Com

puta

tion

Tim

e (s

)

Number of Pixels

Fig. 8. Computation time (in seconds) required by LSD for theprocessingof 1297 images as a function of the image size (total number ofpixels).The computations were done with LSD implemented on Megawave2 version2.31a, running on an Apple PowerBook G4 1.5 GHz. The slanted linearseries corresponds to Gaussian white noise images. The vertical linear seriescorresponds to images of size3072 × 2304, a popular camera resolutiontoday.

Fig. 8 shows a plot of the computational time in seconds vs.the image size on an Apple PowerBook G4 1.5 GHz. For mostimages the computation time is shorter than for a white noiseimage of the same size (the slanted linear series of points onthe plot). The main reason is that in natural images many pixelsare discarded by the gradient threshold. Some images, however,require longer processing time than white noise images, as can beseen on the plot. It is usually the case in images with noise-likestructures (as a grass background) and long range structures (asobjects on the foreground).

Fig. 9 shows a series of experiments on natural images. Notethat the detected line segments represent well the structure ofthese diverse images. The images on the left hand columncontain highly geometrical contents. Almost all the expectedline segments were found, the perceptual exceptions being smallones that lay beyond the meaningfulness limit. In accordancewith the theory there are very few false detections. The imageson the right hand column show results on some non-geometricimages. Most detections in this second group of images do notcorrespond to real straight or flat objects; they correspondto

locally straight edges. In cases like the profile of an arm, a linesegment interpretation is not strictly correct in the sensethat anarm is not straight, but it is a reasonable interpretation interms ofthe 2D structure present on the image at a given resolution. Forcurved edges, like the one in the wheel on the middle-right image,the line segment interpretation is only an economic approximationto a curve. Such results are acceptable in the sense that everydetection corresponds to a locally straight structure in the imageand every locally straight structure has a line segment associated.

The presence of noise can deteriorate the performance ofLSD. Helmholtz principle states that no detection should bemade on white noise images. As a result, when noises withincreasing variance are added, theNFA value of meaningful linesegments increases. Eventually, noise dominates the image, theNFA becomes larger than1, and the line segment is no moredetected. See [16] for more details.

Noise affects the region growing algorithm too and this effectis critical for LSD. Noise produces variations to the level-lineangles. Low power noise produces negligible variations andthe result are not be affected. With moderate noise power, thevariations to the level-line angles become larger and the angledifference can reach the angle tolerance valueτ . Then the regiongrowing algorithm is no more able to follow the edge and the line-support regions become fragmented. Thus, with more noise, onlysmall line-support regions are formed and no detection is made.Fig. 10 top, shows an example of a synthetic noisy image; onlya small fraction of the edge was detected by LSD. Nevertheless,no false detections were made, in striking contrast to stateof theart methods that have no false detection control, see Fig. 10. Thesame effect happens on real images, see Fig. 11.

A critic can be raised to the theory: almost no line segment isdetected on the images of Fig. 10 and Fig. 11 at full resolution,even if they are perfectly visible for us. The answer is thatthe human visual system uses a multiscale analysis. For a faircomparison a multiscale analysis must be authorized to the linesegment detection theory too. (The Hough transform method andEtemadi’s method include such a step, since they rely on Cannypoints, whose processing implies Gaussian filtering.) Fig.10bottom and Fig. 11 middle and bottom show that the line segmentsmasked by noise can be detected by the very same algorithmat coarser scales. Multiscale analysis also helps detecting globalstructures masked at full-scale by details of the image. See[16].

Fig. 12 shows a comparison of six line segment detectionalgorithms on a natural image. The computation time on anApple PowerBook G4 1.5 GHz is shown for all of them, aswell as the number of line segments found. As shown before, theHough transform method often produces false detections, manyunrelated with edges orientations, like the horizontal ones on thehair of the man. The Etemadi’s and Burns et al. methods have thethreshold problem: A decision rule is needed to select the goodline segments, otherwise the detection is useless (1517 and3677line segment detected, respectively). Desolneux et al. producesno false detection but fails to get the right interpretationwhenaligned line segments are present, as in the balustrade at thebackground of Fig. 12. Also, when slow gradients are present, asin the shadow of the table at the left of the image, this producesmultiple parallel detections instead of one wider line segment.Multisegment detection produces good results (even if the paralleldetections problem is still present and in some cases hallucinatesglobal aligned structures not present, see [16]). Its computation

7

Fig. 9. Result of LSD on natural images.

Original image,256 × 256 LSD Hough transform method Etemadi’s method Burns et al. method

Fig. 10. Analysis of a noisy edge image at two different scales by four line segment detection algorithms. When a lot of noise is present (here Gaussiannoise with σ = 50), LSD will not detect some of the line segments that we can see; it will not produce false detections either. The methods without afalse detection control produce many false detections, making the result useless. Hough transform method and Etemadi’s method did, indeed, detect the edgeat full resolution. This is because the detection relies on Canny edge points, that involve a Gaussian filtering. The way to cope with noise is a multiscaleanalysis with Gaussian filtering. When LSD processes the half resolution image (second row) it succeeds in detecting theedge; the Hough transform method,Etemadi’s method and the Burns et al. method still produce false detections.

8

Original image,972 × 800 LSD Hough transform method Etemadi’s method Burns et al. method

Fig. 11. The same effect shown in Fig. 10 can be seen on a real noisy image. The three rows correspond to the analysis at full scale, 1/2 resolution and 1/4resolution by Gaussian filtering. At full resolution, LSD fails to detect the structure of the image, but produces no false detection. Algorithms without a falsedetection control, like the Hough transform method, Etemadi’s method and Burns et al. method produce useless results. The structure of the image can’t beobtained at full resolution when noise dominates. A multiscale approach is needed (as probably used in human vision). Most of the structure is detected byLSD at half resolution. Note that the Hough transform methodand Etemadi’s method detect part of the structure of the image at full resolution; the reasonis that both approaches use Canny points, that involve a Gaussian filtering.

time is prohibitive, though. LSD produces a good description ofthe image structure with 716 line segments in 0.7 seconds.

The results of the multisegment detector and LSD are similarin most cases. Let us comment briefly on the main differences.The multisegment detector processes every line that crosses animage, producing a global interpretation for each one of them.This process leads occasionally to the hallucination of a globalstructure that is not present in the image. Fig. 1 shows anexample: the small line segments in the foliage that are horizontalor vertical, and aligned with some true alignment present onthe image are kept. This obviously casual alignment reinforcesthe meaningfulness of the line. In consequence the small linesegments, non meaningful by themselves, are interpreted aspartsof a larger multisegment. Being much more local, LSD do notpresent this problem. But the global analysis of the multisegmentdetector is needed, however, to grasp the right interpretation onother cases, as Fig. 13 shows. In this image LSD cannot detectsmall line segments that are too short, while the multisegmentalgorithm succeeds in reconstructing the global structure.

Image,140 × 140 pixels. LSD Multisegment detection

Fig. 13. A case where the multisegment detector gives a better result thanLSD. Some line segment are too small to be meaningful for LSD.Thismeans that their line support could have arisen in noise. Theglobal analysisperformed on each line allows the multisegment detector to obtain the rightline interpretation.

VII. C ONCLUSIONS

An examination of the experimental results (and of other manythat the reader may wish to perform on line) indicate that aline segment detection can be accurate and have a small amountof false positive and false negative detections. This excellentresult can be primarily attributed to Burns et al., who procuredthe right edge representation as a region of aligned orientationpixels, and to Desolneux et al., who proposed a general methodto eliminate false positives. The results substantiate theidea that areliable raw primal sketch is doable in digital images. However,experiments also show that the story is not complete, but juststarting. A circular plate is detected as a concatenation ofstraightline segments. This representation must lead to the notion ofthe curve. A more accurate representation should distinguish realpolygons from curves. It should also permit to build up moreelaborate gestalts such as bars, regular polygons, periodic gridsor stripes, to name a few ones that are visible in the test imagespresented in this paper.

ACKNOWLEDGMENTS

The authors are indebted to their collaborators for many re-marks and corrections, and more particularly to Andres Almansa,Gabriele Facciolo, and Enric Meinhardt-Llopis. They also wish tothank J. Ross Beveridge for providing the software for the Burnset al. algorithm. The research was partially financed by the ALFAproject CVFA II-0366-FA, the Centre National d’Etudes Spatiales,the Office of Naval research under grant N00014-97-1-0839.

REFERENCES

[1] D.H. Ballard. Generalizing the hough transform to detect arbitraryshapes.PR, 13(2):111–122, 1981.

9

Original image,600 × 450 Canny edge points, 26932 pixels

Hough transform method, 37s, 848 line segments Etemadi’s method, 1.2s, 1517 line segments

Burns et al. method, 0.6s, 3677 line segments Desolneux et al. method, 2m40s, 279 line segments

Multisegment detection, 17m17s, 904 line segments LSD, 0.7s, 716 line segments

Fig. 12. A comparison of various line segment detection methods. The processing times on an Apple PowerBook G4 1.5 GHz areindicated. Etemadi’smethod detects line segments and arcs at the same time; here only line segments are shown. Hough and Etemadi have many wrong detections. Burns et al. isaccurate but has an overwhelming number of false detections. Deolneux et al. has no false detection but is too global. Multisegments and LSD give similarresults in very dissimilar times.

10

[2] J. Brian Burns, Allen R. Hanson, and Edward M. Riseman. Extractingstraight lines.IEEE Trans. PAMI, 8(4):425–455, 1986.

[3] J. Canny. A computational approach to edge detection.IEEE Trans.Pattern Anal. Mach. Intell., 8(6):679–698, 1986.

[4] A. Desolneux, S. Ladjal, L. Moisan, and J.M. Morel. Dequantizing im-age orientation.IEEE Transactions on Image Processing, 11(10):1129–1140, 2002.

[5] A. Desolneux, L. Moisan, and J.M. Morel. Meaningful alignments.International Journal of Computer Vision, 40(1):7–23, 2000.

[6] A. Desolneux, L. Moisan, and J.M. Morel.From Gestalt Theory to ImageAnalysis, a Probabilistic Approach, volume 34 of InterdisciplinaryApplied Mathematics. Springer, 2008.

[7] A. Etemadi. Robust segmentation of edge data.Int. Conf. on ImageProcessing and its Applications, pages 311–314, 1992.

[8] O. Faugeras, R. Deriche, H. Mathieu, N.J. Ayache, and G. Randall. Thedepth and motion analysis machine.PRAI, 6:353–385, 1992.

[9] P. Franti, E.I. Ageenko, H. Kalviainen, and S. Kukkonen. Compressionof line drawing images using hough transform for exploitingglobaldependencies. InJCIS 1998, 1998.

[10] C.X. Ji and Z.P. Zhang. Stereo match based on linear feature. InICPR88,pages 875–878, 1988.

[11] P. Kahn, L. Kitchen, and E. M. Riseman. Real-time feature extraction:A fast line finder for vision-guided robot navigation. Technical Report87-57, COINS, 1987.

[12] P. Kahn, L. Kitchen, and E. M. Riseman. A fast line finder for vision-guided robot navigation. IEEE Trans. Pattern Anal. Mach. Intell.,12(11):1098–1102, 1990.

[13] S. Mahadevan and D.P. Casasent. Detection of triple junction parametersin microscope images. InSPIE, pages 204–214, 2001.

[14] R. Grompone von Gioi and J. Jakubowicz. Geometry-basedunsuper-vised urban-area detection.In preparation, 2007.

[15] R. Grompone von Gioi, J. Jakubowicz, J.M. Morel, and G. Randall. Onstraight line segment detection.Submited to JMIV, 2007.

[16] R. Grompone von Gioi, J. Jakubowicz, J.M. Morel, and G. Randall.Lsd: A line segment detector. Technical report, CMLA, ENS-CACHAN,2008.

[17] R. Grompone von Gioi, J. Jakubowicz, and G. Randall. Multisegmentdetection.ICIP, 2007.