SlideShare a Scribd company logo
1 of 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

More Related Content

What's hot

Enhancement in frequency domain
Enhancement in frequency domainEnhancement in frequency domain
Enhancement in frequency domain
Ashish Kumar
 
4.intensity transformations
4.intensity transformations4.intensity transformations
4.intensity transformations
Yahya Alkhaldi
 
Comparison of image fusion methods
Comparison of image fusion methodsComparison of image fusion methods
Comparison of image fusion methods
Amr Nasr
 

What's hot (20)

Morphological image processing
Morphological image processingMorphological image processing
Morphological image processing
 
Digital Image Processing: An Introduction
Digital Image Processing: An IntroductionDigital Image Processing: An Introduction
Digital Image Processing: An Introduction
 
Digital Image Processing
Digital Image ProcessingDigital Image Processing
Digital Image Processing
 
Chapter 6 color image processing
Chapter 6 color image processingChapter 6 color image processing
Chapter 6 color image processing
 
Digital Image restoration
Digital Image restorationDigital Image restoration
Digital Image restoration
 
Enhancement in frequency domain
Enhancement in frequency domainEnhancement in frequency domain
Enhancement in frequency domain
 
DIGITAL IMAGE PROCESSING - Visual perception - DAY 2
DIGITAL IMAGE PROCESSING - Visual perception - DAY 2DIGITAL IMAGE PROCESSING - Visual perception - DAY 2
DIGITAL IMAGE PROCESSING - Visual perception - DAY 2
 
Spatial filtering
Spatial filteringSpatial filtering
Spatial filtering
 
Image Restoration (Frequency Domain Filters):Basics
Image Restoration (Frequency Domain Filters):BasicsImage Restoration (Frequency Domain Filters):Basics
Image Restoration (Frequency Domain Filters):Basics
 
Morphological image processing
Morphological image processingMorphological image processing
Morphological image processing
 
introduction to Digital Image Processing
introduction to Digital Image Processingintroduction to Digital Image Processing
introduction to Digital Image Processing
 
Pattern Recognition.pptx
Pattern Recognition.pptxPattern Recognition.pptx
Pattern Recognition.pptx
 
04 image enhancement edge detection
04 image enhancement edge detection04 image enhancement edge detection
04 image enhancement edge detection
 
Image Enhancement
Image Enhancement Image Enhancement
Image Enhancement
 
Chapter 1 and 2 gonzalez and woods
Chapter 1 and 2 gonzalez and woodsChapter 1 and 2 gonzalez and woods
Chapter 1 and 2 gonzalez and woods
 
4.intensity transformations
4.intensity transformations4.intensity transformations
4.intensity transformations
 
Introduction to digital image processing
Introduction to digital image processingIntroduction to digital image processing
Introduction to digital image processing
 
Comparison of image fusion methods
Comparison of image fusion methodsComparison of image fusion methods
Comparison of image fusion methods
 
Image Restoration And Reconstruction
Image Restoration And ReconstructionImage Restoration And Reconstruction
Image Restoration And Reconstruction
 
Digital Image Processing
Digital Image ProcessingDigital Image Processing
Digital Image Processing
 

Similar to Edges and lines

Similar to 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
 
Chapter10 image segmentation
Chapter10 image segmentationChapter10 image segmentation
Chapter10 image segmentation
 
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
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
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
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
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?
 
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...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
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)
 
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
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 

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

Editor's Notes

  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