Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computational Photography: Image Registration Jinxiang Chai.

Similar presentations


Presentation on theme: "Computational Photography: Image Registration Jinxiang Chai."— Presentation transcript:

1 Computational Photography: Image Registration Jinxiang Chai

2 Review Image warping Image morphing

3 Image Warping Warping function - similarity, affine, projective etc

4 Image Warping Warping function - similarity, affine, projective etc Image warping - forward warping and two-pass 1D warping - backward warping x y u v S(x,y) T(u,v) forward Inverse

5 Image Warping Warping function - similarity, affine, projective etc Image warping - forward warping and two-pass 1D warping - backward warping Resampling filter - point sampling - bilinear filter x y u v S(x,y) T(u,v) forward Inverse

6 Image Morphing Point based image morphing Vector based image morphing

7 Image Registration Image warping: given h and f, compute g g(x) = f(h(x)) h f g? Image registration: given f and g, compute h h? f g

8 Why Image Registration? Lots of uses –Correct for camera jitter (stabilization)

9 Why Image Registration? Lots of uses –Correct for camera jitter (stabilization) –Align images (mosaics)

10 Why Image Registration? Lots of uses –Correct for camera jitter (stabilization) –Align images (mosaics) –View morphing

11 Why Image Registration? Lots of uses –Correct for camera jitter (stabilization) –Align images (mosaics) –View morphing –Special effects

12 Why Image Registration? Lots of uses –Correct for camera jitter (stabilization) –Align images (mosaics) –View morphing –Special effects –Medical image registration

13 Why Image Registration? Lots of uses –Correct for camera jitter (stabilization) –Align images (mosaics) –View morphing –Special effects –Medical image registration –Image based modeling/rendering –Etc.

14 Image Registration How do we align two images automatically? Two broad approaches: –Feature-based alignment Find a few matching features in both images compute alignment –Direct (pixel-based) alignment Search for alignment where most pixels agree

15 Outline Image registration - feature-based approach - pixel-based approach

16 Required Readings Section 6.1 (Szeliski book) Section 8.1.3 (Szeliski book) Section 8.2 (Szeliski book) Section 8.4 (Szeliski book)

17 Outline Image registration - feature-based approach - pixel-based approach

18 Feature-based Alignment 1.Find a few important features (aka Interest Points) 2.Match them across two images 3.Compute image transformation function h

19 Feature-based Alignment 1.Find a few important features (aka Interest Points) 2.Match them across two images 3.Compute image transformation function h How to choose features –Choose only the points (“features”) that are salient, i.e. likely to be there in the other image –How to find these features?

20 Feature-based Alignment 1.Find a few important features (aka Interest Points) 2.Match them across two images 3.Compute image transformation function h How to choose features –Choose only the points (“features”) that are salient, i.e. likely to be there in the other image –How to find these features? windows where has two large eigenvalues Harris Corner detector

21 Feature Detection -Two images taken at the same place with different angles - Projective transformation H 3X3

22 Feature Matching ? -Two images taken at the same place with different angles - Projective transformation H 3X3

23 Feature Matching ? -Two images taken at the same place with different angles - Projective transformation H 3X3 How do we match features across images? Any criterion?

24 Feature Matching ? -Two images taken at the same place with different angles - Projective transformation H 3X3 How do we match features across images? Any criterion?

25 Feature Matching Intensity/Color similarity –The intensity of pixels around the corresponding features should have similar intensity

26 Feature Matching Intensity/Color similarity –The intensity of pixels around the corresponding features should have similar intensity –Cross-correlation, SSDCross-correlationSSD

27 Feature Matching Intensity/Color similarity –The intensity of pixels around the corresponding features should have similar intensity –Cross-correlation, SSDCross-correlationSSD Distance constraint –The displacement of features should be smaller than a given threshold

28 Feature-space Outlier Rejection bad Good

29 Feature-space Outlier Rejection Can we now compute H 3X3 from the blue points?

30 Feature-space Outlier Rejection Can we now compute H 3X3 from the blue points? –No! Still too many outliers…

31 Feature-space Outlier Rejection Can we now compute H 3X3 from the blue points? –No! Still too many outliers… –What can we do?

32 Feature-space Outlier Rejection Can we now compute H 3X3 from the blue points? –No! Still too many outliers… –What can we do? Robust estimation!

33 Robust EstimationRobust Estimation: A Toy Example How to fit a line based on a set of 2D points?

