an edge image, nd line or curve segments present Given the image. in Line and Curves Detection 1
Issues with Curve Detection Grouping (e.g., the Canny hysteresis thresholding procedure) Model tting They can be performed sequentially or simultaneously. 2
The Hough Transform The Hough Transform (HT) is a popular technique detecting straight lines and curves on gray-scale for images. It maps image data from image space to a parameter where curve detection becomes peak detection space, problem. 3
pair (a b) represents a line. For example parameter represents a horizontal line. This line (0,4) The HT for Line detection 1. Parameterize the line y = ax + b In the parameter spaces determined by a and b, each representation can not represent a vertical line. 4
we can also parameterize a line in Alternatively, coordinates as polar x cos + y sin ; =0 5
θ X ρ y=ax+b xcos θ + ysin θ = ρ Y 6
( ) represents a line. For example, avertical line of be represented as (0 4). my ρ (θ, ρ) θ In parameter space determined by and, each pair 7
lines that satisfy x 0 cos + y 0 sin ; =0,each of all can be represent by a pair of ( ). In the which space, the image point is represented by a parameter curve sinusoid An image point (x 0 y 0 ) represents the intersection of 15 10 5 rho 0 5 10 15 0 50 100 150 200 250 300 350 400 theta 8
intersection of two sinusoid curves representing The line going through two image points (e.g., (10,10) the lines are parameterized using a and b, then an If point is represented by as a line in the image (20,20)) uniquely determines a line. and X (10,10) 30 25 20 x1=(10,10) x2=(20,20) 15 (20, 20) rho 10 5 0 5 10 Y 15 20 0 20 40 60 80 100 120 140 160 180 theta parameter space (g. 5.1). 9
to quantize the parameter space. By necessary the parameter space is divided into quantization, grid of cells, the dimensions of each cell are nite by the quantization intervals. Each cell is determined 2. Quantize parameters and To keep the parameter space nite, it is often indexed by a pair of quantized ( ). 10
accumulator array is used to accrue the The of each image point to a quantized contribution example, if we have N image points lying on a For with parameter pair ( 0 0 ), then we have line 3. Build an accumulator array A( ) ( ). The standard HT scheme for updating the accumulator array A( ) is A( ) =#f(x y) 2 X Y jx cos + y sin + =0g where X Y are the image domain. A( 0 0 )=N and the accumulator array values for all other parameter pairs are 1. For each quantized, we use the line equation to 11
quantized. The accumulator corresponding to then quantized and are then incremented by 1. the compute the corresponding. The computed is 12
A( ). To detect multiple lines, look for all local of of A( ). maxima 4. Search A( ) for peaks The image lines are therefore detected by the peaks 13
Identify the ranges for and. Let the range for for 2. be between l and h, and the range for between Discrete the parameter space of and using 4. steps and. Let d and d be 1D arrays sampling HT Algorithm Outline For an input gray scale image I of M N. 1. Locate the HT coordinate system l and h. Choose quantization intervals and for and 3. respectively. containing the discretized and. 14
For each image pixel (c r), if its gradient magnitude 7. r) >, where is a gradient magnitude g(c 5. Let A(T, R) be an array of integer counter initialize elements of A to zero, where R = h; l all and = h; l. T 6. Let L(T,R) be an array of a list of 2D coordinates. threshold. i=1 to T for = c cos( d (i)) + r sin( d (i)) nd the index k, for the element of d closest to increment A(i,k) by one. 15
Find all local A(i p k p ) such that A(i p k p ) >t, where 8. is a threshold. t points in L(i p k p ), describing the lines detected in of image, along with points located on these lines the Add point (c,r) to L(i,k) 9. The output is a set of pairs ( d (i p ) d (k p )) and lists 16
0 << p M 2 + N 2 -M << p M 2 + N 2 HT Coordinate Systems The HT coordinate system coincides with the row-column coordinate system. Ranges of and ;90 <<180 or 0 <<180 The HT coordinate system locates at the center of the image 17
p M 2 +N 2 p M 2 +N 2 p M 2 +N 2 Ranges of and 2 0 << 0 <<360 or ; 2 2 << 0 <<180 18
An Example 19
be used to restrict the range of values of that the can point may vote for. Instead of checking for all image for those lines whose orientations are close accumulators the gradient direction of the image point, therefore to Incorporating Gradient Direction If gradient direction at each image point is available, it possible s as in the standard HT, we only increase the signicantly reducing the required computations. 20
1 0.8 0.6 P(Θ Θ) 0.4 0.2 θ, ρ 0 80 60 40 20 ρ 0 20 40 40 20 0 θ 20 40 60 80 21
contribution of each point to the accumulator array the be determined based on the gradient magnitude of can Incorporating Gradient Magnitude Instead of updating the accumulator array by an unit, the point. 22
HT can be generalized to detect any parameterizable The such as circles and ellipse. For example for circle curves (x ; x 0 ) 2 +(y ; y 0 ) 2 = R 2 the parameters are (x 0 y 0 ), and R. We can where construct a 3D accumulator A(x 0 y 0 R). For therefore edge point vary (x 0 y 0 ), compute the corresponding each using the circle equation, and then update A. In the R HT for Curves detection, a circle can be parameterized as end, search A for peaks. 23
we know the gradient direction of each point, we may If a dierent parameterizable representation for circle use x = R cos + x 0 y = R sin + y 0 represents the gradient direction of point (x y). where can then reduce search from 2D to 1D. We can vary We updating the corresponding accumulator then accordingly. to take advantage of the gradient direction R and then use the above equation to compute x 0 and y 0, 24
Another HT Technique for Circle Detection Detect circle center rst Determine circle radius Y cos θ sin θ θ X For the parametric circle equation, we have the tangent 25
y ; y 0 x ; x 0 x ; x 0 equation does not contain circle radius R, therefore This to nd circle centers rst. allowing of the circle at (x y) is dx = ; tan dy From circle equation (x ; x 0 ) 2 +(y ; y 0 ) 2 = R 2, we have dx = ; y ; y 0 dy Equating the above two equations yields =tan where represents the gradient direction at (x y). 26
Another HT Technique for Circle Detection Given (x 0 y 0 ), we can then use equation ; x 0 ) 2 +(y ; y 0 ) 2 = R 2 to determine Rs for each (x 0 y 0 ). Note dierent Rs may be identied for each (x (x 0 y 0 ), indicating concentric circles. 27
HT for Ellipse Detection Let an ellipse equation be (x ; x 0 ) 2 a 2 + (y ; y 0) 2 b 2 =1 28
for Ellipse Detection (cont'd) HT Y (x,y) b τ (x 0,y ) 0 θ X a x = x 0 + a cos y = y 0 + b sin 29
HT for Ellipse Detection (cont'd) From the tangent denition, dx = ; tan dy From the parametric ellipse equation, we have dx = ;a b tan dy As a result, we have tan = b a tan Substituting the above equation to the parametric ellipse 30
a b2 q1+ b a2 q1+ equation yields the parametric representation of an ellipse using x = x 0 a 2 tan 2 y = y 0 b 2 tan 2 This still, however, involves 4 parameters. 31
We also know tan = b a y ; y 0 x ; x 0 x ; x 0 the above equation, we can treat b2 a 2 In eectively reducing to three dimensions. We unknown, therefore construct an accumulator array involving can 0, y 0, and b2 a 2. x HT for Ellipse Detection (cont'd) From the previous equations, we have = b a tan tan As a result, we have y ; y 0 b2 = 2 tan a as a single 32
X 0 ; Y 0 represent the coordinate system where the Let and minor axes align with X 0 and Y 0 respectively major Detection of Ellipse with an Unknown Orientation as shown in the gure. Y Y (x,y) X τ θ α β X 33
0 x B@ y 1 = CA 0 x 0 B@ y 0 1 + CA 0 cos B@ tan = b a 10 B@ a cos CA is the gradient direction of point (x y) in X-Y where frame. coordinate 1 CA sin b sin ; sin cos From the previous discussion, we have tan = b a tan Since = ;, we therefore have tan( ; ) 34
a nominal ellipse, with =. Again, we reduce the for of parameter array from 5 to 4. dimension Detection of Ellipse with an Unknown Orientation From the above equation, we have ; 0 ) sin +(y ; y 0 )cos (x b2 x x 0 ) cos ; (y ; y 0 ) sin = ; (x a 2 tan( ; ) When = 0,the above equation reduces to the equation 35
method is to scan the image horizontally and One any possible edge points on each row. For each identify idea is that if the two points happen to be on an The then their centroid must be on the vertical center ellipse, center line. Similarly, if scan vertically, the vertical centerline can be detected. The ellipse center horizontal the intersection of the vertical and horizontal center is Given the center of the ellipse, other parameters lines. Other Ecient Ellipse Detection using HT row, identify the centroid of any two selected edge points. line of the ellipse. So, by voting, we may detect the are then determined. 36
transform can be generalized to detect any shapes, HT for those without analytic (parametric) even Generalized HT representation. 37
and quantization errors may introduce noise peaks spurious HT Summary Advantages: Robust to image noise and occlusion Can detect multiple curves Disadvantages computational intense standard HT only detects line not line segments 38