SlideShare uma empresa Scribd logo
1 de 33
Baixar para ler offline
Robert Collins
CSE486, Penn State




                            Lecture 7:
                     Correspondence Matching
                       Reading: T&V Section 7.2
Robert Collins

                Recall: Derivative of Gaussian Filter
CSE486, Penn State


                                              Ix=dI(x,y)/dx
                          Gx

    I(x,y)
                               convolve



                          Gy
                                              Iy=dI(x,y)/dy

                               convolve
Robert Collins
CSE486, Penn State
                     Observe and Generalize
                     Derivative of Gaussian




                      Looks like vertical and
                      horizontal step edges

        Key idea: Convolution (and cross correlation) with a
        filter can be viewed as comparing a little “picture” of
        what you want to find against all local regions in the
        image.
Robert Collins
CSE486, Penn State
                        Observe and Generalize
      Key idea: Cross correlation with a filter can be viewed
      as comparing a little “picture” of what you want to find
      against all local regions in the image.
                                             Minimum response:
looks like vertical edge; lighter on right    vertical edge; lighter on left




     Maximum response:
      vertical edge; lighter on right
Robert Collins
CSE486, Penn State
                        Observe and Generalize
      Key idea: Cross correlation with a filter can be viewed
      as comparing a little “picture” of what you want to find
      against all local regions in the image.

       For this reason, it is sometimes called
        “matched filtering”

       In fact, you can prove that the best linear operator
       for finding an image patch is essentially the patch itself
           (using variational calculus, outside scope of our course).
Robert Collins
CSE486, Penn State
                      Template Matching
        What if we cut little pictures out from an image, then
        tried convolve them with the same or other images?
Robert Collins
CSE486, Penn State
                     Template Matching



                 *
Robert Collins
CSE486, Penn State
                     Template Matching



                 *
Robert Collins
CSE486, Penn State
                              Confession

        I’ve cheated a little bit.


        I subtracted the mean greyvalue from both the image
        and the template before doing cross correlation.

        Why? (we will discuss later, but think about it first)
Robert Collins
CSE486, Penn State
                     Correspondence Problem
         Vision tasks such as stereo and motion estimation require
         finding corresponding features across two or more views.
Robert Collins
CSE486, Penn State
                     The Correspondence Problem

         • Basic assumptions:
              – Most scene points are visible in both images
              – Corresponding image regions are similar

         • These assumptions hold if:
              – The distance of points from the cameras is
                 much larger than the distance between cameras




Camps, PSU
Robert Collins
CSE486, Penn State
                     The Correspondence Problem

         • Is a “search” problem:
              – Given an element in the left image, search for
                the corresponding element in the right image.
              – We will typically need geometric constraints to
                reduce the size of the search space
         • We must choose:
              – Elements to match
              – A similarity measure to compare elements

Camps, PSU
Robert Collins
CSE486, Penn State
                        Correspondence Problem

         • Two classes of algorithms:
              – Correlation-based algorithms
                     • Produce a DENSE set of correspondences

              – Feature-based algorithms
                     • Produce a SPARSE set of correspondences




Camps, PSU
Robert Collins
CSE486, Penn State
                     Correlation-based Algorithms
      Elements to be matched are image patches of fixed size




   Task: what is the corresponding patch in a second image?
                          ?
                          =




Camps, PSU
Robert Collins
CSE486, Penn State
                     Correlation-based Algorithms

    Task: what is the corresponding patch in a second image?
                          ?
                          =


           1) Need an appearance similarity function.

           2) Need a search strategy to find location with
              highest similarity. Simplest (but least
              efficient) approach is exhaustive search.
Robert Collins

                 Comparing Windows:
CSE486, Penn State                        ?
                                          =
                                      f       g
    Some possible measures:




                                              Most
                                              popular




Camps, PSU
Robert Collins
CSE486, Penn State

                        Correlation Cfg




         If we are doing exhaustive search over all image
         patches in the second image, this becomes cross-
         correlation of a template with an image. We have
         seen this before – imfilter(im,template,’corr’).
Robert Collins
CSE486, Penn State
                               Example




                     Image 1              Image 2

      Note: this is a stereo pair from the NASA mars rover.
      The rover is exploring the “El Capitan” formation.
Robert Collins
CSE486, Penn State
                               Example




                                         Template
                                         (image patch)
                     Image 1
Robert Collins

                 Example: Raw Cross-correlation
CSE486, Penn State




     score = imfilter(image2,tmpl)
                                     Score around
                                     correct match

Highest score




                     Correct match