34 Robust EstimationRobust Estimation: A Toy Example How to fit a line based on a set of 2D points? RANSACRANSAC: an iterative method to estimate parameters of a mathematical model from a set of observed data which contains outliersoutliers

35 RANSACRANSAC: RANdom SAmple Consensus Objective Robust fit of model to data set S which contains outliers Algorithm (i)Randomly select a sample of s data points from S and instantiate the model from this subset. (ii)Determine the set of data points S i which are within a distance threshold t of the model. The set S i is the consensus set of samples and defines the inliers of S. (iii)If the subset of S i is greater than some threshold T, re- estimate the model using all the points in S i and terminate (iv)If the size of S i is less than T, select a new subset and repeat the above. (v)After N trials the largest consensus set S i is selected, and the model is re-estimated using all the points in the subset S i

36 RANSAC Repeat M times: –Sample minimal number of matches to estimate two view relation (affine, perspective, etc). –Calculate number of inliers or posterior likelihood for relation. –Choose relation to maximize number of inliers.

37 RANSAC Line Fitting Example Task: Estimate best line

38 RANSAC Line Fitting Example Sample two points

39 RANSAC Line Fitting Example Fit Line

40 RANSAC Line Fitting Example Total number of points within a threshold of line.

41 RANSAC Line Fitting Example Repeat, until get a good result

42 RANSAC Line Fitting Example Repeat, until get a good result

43 RANSAC Line Fitting Example Repeat, until get a good result

44 How Many Samples? Choose N so that, with probability p, at least one random sample is free from outliers. e.g. p=0.99 proportion of outliers e s5%10%20%25%30%40%50% 2235671117 33479111935 435913173472 54612172657146 64716243797293 748203354163588 8592644782721177

45 How Many Samples? Choose N so that, with probability p, at least one random sample is free from outliers. e.g. p=0.99 proportion of outliers e s5%10%20%25%30%40%50% 2235671117 33479111935 435913173472 54612172657146 64716243797293 748203354163588 8592644782721177 Affine transform

46 How Many Samples? Choose N so that, with probability p, at least one random sample is free from outliers. e.g. p=0.99 proportion of outliers e s5%10%20%25%30%40%50% 2235671117 33479111935 435913173472 54612172657146 64716243797293 748203354163588 8592644782721177 Projective transform

47 RANSAC for Estimating Projective Transformation RANSAC loop: 1.Select four feature pairs (at random) 2.Compute the transformation matrix H (exact) 3.Compute inliers where SSD(p i ’, H p i ) < ε 4.Keep largest set of inliers 5.Re-compute least-squares H estimate on all of the inliers

48 RANSAC

49 Feature-based Registration Works for small or large motion Model the motion within a patch or whole image using a parametric transformation model

50 Feature-based Registration Works for small or large motion Model the motion within a patch or whole image using a parametric transformation model How to deal with motions that cannot be described by a small number of parameters?

51 Outline Image registration - feature-based approach - pixel-based approach

52 Direct (pixel-based) Alignment : Optical flow Will start by estimating motion of each pixel separately Then will consider motion of entire image

53 Problem Definition: Optical FlowOptical Flow How to estimate pixel motion from image H to image I?

54 Problem Definition: Optical FlowOptical Flow How to estimate pixel motion from image H to image I? –Solve pixel correspondence problem given a pixel in H, look for nearby pixels of the same color in I

55 Problem Definition: Optical FlowOptical Flow How to estimate pixel motion from image H to image I? –Solve pixel correspondence problem given a pixel in H, look for nearby pixels of the same color in I Key assumptions –color constancy: a point in H looks the same in I For grayscale images, this is brightness constancy –small motion: points do not move very far This is called the optical flow problem

56 Optical Flow Constraints Let’s look at these constraints more closely –brightness constancy: Q: what’s the equation?

57 Optical Flow Constraints Let’s look at these constraints more closely –brightness constancy: Q: what’s the equation? H(x,y) - I(x+u,v+y) = 0

58 Optical Flow Constraints Let’s look at these constraints more closely –brightness constancy: Q: what’s the equation? –small motion: (u and v are less than 1 pixel) suppose we take the Taylor series expansion of I: H(x,y) - I(x+u,v+y) = 0

59 Optical Flow Constraints Let’s look at these constraints more closely –brightness constancy: Q: what’s the equation? –small motion: (u and v are less than 1 pixel) suppose we take the Taylor series expansion of I: H(x,y) - I(x+u,v+y) = 0

