SlideShare una empresa de Scribd logo
1 de 60
Edges and Lines
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
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
Origin of Edges

                                surface normal discontinuity


                                depth discontinuity


                                surface color discontinuity


                                illumination discontinuity




 • Edges are caused by a variety of factors


                                                  Source: Steve Seitz
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 function
    image       (along horizontal scanline)     first derivative




                                              edges correspond to
                                              extrema of derivative
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 signal




 Where is the edge?
                                                            Source: S. Seitz
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
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
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
Derivative of Gaussian filter



                * [1 -1] =
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
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
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 localization

J. Canny, A Computational Approach To Edge Detection, IEEE
Trans. Pattern Analysis and Machine Intelligence, 8:679-714, 1986.

                                                             Source: L. Fei-Fei
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, gx)
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
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 from strong edge pixels
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
Final Canny Edges
Canny edge detector
1. Filter image with x, y derivatives of Gaussian
2. Find magnitude and orientation of gradient
3. Non-maximum suppression:
    – Thin multi-pixel wide “ridges” down to single pixel width
4. 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
Effect of σ (Gaussian kernel spread/size)




original             Canny with         Canny with


The choice of σ depends on desired behavior
  • large σ detects large scale edges
  • small σ detects fine features
                                                 Source: S. Seitz
Learning to detect boundaries
      image                    human segmentation              gradient magnitude




 • Berkeley segmentation database:
   http://www.eecs.berkeley.edu/Research/Projects/CS/vision/grouping/segbench/
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
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
Parameter space representation
• A line in the image corresponds to a point in
  Hough space

     Image space               Hough parameter space




                                             Source: S. Seitz
Parameter space representation
 • What does a point (x0, y0) in the image space
   map to in the Hough space?


    Image space                 Hough parameter space
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
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
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
Parameter space representation
• Problems with the (m,b) space:
  – Unbounded parameter domain
  – Vertical lines require infinite m
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
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 θ
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 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
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
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?
Hough transform for circles

       image space                               Hough parameter space
y                                                        r


                ( x , y ) + r∇ I ( x , y )



                     (x,y)
                                                                     x
    ( x , y ) − r∇ I ( x , y )


                                             x
                                                  y
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

      y
Is this more or less efficient than voting with features?
Finding straight lines

• Another solution: get connected components of
  pixels and check for straightness
Finding line segments using connected
 components
1. Compute canny edges
      –      Compute: gx, gy (DoG in x,y directions)
      –      Compute: theta = atan(gy / gx)