Robert Collins
CSE486, Penn State
                     Example: Cross-correlation

                                     Note that score image
                                     looks a lot like a blurry
                                     version of image 2.

                                     This clues us in to the
                                     problem with straight
                                     correlation with an
                                     image template.
Problem with Correlation
Robert Collins
CSE486, Penn State


                         of Raw Image Templates
           Consider correlation of template with an image
           of constant grey value:

                     a    b   c       v   v   v
                     d    e   f   x   v   v   v
                     g    h   i       v   v   v


                 Result: v*(a+b+c+d+e+f+g+h+i)
Problem with Correlation
Robert Collins
CSE486, Penn State


                         of Raw Image Templates
           Now consider correlation with a constant image
           that is twice as bright.

                     a    b   c       2v 2v 2v
                     d    e   f   x   2v 2v 2v
                     g    h   i       2v 2v 2v


              Result: 2*v*(a+b+c+d+e+f+g+h+i)
                      > v*(a+b+c+d+e+f+g+h+i)
          Larger score, regardless of what the template is!
Robert Collins
CSE486, Penn State
                             Solution

      Subtract off the mean value of the template.

      In this way, the correlation score is higher only
      when darker parts of the template overlap darker
      parts of the image, and brighter parts of the template
      overlap brighter parts of the image.
Robert Collins

                 Correlation, zero-mean template
CSE486, Penn State




       Better! But highest score is still not the correct match.
       Note: highest score IS best within local neighborhood
       of correct match.
Robert Collins
CSE486, Penn State
                      “SSD” or “block matching”
                     (Sum of Squared Differences)




         1) The most popular matching score.
         2) We used it when deriving Harris corners
         3) T&V claim it works better than cross-correlation




Camps, PSU
Robert Collins
CSE486, Penn State
             Relation between SSD and Correlation




                                   Correlation!
Camps, PSU
Robert Collins
CSE486, Penn State
                                 SSD




          Best match (highest score) in image coincides with
          correct match in this case!
Robert Collins
CSE486, Penn State
                     Handling Intensity Changes

      Intensity Changes:

      •the camera taking the second image
      might have different intensity
      response characteristics than the
      camera taking the first image

      •Illumination in the scene could
      change

      •The camera might have auto-gain
      control set, so that it’s response
      changes as it moves through the
      scene.
Robert Collins
CSE486, Penn State
                     Intensity Normalization
       •When a scene is imaged by different sensors, or under
       different illumination intensities, both the SSD and
       the Cfg can be large for windows representing the same
       area in the scene!
       •A solution is to NORMALIZE the pixels in the windows
       before comparing them by subtracting the mean of the
       patch intensities and dividing by the std.dev.
Robert Collins
CSE486, Penn State
                     Normalized Cross Correlation

                          f                    g


                          intensity normalization




               NCC(f,g) =      ( ,      ) =
Robert Collins
CSE486, Penn State
                     Normalized Cross Correlation




       Highest score also coincides with correct match.
       Also, looks like less chances of getting a wrong match.
Robert Collins
CSE486, Penn State
                     Normalized Cross Correlation

           Important point about NCC:
             Score values range from 1 (perfect match)
               to -1 (completely anti-correlated)

           Intuition: treating the normalized patches as vectors,
           we see they are unit vectors. Therefore, correlation
           becomes dot product of unit vectors, and thus must
           range between -1 and 1.

Mais conteúdo relacionado

Semelhante a Lecture07

Lecture31
Lecture31Lecture31
Lecture31
zukun
 
Lecture17
Lecture17Lecture17
Lecture17
zukun
 
Lecture14
Lecture14Lecture14
Lecture14
zukun
 
Lecture23
Lecture23Lecture23
Lecture23
zukun
 
Lecture09
Lecture09Lecture09
Lecture09
zukun
 
Lecture20
Lecture20Lecture20
Lecture20
zukun
 
Lecture19
Lecture19Lecture19
Lecture19
zukun
 
Lecture04
Lecture04Lecture04
Lecture04
zukun
 
Lecture01
Lecture01Lecture01
Lecture01
zukun
 
Lecture28
Lecture28Lecture28
Lecture28
zukun
 
Lecture28
Lecture28Lecture28
Lecture28
zukun
 

Semelhante a Lecture07 (11)

Lecture31
Lecture31Lecture31
Lecture31
 
Lecture17
Lecture17Lecture17
Lecture17
 
Lecture14
Lecture14Lecture14
Lecture14
 
Lecture23
Lecture23Lecture23
Lecture23
 
Lecture09
Lecture09Lecture09
Lecture09
 