60 Optical Flow Equation Combining these two equations

61 Optical Flow Equation Combining these two equations

62 Optical Flow Equation Combining these two equations

63 Optical Flow Equation Combining these two equations

64 Optical Flow Equation Combining these two equations In the limit as u and v go to zero, this becomes exact

65 Optical Flow Equation How many unknowns and equations per pixel?

66 Optical Flow Equation How many unknowns and equations per pixel? Intuitively, what does this constraint mean?

67 Optical Flow Equation How many unknowns and equations per pixel? Intuitively, what does this constraint mean? –The component of the flow in the gradient direction is determined –The component of the flow parallel to an edge is unknown

68 Optical Flow Equation How many unknowns and equations per pixel? Intuitively, what does this constraint mean? –The component of the flow in the gradient direction is determined –The component of the flow parallel to an edge is unknown

69 Aperture Problem

70 Stripes moved upwards 6 pixels Stripes moved left 5 pixels

71 Aperture Problem Stripes moved upwards 6 pixels Stripes moved left 5 pixels How to address this problem?

72 Solving the Aperture Problem How to get more equations for a pixel? –Basic idea: impose additional constraints most common is to assume that the flow field is smooth locally one method: pretend the pixel’s neighbors have the same (u,v) –If we use a 5x5 window, that gives us 25 equations per pixel!

73 RGB Version How to get more equations for a pixel? –Basic idea: impose additional constraints most common is to assume that the flow field is smooth locally one method: pretend the pixel’s neighbors have the same (u,v) –If we use a 5x5 window, that gives us 25 equations per pixel!

74 Lukas-Kanade Flow Prob: we have more equations than unknowns

75 Lukas-Kanade Flow Prob: we have more equations than unknowns Solution: solve least squares problem

76 Lukas-Kanade Flow Prob: we have more equations than unknowns Solution: solve least squares problem –minimum least squares solution given by solution (in d) of:

77 Lukas-Kanade Flow –The summations are over all pixels in the K x K window –This technique was first proposed by Lukas & Kanade (1981)

78 Lukas-Kanade Flow When is this Solvable? A T A should be invertible A T A should not be too small due to noise –eigenvalues 1 and 2 of A T A should not be too small A T A should be well-conditioned – 1 / 2 should not be too large ( 1 = larger eigenvalue)

79 Edge Bad for motion estimation - large  1, small 2

80 Low Texture Region Bad for motion estimation: - gradients have small magnitude - small  1, small 2

81 High Textured Region Good for motion estimation: - gradients are different, large magnitudes - large  1, large 2

82 Observation This is a two image problem BUT –Can measure sensitivity by just looking at one of the images! –This tells us which pixels are easy to track, which are hard very useful later on when we do feature tracking...

83 Errors in Lucas-Kanade What are the potential causes of errors in this procedure? –Suppose A T A is easily invertible –Suppose there is not much noise in the image

84 Errors in Lucas-Kanade What are the potential causes of errors in this procedure? –Suppose A T A is easily invertible –Suppose there is not much noise in the image When our assumptions are violated –Brightness constancy is not satisfied –The motion is not small –A point does not move like its neighbors window size is too large what is the ideal window size?

85 Iterative Refinement Iterative Lukas-Kanade Algorithm 1.Estimate velocity at each pixel by solving Lucas- Kanade equations 2.Warp H towards I using the estimated flow field - use image warping techniques 3.Repeat until convergence

86 Revisiting the Small Motion Assumption Is this motion small enough? –Probably not—it’s much larger than one pixel (2 nd order terms dominate) –How might we solve this problem?

87 Reduce the Resolution!

88 image I image H Gaussian pyramid of image HGaussian pyramid of image I image I image H u=10 pixels u=5 pixels u=2.5 pixels u=1.25 pixels Coarse-to-fine Optical Flow Estimation

89 image I image J Gaussian pyramid of image HGaussian pyramid of image I image I image H Coarse-to-fine Optical Flow Estimation run iterative L-K Upsample & warp......

90 Beyond Translation So far, our patch can only translate in (u,v) What about other motion models? –rotation, affine, perspective

91 Warping Function w(x;p) describes the geometric relationship between two images: Template Image H(x)Input Image I(x) x

92 Warping Functions Translation: Affine: Perspective:

93 Image Registration Find the warping parameter p that minimizes the intensity difference between template image and the warped input image

