SlideShare a Scribd company logo
1 of 40
Download to read offline
Robert Collins
CSE486, Penn State




                        Lecture 09:
                     Stereo Algorithms
Robert Collins
CSE486, Penn State
                     Recall: Simple Stereo System
                     Y                        Z
                                                                  (X,Y,Z)
                                      z
      left     y
      camera
    located at                (   ,       )
                                                                  z
     (0,0,0)                              y       (       ,   )
                          x                                               right
                                                                          camera
                         Tx                                                located at
                                                      x                    (Tx,0,0)
   Image coords of point (X,Y,Z)
   Left Camera:                                                       X

   Right Camera:

Camps, PSU
Robert Collins
CSE486, Penn State
                       Recall: Stereo Disparity
   Left camera




   Right camera




    Stereo Disparity                              baseline
                                       depth


                                                  disparity

                                     Important equation!
Robert Collins
CSE486, Penn State
                     Recall: Stereo Disparity
   Left camera




   Right camera




                                     depth
        Note: Depth and
        stereo disparity are
                                                disparity
        inversely proportional
                                   Important equation!
Robert Collins
CSE486, Penn State
                            Stereo Example




               Left Image                        Right Image


                 From Middlebury stereo evaluation page
                     http://www.middlebury.edu/stereo/
Robert Collins
CSE486, Penn State
                        Stereo Example
           Left image        Disparity values (0-64)




          Right image




                           Note how disparity is larger
                           (brighter) for closer surfaces.
Robert Collins
CSE486, Penn State
                       Computing Disparity

         • Correspondence Problem:
              – Determining which pixel in the right image
                corresponds to each pixel in the left image.
              – Disp = x_coord(left) - x_coord(right)

         Recall our discussion of computing correspondences
         of image patches ( Lecture 7 ).
            SSD - sum of squared difference measure
            NCC - normalized cross correlation measure


Camps, PSU
Robert Collins
CSE486, Penn State
                     Epipolar Constraint

       Important Concept:

       For stereo matching, we don’t have to search the
       whole 2D right image for a corresponding point.

       The “epipolar constraint” reduces the search space
       to a one-dimensional line.
Robert Collins
CSE486, Penn State
                     Recall : Simple Stereo System
                               P
                     z                 Left camera
  y
                                   z
                      y                Right camera
             x
                           Epipolar line
           Tx
                           x
                                                     Same Y Coord!
Robert Collins
CSE486, Penn State
                     Matching using Epipolar Lines
                     Left Image             Right Image




    For a patch in left image
   Compare with patches along
    same row in right image
                                     Match Score Values
Robert Collins
CSE486, Penn State
                     Matching using Epipolar Lines
                     Left Image             Right Image




    Select patch with highest
       match score.
    Repeat for all pixels in         Match Score Values
    left image.
Robert Collins
CSE486, Penn State
                      Example: 5x5 windows
                        NCC match score




           Computed disparities         Ground truth
  Black pixels: bad disparity values,
  or no matching patch in right image
Robert Collins
CSE486, Penn State
                     Occlusions: No matches

                                       Left image




                                       Right image
Robert Collins
CSE486, Penn State
                          Effects of Patch Size




                 5x5 patches                11x11patches

       Smoother in some areas            Loss of finer details
Robert Collins

               Adding Inter-Scanline Consistency
CSE486, Penn State




               So far, each left image patch has been matched
               independently along the right epipolar line.

               This can lead to errors.

               We would like to enforce some consistency
               among matches in the same row (scanline).
Robert Collins
CSE486, Penn State
                                                     Disparity Space Image
            First we introduce the concept of DSI.
            The DSI for one row represents pairwise match scores
            between patches along that row in the left and right image.
                                                             Pixels along left scanline

                                                                             Pixel i
                                                                                          C(i,j) = Match score
                                                                                          for patch centered
                     Pixels along right scanline




                                                                                          at left pixel i with
                                                                                          patch centered at
                                                                                          right pixel j.
                                                   Pixel j
Robert Collins
CSE486, Penn State
                      Disparity Space Image (DSI)
                     Left Image             Right Image




                                     Dissimilarity Values
                                        (1-NCC) or SSD