Lecture20
Lecture20Lecture20
Lecture20
 
Lecture19
Lecture19Lecture19
Lecture19
 
Lecture04
Lecture04Lecture04
Lecture04
 
Lecture01
Lecture01Lecture01
Lecture01
 
Lecture28
Lecture28Lecture28
Lecture28
 
Lecture28
Lecture28Lecture28
Lecture28
 

Mais de zukun

My lyn tutorial 2009
My lyn tutorial 2009My lyn tutorial 2009
My lyn tutorial 2009
zukun
 
ETHZ CV2012: Tutorial openCV
ETHZ CV2012: Tutorial openCVETHZ CV2012: Tutorial openCV
ETHZ CV2012: Tutorial openCV
zukun
 
ETHZ CV2012: Information
ETHZ CV2012: InformationETHZ CV2012: Information
ETHZ CV2012: Information
zukun
 
Siwei lyu: natural image statistics
Siwei lyu: natural image statisticsSiwei lyu: natural image statistics
Siwei lyu: natural image statistics
zukun
 
Lecture9 camera calibration
Lecture9 camera calibrationLecture9 camera calibration
Lecture9 camera calibration
zukun
 
Brunelli 2008: template matching techniques in computer vision
Brunelli 2008: template matching techniques in computer visionBrunelli 2008: template matching techniques in computer vision
Brunelli 2008: template matching techniques in computer vision
zukun
 
Modern features-part-4-evaluation
Modern features-part-4-evaluationModern features-part-4-evaluation
Modern features-part-4-evaluation
zukun
 
Modern features-part-3-software
Modern features-part-3-softwareModern features-part-3-software
Modern features-part-3-software
zukun
 
Modern features-part-2-descriptors
Modern features-part-2-descriptorsModern features-part-2-descriptors
Modern features-part-2-descriptors
zukun
 
Modern features-part-1-detectors
Modern features-part-1-detectorsModern features-part-1-detectors
Modern features-part-1-detectors
zukun
 
Modern features-part-0-intro
Modern features-part-0-introModern features-part-0-intro
Modern features-part-0-intro
zukun
 
Lecture 02 internet video search
Lecture 02 internet video searchLecture 02 internet video search
Lecture 02 internet video search
zukun
 
Lecture 01 internet video search
Lecture 01 internet video searchLecture 01 internet video search
Lecture 01 internet video search
zukun
 
Lecture 03 internet video search
Lecture 03 internet video searchLecture 03 internet video search
Lecture 03 internet video search
zukun
 
Icml2012 tutorial representation_learning
Icml2012 tutorial representation_learningIcml2012 tutorial representation_learning
Icml2012 tutorial representation_learning
zukun
 
Advances in discrete energy minimisation for computer vision
Advances in discrete energy minimisation for computer visionAdvances in discrete energy minimisation for computer vision
Advances in discrete energy minimisation for computer vision
zukun
 
Gephi tutorial: quick start
Gephi tutorial: quick startGephi tutorial: quick start
Gephi tutorial: quick start
zukun
 
EM algorithm and its application in probabilistic latent semantic analysis
EM algorithm and its application in probabilistic latent semantic analysisEM algorithm and its application in probabilistic latent semantic analysis
EM algorithm and its application in probabilistic latent semantic analysis
zukun
 
Object recognition with pictorial structures
Object recognition with pictorial structuresObject recognition with pictorial structures
Object recognition with pictorial structures
zukun
 
Iccv2011 learning spatiotemporal graphs of human activities
Iccv2011 learning spatiotemporal graphs of human activities Iccv2011 learning spatiotemporal graphs of human activities
Iccv2011 learning spatiotemporal graphs of human activities
zukun
 

Mais de zukun (20)

My lyn tutorial 2009
My lyn tutorial 2009My lyn tutorial 2009
My lyn tutorial 2009
 
ETHZ CV2012: Tutorial openCV
ETHZ CV2012: Tutorial openCVETHZ CV2012: Tutorial openCV
ETHZ CV2012: Tutorial openCV
 
ETHZ CV2012: Information
ETHZ CV2012: InformationETHZ CV2012: Information
ETHZ CV2012: Information
 
Siwei lyu: natural image statistics
Siwei lyu: natural image statisticsSiwei lyu: natural image statistics
Siwei lyu: natural image statistics
 
Lecture9 camera calibration
Lecture9 camera calibrationLecture9 camera calibration
Lecture9 camera calibration
 
Brunelli 2008: template matching techniques in computer vision
Brunelli 2008: template matching techniques in computer visionBrunelli 2008: template matching techniques in computer vision
Brunelli 2008: template matching techniques in computer vision
 
