Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Edges and Lines
Edge detection • Goal: Identify sudden   changes (discontinuities) in an   image    – Intuitively, most semantic and      ...
Why do we care about edges?• Extract information,  recognize objects                                     Vertical vanishin...
Origin of Edges                                surface normal discontinuity                                depth discontin...
Closeup of edges                   Source: D. Hoiem
Closeup of edges                   Source: D. Hoiem
Closeup of edges                   Source: D. Hoiem
Closeup of edges                   Source: D. Hoiem
Characterizing edges• An edge is a place of rapid change in the image  intensity function                     intensity fu...
With a little Gaussian noise                               Gradient                                      Source: D. Hoiem
Effects of noise • Consider a single row or column of the image    – Plotting intensity as a function of position gives a ...
Effects of noise• Difference filters respond strongly to noise  – Image noise results in pixels that look very different  ...
Solution: smooth first            f            g        f*g   d      ( f ∗ g)   dx                                   d• To...
Derivative theorem of convolution• Differentiation is convolution, and convolution is                       d             ...
Derivative of Gaussian filter                * [1 -1] =
Tradeoff between smoothing and localization    1 pixel             3 pixels              7 pixels • Smoothed derivative re...
Designing an edge detector• Criteria for a good edge detector:   – Good detection: the optimal detector should find all re...
Canny edge detector  • This is probably the most widely used edge    detector in computer vision  • Theoretical model: ste...
Example          original image (Lena)
Derivative of Gaussian filter         x-direction       y-direction
Compute Gradients (DoG)X-Derivative of Gaussian   Y-Derivative of Gaussian   Gradient Magnitude
Get Orientation at Each Pixel• Threshold at minimum level• Get orientation                               theta = atan2(gy,...
Non-maximum suppression for each    orientation                             At q, we have a                             ma...
Before Non-max Suppression
After non-max suppression
Hysteresis thresholding• Threshold at low/high levels to get weak/strong edge pixels• Do connected components, starting fr...
Hysteresis thresholding• Check that maximum value of gradient value  is sufficiently large  – drop-outs? use hysteresis   ...
Final Canny Edges
Canny edge detector1. Filter image with x, y derivatives of Gaussian2. Find magnitude and orientation of gradient3. Non-ma...
Effect of σ (Gaussian kernel spread/size)original             Canny with         Canny withThe choice of σ depends on desi...
Learning to detect boundaries      image                    human segmentation              gradient magnitude • Berkeley ...
Finding straight lines• One solution: try many possible lines and see  how many points each line passes through• Hough tra...
Hough transform• An early type of voting scheme• General outline:  – Discretize parameter space into bins  – For each feat...
Parameter space representation• A line in the image corresponds to a point in  Hough space     Image space               H...
Parameter space representation • What does a point (x0, y0) in the image space   map to in the Hough space?    Image space...
Parameter space representation • What does a point (x0, y0) in the image space   map to in the Hough space?   – Answer: th...
Parameter space representation • Where is the line that contains both (x0, y0)   and (x1, y1)?     Image space            ...
Parameter space representation • Where is the line that contains both (x0, y0)   and (x1, y1)?    – It is the intersection...
Parameter space representation• Problems with the (m,b) space:  – Unbounded parameter domain  – Vertical lines require inf...
Parameter space representation• Problems with the (m,b) space:  – Unbounded parameter domain  – Vertical lines require inf...
Algorithm outline • Initialize accumulator H   to all zeros • For each edge point (x,y)      ρ   in the image      For θ =...
Basic illustration          features   votes
Other shapes        Square   Circle
Several lines
A more complicated image                       http://ostatic.com/files/images/ss_hough.jpg
Effect of noise        features   votes
Effect of noise          features                  votes • Peak gets fuzzy and hard to locate
Effect of noise• Number of votes for a line of 20 points with  increasing noise:
Random points            features                   votes• Uniform noise can lead to spurious peaks in the array
Random points• As the level of uniform noise increases, the  maximum number of votes increases too:
Dealing with noise• Choose a good grid / discretization  – Too coarse: large votes obtained when too many    different lin...
Incorporating image gradients• Recall: when we detect an  edge point, we also know its  gradient direction• But this means...
Hough transform for circles• How many dimensions will the parameter space  have?• Given an oriented edge point, what are a...
Hough transform for circles       image space                               Hough parameter spacey                        ...
Hough transform for circles • Conceptually equivalent procedure: for each   (x,y,r), draw the corresponding circle in the ...
Finding straight lines• Another solution: get connected components of  pixels and check for straightness
Finding line segments using connected components1. Compute canny edges      –      Compute: gx, gy (DoG in x,y directions)...
1. Image  Canny
2. Canny lines  … straight edges
Comparison Hough Transform Method   Connected Components Method
Upcoming SlideShare
Loading in …5
×

Edges and lines

1,466 views

Published on

Published in: Technology, Art & Photos
  • Be the first to comment

Edges and lines

  1. 1. Edges and Lines
  2. 2. Edge detection • Goal: Identify sudden changes (discontinuities) in an image – Intuitively, most semantic and shape information from the image can be encoded in the edges – More compact than pixels • Ideal: artist’s line drawing (but artist is also using object-level knowledge) Source: D. Lowe
  3. 3. Why do we care about edges?• Extract information, recognize objects Vertical vanishing point (at infinity) Vanishing• Recover geometry and line viewpoint Vanishing Vanishing point point
  4. 4. Origin of Edges surface normal discontinuity depth discontinuity surface color discontinuity illumination discontinuity • Edges are caused by a variety of factors Source: Steve Seitz
  5. 5. Closeup of edges Source: D. Hoiem
  6. 6. Closeup of edges Source: D. Hoiem
  7. 7. Closeup of edges Source: D. Hoiem
  8. 8. Closeup of edges Source: D. Hoiem
  9. 9. Characterizing edges• An edge is a place of rapid change in the image intensity function intensity function image (along horizontal scanline) first derivative edges correspond to extrema of derivative
  10. 10. With a little Gaussian noise Gradient Source: D. Hoiem
  11. 11. Effects of noise • Consider a single row or column of the image – Plotting intensity as a function of position gives a signal Where is the edge? Source: S. Seitz
  12. 12. Effects of noise• Difference filters respond strongly to noise – Image noise results in pixels that look very different from their neighbors – Generally, the larger the noise the stronger the response• What can we do about it? Source: D. Forsyth
  13. 13. Solution: smooth first f g f*g d ( f ∗ g) dx d• To find edges, look for peaks in ( f ∗ g) dx Source: S. Seitz
  14. 14. Derivative theorem of convolution• Differentiation is convolution, and convolution is d d associative: ( f ∗ g) = f ∗ g dx dx• This saves us one operation: f d g dx d f∗ g dx Source: S. Seitz
  15. 15. Derivative of Gaussian filter * [1 -1] =
  16. 16. Tradeoff between smoothing and localization 1 pixel 3 pixels 7 pixels • Smoothed derivative removes noise, but blurs edge. Also finds edges at different “scales”. Source: D. Forsyth
  17. 17. Designing an edge detector• Criteria for a good edge detector: – Good detection: the optimal detector should find all real edges, ignoring noise or other artifacts – Good localization • the edges detected must be as close as possible to the true edges • the detector must return one point only for each true edge point• Cues of edge detection – Differences in color, intensity, or texture across the boundary – Continuity and closure – High-level knowledge Source: L. Fei-Fei
  18. 18. Canny edge detector • This is probably the most widely used edge detector in computer vision • Theoretical model: step-edges corrupted by additive Gaussian noise • Canny has shown that the first derivative of the Gaussian closely approximates the operator that optimizes the product of signal- to-noise ratio and localizationJ. Canny, A Computational Approach To Edge Detection, IEEETrans. Pattern Analysis and Machine Intelligence, 8:679-714, 1986. Source: L. Fei-Fei
  19. 19. Example original image (Lena)
  20. 20. Derivative of Gaussian filter x-direction y-direction
  21. 21. Compute Gradients (DoG)X-Derivative of Gaussian Y-Derivative of Gaussian Gradient Magnitude
  22. 22. Get Orientation at Each Pixel• Threshold at minimum level• Get orientation theta = atan2(gy, gx)
  23. 23. Non-maximum suppression for each orientation At q, we have a maximum if the value is larger than those at both p and at r. Interpolate to get these values.Source: D. Forsyth
  24. 24. Before Non-max Suppression
  25. 25. After non-max suppression
  26. 26. Hysteresis thresholding• Threshold at low/high levels to get weak/strong edge pixels• Do connected components, starting from strong edge pixels
  27. 27. Hysteresis thresholding• Check that maximum value of gradient value is sufficiently large – drop-outs? use hysteresis • use a high threshold to start edge curves and a low threshold to continue them. Source: S. Seitz
  28. 28. Final Canny Edges
  29. 29. Canny edge detector1. Filter image with x, y derivatives of Gaussian2. Find magnitude and orientation of gradient3. Non-maximum suppression: – Thin multi-pixel wide “ridges” down to single pixel width4. Thresholding and linking (hysteresis): – Define two thresholds: low and high – Use the high threshold to start edge curves and the low threshold to continue them• MATLAB: edge(image, ‘canny’) Source: D. Lowe, L. Fei-Fei
  30. 30. Effect of σ (Gaussian kernel spread/size)original Canny with Canny withThe choice of σ depends on desired behavior • large σ detects large scale edges • small σ detects fine features Source: S. Seitz
  31. 31. Learning to detect boundaries image human segmentation gradient magnitude • Berkeley segmentation database: http://www.eecs.berkeley.edu/Research/Projects/CS/vision/grouping/segbench/
  32. 32. Finding straight lines• One solution: try many possible lines and see how many points each line passes through• Hough transform provides a fast way to do this
  33. 33. Hough transform• An early type of voting scheme• General outline: – Discretize parameter space into bins – For each feature point in the image, put a vote in every bin in the parameter space that could have generated this point – Find bins that have the most votes Image space Hough parameter space P.V.C. Hough, Machine Analysis of Bubble Chamber Pictures, Proc. Int. Conf. High Energy Accelerators and Instrumentation, 1959
  34. 34. Parameter space representation• A line in the image corresponds to a point in Hough space Image space Hough parameter space Source: S. Seitz
  35. 35. Parameter space representation • What does a point (x0, y0) in the image space map to in the Hough space? Image space Hough parameter space
  36. 36. Parameter space representation • What does a point (x0, y0) in the image space map to in the Hough space? – Answer: the solutions of b = –x0m + y0 – This is a line in Hough space Image space Hough parameter space
  37. 37. Parameter space representation • Where is the line that contains both (x0, y0) and (x1, y1)? Image space Hough parameter space (x1, y1) (x0, y0) b = –x1m + y1
  38. 38. Parameter space representation • Where is the line that contains both (x0, y0) and (x1, y1)? – It is the intersection of the lines b = –x0m + y0 and Image –x m + b = space y1 Hough parameter space 1 (x1, y1) (x0, y0) b = –x1m + y1
  39. 39. Parameter space representation• Problems with the (m,b) space: – Unbounded parameter domain – Vertical lines require infinite m
  40. 40. Parameter space representation• Problems with the (m,b) space: – Unbounded parameter domain – Vertical lines require infinite m• Alternative: polar representation x cosθ + y sinθ = ρ Each point will add a sinusoid in the (θ,ρ) parameter space
  41. 41. Algorithm outline • Initialize accumulator H to all zeros • For each edge point (x,y) ρ in the image For θ = 0 to 180 ρ = x cos θ + y sin θ H(θ, ρ) = H(θ, ρ) + 1 θ end end • Find the value(s) of (θ, ρ) where H(θ, ρ) is a local maximum – The detected line in the image is given by ρ = x cos θ + y sin θ
  42. 42. Basic illustration features votes
  43. 43. Other shapes Square Circle
  44. 44. Several lines
  45. 45. A more complicated image http://ostatic.com/files/images/ss_hough.jpg
  46. 46. Effect of noise features votes
  47. 47. Effect of noise features votes • Peak gets fuzzy and hard to locate
  48. 48. Effect of noise• Number of votes for a line of 20 points with increasing noise:
  49. 49. Random points features votes• Uniform noise can lead to spurious peaks in the array
  50. 50. Random points• As the level of uniform noise increases, the maximum number of votes increases too:
  51. 51. Dealing with noise• Choose a good grid / discretization – Too coarse: large votes obtained when too many different lines correspond to a single bucket – Too fine: miss lines because some points that are not exactly collinear cast votes for different buckets• Increment neighboring bins (smoothing in accumulator array)• Try to get rid of irrelevant features – Take only edge points with significant gradient magnitude
  52. 52. Incorporating image gradients• Recall: when we detect an edge point, we also know its gradient direction• But this means that the line is uniquely determined!• Modified Hough transform:• For each edge point (x,y) θ = gradient orientation at (x,y) ρ = x cos θ + y sin θ H(θ, ρ) = H(θ, ρ) + 1 end
  53. 53. Hough transform for circles• How many dimensions will the parameter space have?• Given an oriented edge point, what are all possible bins that it can vote for?
  54. 54. Hough transform for circles image space Hough parameter spacey r ( x , y ) + r∇ I ( x , y ) (x,y) x ( x , y ) − r∇ I ( x , y ) x y
  55. 55. Hough transform for circles • Conceptually equivalent procedure: for each (x,y,r), draw the corresponding circle in the image and compute its “support” r x yIs this more or less efficient than voting with features?
  56. 56. Finding straight lines• Another solution: get connected components of pixels and check for straightness
  57. 57. Finding line segments using connected components1. Compute canny edges – Compute: gx, gy (DoG in x,y directions) – Compute: theta = atan(gy / gx)2. Assign each edge to one of 8 directions3. For each direction d, get edgelets: – find connected components for edge pixels with directions in {d-1, d, d+1}• Compute straightness and theta of edgelets using eig of x,y 2nd moment matrix of their points ∑ ( x − µ x ) ( y − µ y ) Larger eigenvector  ∑( x − µx )2M=  [ v, λ] = eig(Μ ) ∑ ( x − µ x ) ( y − µ y ) ∑( y − µ ) θ = atan 2( v(2,2), v(1,2)) 2  y   conf = λ2 / λ1• Threshold on straightness, store segment Slides from Derek Hoiem
  58. 58. 1. Image  Canny
  59. 59. 2. Canny lines  … straight edges
  60. 60. Comparison Hough Transform Method Connected Components Method

×