2. Assign each edge to one of 8 directions
3. 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 )2
M=                                                        [ 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
1. Image  Canny
2. Canny lines  … straight edges
Comparison




 Hough Transform Method   Connected Components Method

Más contenido relacionado

La actualidad más candente

Edge detection of video using matlab code
Edge detection of video using matlab codeEdge detection of video using matlab code
Edge detection of video using matlab code
Bhushan Deore
 
Digital image processing img smoothning
Digital image processing img smoothningDigital image processing img smoothning
Digital image processing img smoothning
Vinay Gupta
 

La actualidad más candente (20)

Image Enhancement in Spatial Domain
Image Enhancement in Spatial DomainImage Enhancement in Spatial Domain
Image Enhancement in Spatial Domain
 
Edge Detection
Edge Detection Edge Detection
Edge Detection
 
Canny Edge Detection
Canny Edge DetectionCanny Edge Detection
Canny Edge Detection
 
image denoising technique using disctere wavelet transform
image denoising technique using disctere wavelet transformimage denoising technique using disctere wavelet transform
image denoising technique using disctere wavelet transform
 
EDGE DETECTION
EDGE DETECTIONEDGE DETECTION
EDGE DETECTION
 
Image Restoration And Reconstruction
Image Restoration And ReconstructionImage Restoration And Reconstruction
Image Restoration And Reconstruction
 
Edge detection of video using matlab code
Edge detection of video using matlab codeEdge detection of video using matlab code
Edge detection of video using matlab code
 
HIGH PASS FILTER IN DIGITAL IMAGE PROCESSING
HIGH PASS FILTER IN DIGITAL IMAGE PROCESSINGHIGH PASS FILTER IN DIGITAL IMAGE PROCESSING
HIGH PASS FILTER IN DIGITAL IMAGE PROCESSING
 
DCT image compression
DCT image compressionDCT image compression
DCT image compression
 
Adaptive unsharp masking
Adaptive unsharp maskingAdaptive unsharp masking
Adaptive unsharp masking
 
Chapter10 image segmentation
Chapter10 image segmentationChapter10 image segmentation
Chapter10 image segmentation
 
Image segmentation
Image segmentationImage segmentation
Image segmentation
 
Image enhancement
Image enhancementImage enhancement
Image enhancement
 
Image segmentation
Image segmentationImage segmentation
Image segmentation
 
Spatial domain and filtering
Spatial domain and filteringSpatial domain and filtering
Spatial domain and filtering
 
Region based segmentation
Region based segmentationRegion based segmentation
Region based segmentation
 
Shape Features
 Shape Features  Shape Features
Shape Features
 
Digital image processing img smoothning
Digital image processing img smoothningDigital image processing img smoothning
Digital image processing img smoothning
 
Unit3 dip
Unit3 dipUnit3 dip
Unit3 dip
 
Bit plane slicing
Bit plane slicingBit plane slicing
Bit plane slicing
 

Similar a Edges and lines

Similar a Edges and lines (20)

Lec06 edge
Lec06 edgeLec06 edge
Lec06 edge
 
Feature Detection and Matching
Feature Detection and MatchingFeature Detection and Matching
Feature Detection and Matching
 
Computer vision - edge detection
Computer vision - edge detectionComputer vision - edge detection
Computer vision - edge detection
 
Lec09 hough
Lec09 houghLec09 hough
Lec09 hough
 
Fuzzy Logic Based Edge Detection
Fuzzy Logic Based Edge DetectionFuzzy Logic Based Edge Detection
Fuzzy Logic Based Edge Detection
 
Lec05 filter
Lec05 filterLec05 filter
Lec05 filter
 
cv1.ppt
cv1.pptcv1.ppt
cv1.ppt
 
Lecture 6-computer vision features descriptors matching
Lecture 6-computer vision features descriptors matchingLecture 6-computer vision features descriptors matching
Lecture 6-computer vision features descriptors matching
 
Computer Vision harris
Computer Vision harrisComputer Vision harris
Computer Vision harris
 
09 cie552 image_featuresi
09 cie552 image_featuresi09 cie552 image_featuresi
09 cie552 image_featuresi
 
Basics of Linear Hough Transform
Basics of Linear Hough TransformBasics of Linear Hough Transform
Basics of Linear Hough Transform
 
Lec03 light
Lec03 lightLec03 light
Lec03 light
 
image segmentation image segmentation.pptx
image segmentation image segmentation.pptximage segmentation image segmentation.pptx
image segmentation image segmentation.pptx
 
06 image features
06 image features06 image features
06 image features
 
16 17 bag_words
16 17 bag_words16 17 bag_words
16 17 bag_words
 
PPT s06-machine vision-s2
PPT s06-machine vision-s2PPT s06-machine vision-s2
PPT s06-machine vision-s2
 
Edge Detection and Segmentation
Edge Detection and SegmentationEdge Detection and Segmentation
Edge Detection and Segmentation
 
Edge linking via Hough transform.ppt
Edge linking via Hough transform.pptEdge linking via Hough transform.ppt
Edge linking via Hough transform.ppt
 
Computer Vision invariance
Computer Vision invarianceComputer Vision invariance
Computer Vision invariance
 
Module 31
Module 31Module 31
Module 31
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 

Edges and lines

  • 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. 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. 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. Closeup of edges Source: D. Hoiem
  • 6. Closeup of edges Source: D. Hoiem
  • 7. Closeup of edges Source: D. Hoiem
  • 8. Closeup of edges Source: D. Hoiem
  • 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. With a little Gaussian noise Gradient Source: D. Hoiem
  • 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. 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. 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. 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. Derivative of Gaussian filter * [1 -1] =
  • 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. 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. 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 localization J. Canny, A Computational Approach To Edge Detection, IEEE Trans. Pattern Analysis and Machine Intelligence, 8:679-714, 1986. Source: L. Fei-Fei
  • 19. Example original image (Lena)
  • 20. Derivative of Gaussian filter x-direction y-direction
  • 21. Compute Gradients (DoG) X-Derivative of Gaussian Y-Derivative of Gaussian Gradient Magnitude
  • 22. Get Orientation at Each Pixel • Threshold at minimum level • Get orientation theta = atan2(gy, gx)
  • 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
  • 26. Hysteresis thresholding • Threshold at low/high levels to get weak/strong edge pixels • Do connected components, starting from strong edge pixels
  • 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
  • 29. Canny edge detector 1. Filter image with x, y derivatives of Gaussian 2. Find magnitude and orientation of gradient 3. Non-maximum suppression: – Thin multi-pixel wide “ridges” down to single pixel width 4. 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. Effect of σ (Gaussian kernel spread/size) original Canny with Canny with The choice of σ depends on desired behavior • large σ detects large scale edges • small σ detects fine features Source: S. Seitz
  • 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. 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. 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. Parameter space representation • A line in the image corresponds to a point in Hough space Image space Hough parameter space Source: S. Seitz
  • 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. 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. 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. 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. Parameter space representation • Problems with the (m,b) space: – Unbounded parameter domain – Vertical lines require infinite m
  • 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. 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. Basic illustration features votes
  • 43. Other shapes Square Circle
  • 45. A more complicated image http://ostatic.com/files/images/ss_hough.jpg
  • 46. Effect of noise features votes
  • 47. Effect of noise features votes • Peak gets fuzzy and hard to locate
  • 48. Effect of noise • Number of votes for a line of 20 points with increasing noise:
  • 49. Random points features votes • Uniform noise can lead to spurious peaks in the array
  • 50. Random points • As the level of uniform noise increases, the maximum number of votes increases too:
  • 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. 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. 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. Hough transform for circles image space Hough parameter space y r ( x , y ) + r∇ I ( x , y ) (x,y) x ( x , y ) − r∇ I ( x , y ) x y
  • 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 y Is this more or less efficient than voting with features?
  • 56. Finding straight lines • Another solution: get connected components of pixels and check for straightness
  • 57. Finding line segments using connected components 1. Compute canny edges – Compute: gx, gy (DoG in x,y directions) – Compute: theta = atan(gy / gx) 2. Assign each edge to one of 8 directions 3. 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 )2 M=  [ 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. 1. Image  Canny
  • 59. 2. Canny lines  … straight edges
  • 60. Comparison Hough Transform Method Connected Components Method

Notas del editor

  1. How to fix?
  2. Is this filter separable?
  3. Figure 15.1, top half. Note that most points in the vote array are very dark, because they get only one vote.
  4. This is 15.1 lower half
  5. This is 15.1 lower half
  6. This is the number of votes that the real line of 20 points gets with increasing noise (figure15.3)
  7. 15.2; main point is that lots of noise can lead to large peaks in the array
  8. Figure 15.4; as the noise increases in a picture without a line, the number of points in the max cell goes up, too