Modern features-part-4-evaluation
Modern features-part-4-evaluationModern features-part-4-evaluation
Modern features-part-4-evaluation
 
Modern features-part-3-software
Modern features-part-3-softwareModern features-part-3-software
Modern features-part-3-software
 
Modern features-part-2-descriptors
Modern features-part-2-descriptorsModern features-part-2-descriptors
Modern features-part-2-descriptors
 
Modern features-part-1-detectors
Modern features-part-1-detectorsModern features-part-1-detectors
Modern features-part-1-detectors
 
Modern features-part-0-intro
Modern features-part-0-introModern features-part-0-intro
Modern features-part-0-intro
 
Lecture 02 internet video search
Lecture 02 internet video searchLecture 02 internet video search
Lecture 02 internet video search
 
Lecture 01 internet video search
Lecture 01 internet video searchLecture 01 internet video search
Lecture 01 internet video search
 
Lecture 03 internet video search
Lecture 03 internet video searchLecture 03 internet video search
Lecture 03 internet video search
 
Icml2012 tutorial representation_learning
Icml2012 tutorial representation_learningIcml2012 tutorial representation_learning
Icml2012 tutorial representation_learning
 
Advances in discrete energy minimisation for computer vision
Advances in discrete energy minimisation for computer visionAdvances in discrete energy minimisation for computer vision
Advances in discrete energy minimisation for computer vision
 
Gephi tutorial: quick start
Gephi tutorial: quick startGephi tutorial: quick start
Gephi tutorial: quick start
 
EM algorithm and its application in probabilistic latent semantic analysis
EM algorithm and its application in probabilistic latent semantic analysisEM algorithm and its application in probabilistic latent semantic analysis
EM algorithm and its application in probabilistic latent semantic analysis
 
Object recognition with pictorial structures
Object recognition with pictorial structuresObject recognition with pictorial structures
Object recognition with pictorial structures
 
Iccv2011 learning spatiotemporal graphs of human activities
Iccv2011 learning spatiotemporal graphs of human activities Iccv2011 learning spatiotemporal graphs of human activities
Iccv2011 learning spatiotemporal graphs of human activities
 