Robert Collins
CSE486, Penn State
                      Disparity Space Image (DSI)
                     Left Image             Right Image




                                     Dissimilarity Values
                                        (1-NCC) or SSD
Robert Collins
CSE486, Penn State
                      Disparity Space Image (DSI)
                     Left Image             Right Image




                                     Dissimilarity Values
                                        (1-NCC) or SSD
Robert Collins
CSE486, Penn State
                      Disparity Space Image (DSI)
                     Left Image               DSI




                                           Enter each vector of
                                           match scores as a
                                           column in the DSI
       Dissimilarity Values
Robert Collins
CSE486, Penn State
                          Disparity Space Image
                                Left scanline
         Right scanline
Robert Collins
CSE486, Penn State
                          Disparity Space Image
                                  Left scanline


                                           Invalid entries due to constraint
                                           that disparity <= high value
                                           64 in this case)
         Right scanline




     Invalid entries due to constraint
     that disparity >= low value
     (0 in this case)
Robert Collins
CSE486, Penn State
                                                    Disparity Space Image
                                           N cols in left scanline

                                                                            If we rearrange the diagonal
                                                                            band of valid values into a
    M cols in right scanline




                                                                            rectangular array (in this case
                                                                            of size 64 x N), that is what is
                                                                            traditionally known as the DSI

                                                                            However, I’m going to keep the full
                                                                            image around, including invalid values
                                                                            (I think it is easier to understand the
                                                                            pixel coordinates involved)

                                                               coordinate in left scanline (e.g. N)

                               Disparity                    Disparity Space Image
                               (e.g. 64)
Robert Collins
CSE486, Penn State
                     DSI and Scanline Consistency
                     Assigning disparities to all pixels in left scanline now
                     amounts to finding a connected path through the DSI
        Start




                                                                                End
Robert Collins
CSE486, Penn State
                        Lowest Cost Path
           We would like to choose the “best” path.
           Want one with lowest “cost” (Lowest sum of
           dissimilarity scores along the path)


                                                ?


                                   ?
                                                        ?
Robert Collins
CSE486, Penn State
                       Constraints on Path

          It is common to impose an ordering constraint
          on the path. Intuitively, the path is not allowed
          to “double back” on itself.
Robert Collins
CSE486, Penn State
                          Ordering Constraint
               A
                                   D
                     B     C                   A     B    C




                                       ABCD
                                                    D


    ABCD                                                         DABC
                         ABCD




            Ordering constraint…              …and its failure
Robert Collins
CSE486, Penn State
                     Dealing with Occlusions




   Left scanline                           Right scanline
                …                  …
Robert Collins
CSE486, Penn State
                         Dealing with Occlusions




   Left scanline                                                    Right scanline
                …                                     …

                                              Match

                                        Match

                     Occluded from    Match               Occluded from
                     right scanline                       left scanline
Robert Collins
CSE486, Penn State
                     An Optimal Scanline Strategy

         • We want to find best path, taking into
           account ordering constraint and the
           possibility of occlusions.

            Algorithm we will discuss now is from
               Cox, Hingorani, Rao, Maggs, “A Maximum
               Likelihood Stereo Algorithm,” Computer
               Vision and Image Understanding, Vol 63(3),
               May 1996, pp.542-567.
Robert Collins
CSE486, Penn State
                         Cox et.al. Stereo Matching
                       Occluded                      i-1,j-1                 i-1,j
                       from right

                                                                    match
       Occluded            match
                                                                            Occluded
       from left                                                            from left


                                                     i,j-1     Occluded         i,j
        Three cases:                                           from right
             – Matching patches. Cost = dissimilarity score
             – Occluded from right. Cost is some constant value.
             – Occluded from left. Cost is some constant value.

                     C(i,j)= min([ C(i-1,j-1) + dissimilarity(i,j)
                                   C(i-1,j) + occlusionConstant,
                                   C(i,j-1) + occlusionConstant]);