94 Image Registration Find the warping parameter p that minimizes the intensity difference between template image and the warped input image Mathematically, we can formulate this as an optimization problem:

95 Image Registration Find the warping parameter p that minimizes the intensity difference between template image and the warped input image Mathematically, we can formulate this as an optimization problem: The above problem can be solved by many optimization algorithm: - Steepest descentSteepest descent - Gauss-newtonGauss-newton - Levenberg-marquardt, etc. Levenberg-marquardt

96 Image Registration Find the warping parameter p that minimizes the intensity difference between template image and the warped input image Mathematically, we can formulate this as an optimization problem: The above problem can be solved by many optimization algorithm: - Steepest descent - Gauss-newton - Levenberg-marquardt, etc

97 Image Registration Mathematically, we can formulate this as an optimization problem:

98 Image Registration Mathematically, we can formulate this as an optimization problem: Taylor series expansion Similar to optical flow:

99 Image Registration Mathematically, we can formulate this as an optimization problem: Taylor series expansion Similar to optical flow:

100 Image Registration Mathematically, we can formulate this as an optimization problem: Taylor series expansion Image gradient Similar to optical flow:

101 Image Registration Mathematically, we can formulate this as an optimization problem: Taylor series expansion Image gradient translation affine …… Similar to optical flow: Jacobian matrix

102 Gauss-newton Optimization Rearrange

103 Gauss-newton Optimization Rearrange

104 Gauss-newton Optimization Rearrange Ab

105 Gauss-newton Optimization Rearrange A ATbATb b (A T A) -1

106 Lucas-Kanade Registration Initialize p=p 0 : Iterate: 1. Warp I with w(x;p) to compute I(w(x;p))

107 Lucas-Kanade Registration Initialize p=p 0 : Iterate: 1. Warp I with w(x;p) to compute I(w(x;p)) 2. Compute the error image

108 Lucas-Kanade Registration Initialize p=p 0 : Iterate: 1. Warp I with w(x;p) to compute I(w(x;p)) 2. Compute the error image 3. Warp the gradient with w(x;p)

109 Lucas-Kanade Registration Initialize p=p 0 : Iterate: 1. Warp I with w(x;p) to compute I(w(x;p)) 2. Compute the error image 3. Warp the gradient with w(x;p) 4. Evaluate the Jacobian at (x;p)

110 Lucas-Kanade Registration Initialize p=p 0 : Iterate: 1. Warp I with w(x;p) to compute I(w(x;p)) 2. Compute the error image 3. Warp the gradient with w(x;p) 4. Evaluate the Jacobian at (x;p) 5. Compute the

111 Lucas-Kanade Registration Initialize p=p 0 : Iterate: 1. Warp I with w(x;p) to compute I(w(x;p)) 2. Compute the error image 3. Warp the gradient with w(x;p) 4. Evaluate the Jacobian at (x;p) 5. Compute the 6. Update the parameters

112 Lucas-Kanade Algorithm Iteration 1: H(x ) I(w(x;p)) H(x)-I(w(x;p))

113 Lucas-Kanade Algorithm Iteration 2: H(x ) I(w(x;p)) H(x)-I(w(x;p))

114 Lucas-Kanade Algorithm Iteration 3: H(x ) I(w(x;p)) H(x)-I(w(x;p))

115 Lucas-Kanade Algorithm Iteration 4: H(x ) I(w(x;p)) H(x)-I(w(x;p))

116 Lucas-Kanade Algorithm Iteration 5: H(x ) I(w(x;p)) H(x)-I(w(x;p))

117 Lucas-Kanade Algorithm Iteration 6: H(x ) I(w(x;p)) H(x)-I(w(x;p))

118 Lucas-Kanade Algorithm Iteration 7: H(x ) I(w(x;p)) H(x)-I(w(x;p))

119 Lucas-Kanade Algorithm Iteration 8: H(x ) I(w(x;p)) H(x)-I(w(x;p))

120 Lucas-Kanade Algorithm Iteration 9: H(x ) I(w(x;p)) H(x)-I(w(x;p))

121 Lucas-Kanade Algorithm Final result: H(x ) I(w(x;p)) H(x)-I(w(x;p))

122 Lucas-Kanade for Image Alignment Pros: –All pixels get used in matching –Can get sub-pixel accuracy (important for good mosaicing!) –Relatively fast and simple Cons: –Prone to local minima –Relative small movement


Download ppt "Computational Photography: Image Registration Jinxiang Chai."

Similar presentations


Ads by Google