Lecture07

  • 1. Robert Collins CSE486, Penn State Lecture 7: Correspondence Matching Reading: T&V Section 7.2
  • 2. Robert Collins Recall: Derivative of Gaussian Filter CSE486, Penn State Ix=dI(x,y)/dx Gx I(x,y) convolve Gy Iy=dI(x,y)/dy convolve
  • 3. Robert Collins CSE486, Penn State Observe and Generalize Derivative of Gaussian Looks like vertical and horizontal step edges Key idea: Convolution (and cross correlation) with a filter can be viewed as comparing a little “picture” of what you want to find against all local regions in the image.
  • 4. Robert Collins CSE486, Penn State Observe and Generalize Key idea: Cross correlation with a filter can be viewed as comparing a little “picture” of what you want to find against all local regions in the image. Minimum response: looks like vertical edge; lighter on right vertical edge; lighter on left Maximum response: vertical edge; lighter on right
  • 5. Robert Collins CSE486, Penn State Observe and Generalize Key idea: Cross correlation with a filter can be viewed as comparing a little “picture” of what you want to find against all local regions in the image. For this reason, it is sometimes called “matched filtering” In fact, you can prove that the best linear operator for finding an image patch is essentially the patch itself (using variational calculus, outside scope of our course).
  • 6. Robert Collins CSE486, Penn State Template Matching What if we cut little pictures out from an image, then tried convolve them with the same or other images?
  • 7. Robert Collins CSE486, Penn State Template Matching *
  • 8. Robert Collins CSE486, Penn State Template Matching *
  • 9. Robert Collins CSE486, Penn State Confession I’ve cheated a little bit. I subtracted the mean greyvalue from both the image and the template before doing cross correlation. Why? (we will discuss later, but think about it first)
  • 10. Robert Collins CSE486, Penn State Correspondence Problem Vision tasks such as stereo and motion estimation require finding corresponding features across two or more views.
  • 11. Robert Collins CSE486, Penn State The Correspondence Problem • Basic assumptions: – Most scene points are visible in both images – Corresponding image regions are similar • These assumptions hold if: – The distance of points from the cameras is much larger than the distance between cameras Camps, PSU
  • 12. Robert Collins CSE486, Penn State The Correspondence Problem • Is a “search” problem: – Given an element in the left image, search for the corresponding element in the right image. – We will typically need geometric constraints to reduce the size of the search space • We must choose: – Elements to match – A similarity measure to compare elements Camps, PSU
  • 13. Robert Collins CSE486, Penn State Correspondence Problem • Two classes of algorithms: – Correlation-based algorithms • Produce a DENSE set of correspondences – Feature-based algorithms • Produce a SPARSE set of correspondences Camps, PSU
  • 14. Robert Collins CSE486, Penn State Correlation-based Algorithms Elements to be matched are image patches of fixed size Task: what is the corresponding patch in a second image? ? = Camps, PSU
  • 15. Robert Collins CSE486, Penn State Correlation-based Algorithms Task: what is the corresponding patch in a second image? ? = 1) Need an appearance similarity function. 2) Need a search strategy to find location with highest similarity. Simplest (but least efficient) approach is exhaustive search.
  • 16. Robert Collins Comparing Windows: CSE486, Penn State ? = f g Some possible measures: Most popular Camps, PSU
  • 17. Robert Collins CSE486, Penn State Correlation Cfg If we are doing exhaustive search over all image patches in the second image, this becomes cross- correlation of a template with an image. We have seen this before – imfilter(im,template,’corr’).
  • 18. Robert Collins CSE486, Penn State Example Image 1 Image 2 Note: this is a stereo pair from the NASA mars rover. The rover is exploring the “El Capitan” formation.
  • 19. Robert Collins CSE486, Penn State Example Template (image patch) Image 1
  • 20. Robert Collins Example: Raw Cross-correlation CSE486, Penn State score = imfilter(image2,tmpl) Score around correct match Highest score Correct match
  • 21. Robert Collins CSE486, Penn State Example: Cross-correlation Note that score image looks a lot like a blurry version of image 2. This clues us in to the problem with straight correlation with an image template.
  • 22. Problem with Correlation Robert Collins CSE486, Penn State of Raw Image Templates Consider correlation of template with an image of constant grey value: a b c v v v d e f x v v v g h i v v v Result: v*(a+b+c+d+e+f+g+h+i)
  • 23. Problem with Correlation Robert Collins CSE486, Penn State of Raw Image Templates Now consider correlation with a constant image that is twice as bright. a b c 2v 2v 2v d e f x 2v 2v 2v g h i 2v 2v 2v Result: 2*v*(a+b+c+d+e+f+g+h+i) > v*(a+b+c+d+e+f+g+h+i) Larger score, regardless of what the template is!
  • 24. Robert Collins CSE486, Penn State Solution Subtract off the mean value of the template. In this way, the correlation score is higher only when darker parts of the template overlap darker parts of the image, and brighter parts of the template overlap brighter parts of the image.
  • 25. Robert Collins Correlation, zero-mean template CSE486, Penn State Better! But highest score is still not the correct match. Note: highest score IS best within local neighborhood of correct match.
  • 26. Robert Collins CSE486, Penn State “SSD” or “block matching” (Sum of Squared Differences) 1) The most popular matching score. 2) We used it when deriving Harris corners 3) T&V claim it works better than cross-correlation Camps, PSU
  • 27. Robert Collins CSE486, Penn State Relation between SSD and Correlation Correlation! Camps, PSU
  • 28. Robert Collins CSE486, Penn State SSD Best match (highest score) in image coincides with correct match in this case!
  • 29. Robert Collins CSE486, Penn State Handling Intensity Changes Intensity Changes: •the camera taking the second image might have different intensity response characteristics than the camera taking the first image •Illumination in the scene could change •The camera might have auto-gain control set, so that it’s response changes as it moves through the scene.
  • 30. Robert Collins CSE486, Penn State Intensity Normalization •When a scene is imaged by different sensors, or under different illumination intensities, both the SSD and the Cfg can be large for windows representing the same area in the scene! •A solution is to NORMALIZE the pixels in the windows before comparing them by subtracting the mean of the patch intensities and dividing by the std.dev.
  • 31. Robert Collins CSE486, Penn State Normalized Cross Correlation f g intensity normalization NCC(f,g) = ( , ) =
  • 32. Robert Collins CSE486, Penn State Normalized Cross Correlation Highest score also coincides with correct match. Also, looks like less chances of getting a wrong match.
  • 33. Robert Collins CSE486, Penn State Normalized Cross Correlation Important point about NCC: Score values range from 1 (perfect match) to -1 (completely anti-correlated) Intuition: treating the normalized patches as vectors, we see they are unit vectors. Therefore, correlation becomes dot product of unit vectors, and thus must range between -1 and 1.