Robert Collins
CSE486, Penn State
                     Cox et.al. Stereo Matching
  Start                            Recap: want to find lowest
                                   cost path from upper left to
                                   lower right of DSI image.

                                   At each point on the path we
                                   have three choices: step left,
                                   step down, step diagonally.
                            End
                                   Each choice has a well-defined
                                   cost associated with it.

   This problem just screams out for Dynamic Programming!
   (which, indeed, is how Cox et.al. solve the problem)
Robert Collins
CSE486, Penn State
                      Real Scanline Example
                     DSI                            DP cost matrix
                                      (cost of optimal path from each point to END)




             Every pixel in left column now is marked with
             either a disparity value, or an occlusion label.
              Proceed for every scanline in left image.
Robert Collins
CSE486, Penn State
                          Example
     Result of DP alg             Result without DP (independent pixels)




  Result of DP alg. Black pixels = occluded.
Robert Collins
CSE486, Penn State
                         Occlusion Filling
           Simple trick for filling in gaps caused by occlusion.




                               = left occluded
          Fill in left occluded pixels with value from the
          nearest valid pixel preceding it in the scanline.




 Similarly, for right occluded, look for valid pixel to the right.
Robert Collins
CSE486, Penn State
                                    Example




                     Result of DP alg with occlusion filling.
Robert Collins
CSE486, Penn State
                                          Example
     Result of DP alg with occlusion filling.   Result without DP (independent pixels)
Robert Collins
CSE486, Penn State
                                          Example
     Result of DP alg with occlusion filling.   Ground truth
Robert Collins
CSE486, Penn State   www.middlebury.edu/stereo/
Robert Collins
CSE486, Penn State
                          State-of-the-Art Results




                     Algorithm Results       Ground truth

           J. Sun, Y. Li, S.B. Kang, and H.-Y. Shum.
           “Symmetric stereo matching for occlusion handling”.
           IEEE Conference on Computer Vision and Pattern
           Recognition, June 2005.

More Related Content

More from zukun

My lyn tutorial 2009
My lyn tutorial 2009My lyn tutorial 2009
My lyn tutorial 2009zukun
 
ETHZ CV2012: Tutorial openCV
ETHZ CV2012: Tutorial openCVETHZ CV2012: Tutorial openCV
ETHZ CV2012: Tutorial openCVzukun
 
ETHZ CV2012: Information
ETHZ CV2012: InformationETHZ CV2012: Information
ETHZ CV2012: Informationzukun
 
Siwei lyu: natural image statistics
Siwei lyu: natural image statisticsSiwei lyu: natural image statistics
Siwei lyu: natural image statisticszukun
 
Lecture9 camera calibration
Lecture9 camera calibrationLecture9 camera calibration
Lecture9 camera calibrationzukun
 
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 visionzukun
 
Modern features-part-4-evaluation
Modern features-part-4-evaluationModern features-part-4-evaluation
Modern features-part-4-evaluationzukun
 
Modern features-part-3-software
Modern features-part-3-softwareModern features-part-3-software
Modern features-part-3-softwarezukun
 
Modern features-part-2-descriptors
Modern features-part-2-descriptorsModern features-part-2-descriptors
Modern features-part-2-descriptorszukun
 
Modern features-part-1-detectors
Modern features-part-1-detectorsModern features-part-1-detectors
Modern features-part-1-detectorszukun
 
Modern features-part-0-intro
Modern features-part-0-introModern features-part-0-intro
Modern features-part-0-introzukun
 
Lecture 02 internet video search
Lecture 02 internet video searchLecture 02 internet video search
Lecture 02 internet video searchzukun
 
Lecture 01 internet video search
Lecture 01 internet video searchLecture 01 internet video search
Lecture 01 internet video searchzukun
 
Lecture 03 internet video search
Lecture 03 internet video searchLecture 03 internet video search
Lecture 03 internet video searchzukun
 
Icml2012 tutorial representation_learning
Icml2012 tutorial representation_learningIcml2012 tutorial representation_learning
Icml2012 tutorial representation_learningzukun
 
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 visionzukun
 
Gephi tutorial: quick start
Gephi tutorial: quick startGephi tutorial: quick start
Gephi tutorial: quick startzukun
 
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 analysiszukun
 
Object recognition with pictorial structures
Object recognition with pictorial structuresObject recognition with pictorial structures
Object recognition with pictorial structureszukun
 
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
 

