Skip to Content
CSE559AComputer Vision (Lecture 21)

CSE559A Lecture 21

Continue on optical flow

The brightness constancy constraint

Ixu(x,y)+Iyv(x,y)+It=0I_x u(x,y) + I_y v(x,y) + I_t = 0

Given the gradients Ix,IyI_x, I_y and ItI_t, can we uniquely recover the motion (u,v)(u,v)?

  • Suppose (u,v)(u, v) satisfies the constraint: I(u,v)+It=0\nabla I \cdot (u,v) + I_t = 0
  • Then I(u+u,v+v)+It=0\nabla I \cdot (u+u', v+v') + I_t = 0 for any (u,v)(u', v') s.t. I(u,v)=0\nabla I \cdot (u', v') = 0
  • Interpretation: the component of the flow perpendicular to the gradient (i.e., parallel to the edge) cannot be recovered!

Aperture problem

  • The brightness constancy constraint is only valid for a small patch in the image
  • For a large motion, the patch may look very different

Consider the barber pole illusion

Estimating optical flow (Lucas-Kanade method)

  • Consider a small patch in the image
  • Assume the motion is constant within the patch
  • Then we can solve for the motion (u,v)(u, v) by minimizing the error:
Ixu(x,y)+Iyv(x,y)+It=0I_x u(x,y) + I_y v(x,y) + I_t = 0

How to get more equations for a pixel? Spatial coherence constraint: assume the pixel’s neighbors have the same (𝑢,𝑣) If we have 𝑛 pixels in the neighborhood, then we can set up a linear least squares system:

[Ix(x1,y1)Iy(x1,y1)Ix(xn,yn)Iy(xn,yn)][uv]=[It(x1,y1)It(xn,yn)]\begin{bmatrix} I_x(x_1, y_1) & I_y(x_1, y_1) \\ \vdots & \vdots \\ I_x(x_n, y_n) & I_y(x_n, y_n) \end{bmatrix} \begin{bmatrix} u \\ v \end{bmatrix} = -\begin{bmatrix} I_t(x_1, y_1) \\ \vdots \\ I_t(x_n, y_n) \end{bmatrix}

Lucas-Kanade flow

Let A=[Ix(x1,y1)Iy(x1,y1)Ix(xn,yn)Iy(xn,yn)]A= \begin{bmatrix} I_x(x_1, y_1) & I_y(x_1, y_1) \\ \vdots & \vdots \\ I_x(x_n, y_n) & I_y(x_n, y_n) \end{bmatrix}

b=[It(x1,y1)It(xn,yn)]b = \begin{bmatrix} I_t(x_1, y_1) \\ \vdots \\ I_t(x_n, y_n) \end{bmatrix}

d=[uv]d = \begin{bmatrix} u \\ v \end{bmatrix}

The solution is d=(AA)1Abd=(A^\top A)^{-1} A^\top b

Lucas-Kanade flow:

  • Find (u,v)(u,v) minimizing i(I(xi+u,yi+v,t)I(xi,yi,t1))2\sum_{i} (I(x_i+u,y_i+v,t)-I(x_i,y_i,t-1))^2
  • use Taylor approximation of I(xi+u,yi+v,t)I(x_i+u,y_i+v,t) for small shifts (u,v)(u,v) to obtain closed-form solution

Refinement for Lucas-Kanade

In some cases, the Lucas-Kanade method may not work well:

  • The motion is large (larger than a pixel)
  • A point does not move like its neighbors
  • Brightness constancy does not hold

Iterative refinement (for large motion)

Iterative Lukas-Kanade Algorithm

  1. Estimate velocity at each pixel by solving Lucas-Kanade equations
  2. Warp It towards It+1 using the estimated flow field
    • use image warping techniques
  3. Repeat until convergence

Iterative refinement is limited due to Aliasing

Coarse-to-fine refinement (for large motion)

  • Estimate flow at a coarse level
  • Refine the flow at a finer level
  • Use the refined flow to warp the image
  • Repeat until convergence

Lucas Kanade coarse-to-fine refinement

Representing moving images with layers (for a point may not move like its neighbors)

  • The image can be decomposed into a moving layer and a stationary layer
  • The moving layer is the layer that moves
  • The stationary layer is the layer that does not move

Lucas Kanade refinement with layers

SOTA models

2009

Start with something similar to Lucas-Kanade

  • gradient constancy
  • energy minimization with smoothing term
  • region matching
  • keypoint matching (long-range)

2015

Deep neural networks

  • Use a deep neural network to represent the flow field
  • Use synthetic data to train the network (floating chairs)

2023

GMFlow

use Transformer to model the flow field

Robust Fitting of parametric models

Challenges:

  • Noise in the measured feature locations
  • Extraneous data: clutter (outliers), multiple lines
  • Missing data: occlusions

Least squares fitting

Normal least squares fitting

y=mx+by=mx+b is not a good model for the data since there might be vertical lines

Instead we use total least squares

Line parametrization: ax+by=dax+by=d

(a,b)(a,b) is the unit normal to the line (i.e., a2+b2=1a^2+b^2=1) dd is the distance between the line and the origin Perpendicular distance between point (xi,yi)(x_i, y_i) and line ax+by=dax+by=d (assuming a2+b2=1a^2+b^2=1):

axi+byid|ax_i + by_i - d|

Objective function:

E=i=1n(axi+byid)2E = \sum_{i=1}^n (ax_i + by_i - d)^2

Solve for dd first: d=axˉ+byˉd =a\bar{x}+b\bar{y} Plugging back in:

E=i=1n(a(xixˉ)+b(yiyˉ))2=[x1xˉy1yˉxnxˉynyˉ](ab)2E = \sum_{i=1}^n (a(x_i-\bar{x})+b(y_i-\bar{y}))^2 = \left\|\begin{bmatrix}x_1-\bar{x}&y_1-\bar{y}\\\vdots&\vdots\\x_n-\bar{x}&y_n-\bar{y}\end{bmatrix}\begin{pmatrix}a\\b\end{pmatrix}\right\|^2

We want to find NN that minimizes UN2\|UN\|^2 subject to N2=1\|N\|^2= 1 Solution is given by the eigenvector of UUU^\top U associated with the smallest eigenvalue

Drawbacks:

  • Sensitive to outliers

Robust fitting

General approach: find model parameters 𝜃 that minimize

iρσ(r(xi;θ))\sum_{i} \rho_{\sigma}(r(x_i;\theta))

r(xi;θ)r(x_i;\theta): residual of xix_i w.r.t. model parameters θ\theta ρσ\rho_{\sigma}: robust function with scale parameter σ\sigma, e.g., ρσ(u)=u2σ2+u2\rho_{\sigma}(u)=\frac{u^2}{\sigma^2+u^2}

Nonlinear optimization problem that must be solved iteratively

  • Least squares solution can be used for initialization
  • Scale of robust function should be chosen carefully

Drawbacks:

  • Need to manually choose the robust function and scale parameter

RANSAC

Voting schemes

Random sample consensus: very general framework for model fitting in the presence of outliers

Outline:

  • Randomly choose a small initial subset of points
  • Fit a model to that subset
  • Find all inlier points that are “close” to the model and reject the rest as outliers
  • Do this many times and choose the model with the most inliers

Hough transform

Last updated on