More from 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
 

Lecture09

  • 1. Robert Collins CSE486, Penn State Lecture 09: Stereo Algorithms
  • 2. Robert Collins CSE486, Penn State Recall: Simple Stereo System Y Z (X,Y,Z) z left y camera located at ( , ) z (0,0,0) y ( , ) x right camera Tx located at x (Tx,0,0) Image coords of point (X,Y,Z) Left Camera: X Right Camera: Camps, PSU
  • 3. Robert Collins CSE486, Penn State Recall: Stereo Disparity Left camera Right camera Stereo Disparity baseline depth disparity Important equation!
  • 4. Robert Collins CSE486, Penn State Recall: Stereo Disparity Left camera Right camera depth Note: Depth and stereo disparity are disparity inversely proportional Important equation!
  • 5. Robert Collins CSE486, Penn State Stereo Example Left Image Right Image From Middlebury stereo evaluation page http://www.middlebury.edu/stereo/
  • 6. Robert Collins CSE486, Penn State Stereo Example Left image Disparity values (0-64) Right image Note how disparity is larger (brighter) for closer surfaces.
  • 7. Robert Collins CSE486, Penn State Computing Disparity • Correspondence Problem: – Determining which pixel in the right image corresponds to each pixel in the left image. – Disp = x_coord(left) - x_coord(right) Recall our discussion of computing correspondences of image patches ( Lecture 7 ). SSD - sum of squared difference measure NCC - normalized cross correlation measure Camps, PSU
  • 8. Robert Collins CSE486, Penn State Epipolar Constraint Important Concept: For stereo matching, we don’t have to search the whole 2D right image for a corresponding point. The “epipolar constraint” reduces the search space to a one-dimensional line.
  • 9. Robert Collins CSE486, Penn State Recall : Simple Stereo System P z Left camera y z y Right camera x Epipolar line Tx x Same Y Coord!
  • 10. Robert Collins CSE486, Penn State Matching using Epipolar Lines Left Image Right Image For a patch in left image Compare with patches along same row in right image Match Score Values
  • 11. Robert Collins CSE486, Penn State Matching using Epipolar Lines Left Image Right Image Select patch with highest match score. Repeat for all pixels in Match Score Values left image.
  • 12. Robert Collins CSE486, Penn State Example: 5x5 windows NCC match score Computed disparities Ground truth Black pixels: bad disparity values, or no matching patch in right image
  • 13. Robert Collins CSE486, Penn State Occlusions: No matches Left image Right image
  • 14. Robert Collins CSE486, Penn State Effects of Patch Size 5x5 patches 11x11patches Smoother in some areas Loss of finer details
  • 15. Robert Collins Adding Inter-Scanline Consistency CSE486, Penn State So far, each left image patch has been matched independently along the right epipolar line. This can lead to errors. We would like to enforce some consistency among matches in the same row (scanline).
  • 16. Robert Collins CSE486, Penn State Disparity Space Image First we introduce the concept of DSI. The DSI for one row represents pairwise match scores between patches along that row in the left and right image. Pixels along left scanline Pixel i C(i,j) = Match score for patch centered Pixels along right scanline at left pixel i with patch centered at right pixel j. Pixel j
  • 17. Robert Collins CSE486, Penn State Disparity Space Image (DSI) Left Image Right Image Dissimilarity Values (1-NCC) or SSD
  • 18. Robert Collins CSE486, Penn State Disparity Space Image (DSI) Left Image Right Image Dissimilarity Values (1-NCC) or SSD
  • 19. Robert Collins CSE486, Penn State Disparity Space Image (DSI) Left Image Right Image Dissimilarity Values (1-NCC) or SSD
  • 20. Robert Collins CSE486, Penn State Disparity Space Image (DSI) Left Image DSI Enter each vector of match scores as a column in the DSI Dissimilarity Values
  • 21. Robert Collins CSE486, Penn State Disparity Space Image Left scanline Right scanline
  • 22. Robert Collins CSE486, Penn State Disparity Space Image Left scanline Invalid entries due to constraint that disparity <= high value 64 in this case) Right scanline Invalid entries due to constraint that disparity >= low value (0 in this case)
  • 23. Robert Collins CSE486, Penn State Disparity Space Image N cols in left scanline If we rearrange the diagonal band of valid values into a M cols in right scanline rectangular array (in this case of size 64 x N), that is what is traditionally known as the DSI However, I’m going to keep the full image around, including invalid values (I think it is easier to understand the pixel coordinates involved) coordinate in left scanline (e.g. N) Disparity Disparity Space Image (e.g. 64)
  • 24. Robert Collins CSE486, Penn State DSI and Scanline Consistency Assigning disparities to all pixels in left scanline now amounts to finding a connected path through the DSI Start End
  • 25. Robert Collins CSE486, Penn State Lowest Cost Path We would like to choose the “best” path. Want one with lowest “cost” (Lowest sum of dissimilarity scores along the path) ? ? ?
  • 26. Robert Collins CSE486, Penn State Constraints on Path It is common to impose an ordering constraint on the path. Intuitively, the path is not allowed to “double back” on itself.
  • 27. Robert Collins CSE486, Penn State Ordering Constraint A D B C A B C ABCD D ABCD DABC ABCD Ordering constraint… …and its failure
  • 28. Robert Collins CSE486, Penn State Dealing with Occlusions Left scanline Right scanline … …
  • 29. Robert Collins CSE486, Penn State Dealing with Occlusions Left scanline Right scanline … … Match Match Occluded from Match Occluded from right scanline left scanline
  • 30. Robert Collins CSE486, Penn State An Optimal Scanline Strategy • We want to find best path, taking into account ordering constraint and the possibility of occlusions. Algorithm we will discuss now is from Cox, Hingorani, Rao, Maggs, “A Maximum Likelihood Stereo Algorithm,” Computer Vision and Image Understanding, Vol 63(3), May 1996, pp.542-567.
  • 31. Robert Collins CSE486, Penn State Cox et.al. Stereo Matching Occluded i-1,j-1 i-1,j from right match Occluded match Occluded from left from left i,j-1 Occluded i,j Three cases: from right – Matching patches. Cost = dissimilarity score – Occluded from right. Cost is some constant value. – Occluded from left. Cost is some constant value. C(i,j)= min([ C(i-1,j-1) + dissimilarity(i,j) C(i-1,j) + occlusionConstant, C(i,j-1) + occlusionConstant]);
  • 32. Robert Collins CSE486, Penn State Cox et.al. Stereo Matching Start Recap: want to find lowest cost path from upper left to lower right of DSI image. At each point on the path we have three choices: step left, step down, step diagonally. End Each choice has a well-defined cost associated with it. This problem just screams out for Dynamic Programming! (which, indeed, is how Cox et.al. solve the problem)
  • 33. Robert Collins CSE486, Penn State Real Scanline Example DSI DP cost matrix (cost of optimal path from each point to END) Every pixel in left column now is marked with either a disparity value, or an occlusion label. Proceed for every scanline in left image.
  • 34. Robert Collins CSE486, Penn State Example Result of DP alg Result without DP (independent pixels) Result of DP alg. Black pixels = occluded.
  • 35. Robert Collins CSE486, Penn State Occlusion Filling Simple trick for filling in gaps caused by occlusion. = left occluded Fill in left occluded pixels with value from the nearest valid pixel preceding it in the scanline. Similarly, for right occluded, look for valid pixel to the right.
  • 36. Robert Collins CSE486, Penn State Example Result of DP alg with occlusion filling.
  • 37. Robert Collins CSE486, Penn State Example Result of DP alg with occlusion filling. Result without DP (independent pixels)
  • 38. Robert Collins CSE486, Penn State Example Result of DP alg with occlusion filling. Ground truth
  • 39. Robert Collins CSE486, Penn State www.middlebury.edu/stereo/
  • 40. Robert Collins CSE486, Penn State State-of-the-Art Results Algorithm Results Ground truth J. Sun, Y. Li, S.B. Kang, and H.-Y. Shum. “Symmetric stereo matching for occlusion handling”. IEEE Conference on Computer Vision and Pattern Recognition, June 2005.