Homework 1 (Due Oct-11-00)

Implement and experiment with "Lucas-Kanade".

If you use matlab do following steps:


Lucas Kanade Summary (+ more help for matlab)

Step 0 (Initialization):
Label in the first image of your sequence (Image F) the region of interest (ROI). Either pick a center + some rectangular area with imagesc(im); xy = ginput(1) or choose an arbitrary ROI shape with imagesc(im); roi = double(roipoly);

In order to get all the indices of the region of interest, you can use inds = find(roi); . For example to sum over all Fx you can do sum(Fx(inds).^2) .

Fx(x,y) is the spatial gradient along the x-axis of image F at location x,y.

Fy(x,y) is the spatial gradient along the y-axis.

You can compute those gradients with the convolution we discussed in class. Pick a sigma (start with 3 for the first few iterations and then 1.5), and compute the convolution kernel. You can create that kernel by computing two vectors: gauss (the Gaussian function), and dgauss (the first derivative of the Gaussian function). Compute the outer product: kernel = gauss * dgauss' . Here's what I get if I do that for sigma = 2 and plot it in matlab with surf(kernel):

Convoluting an image with this kernel can be done using conv2() in matlab. You compute Fx with kernel=gauss * dgauss', and Fy with kernel=dgauss*gauss;

Ft (the temporal gradient of the image) can be computed in just subtracting G-F.

Step 3 (Re-warping). Rewarp G (or F). The rewarping should be done in sub-pixel accuracy. You can do that with interp2(... ,'cubic'); The XI and YI coordinates (as specified in matlab help) can be computed with: first use meshgrid() and then add to them the new U and V.

Step 4 If error to high, goto Step 1.


10/11/00:
Here's more help of example code that we discussed in class today:

How to generate a Gaussian and Gaussian derivative:
sig = 2;
% compute Gaussian density (95% falls in interval abs(x-mean) < 2*sig
x = floor(-3*sig):ceil(3*sig);
GAUSS = exp(-0.5*x.^2/sig^2); GAUSS = GAUSS/sum(GAUSS);
dGAUSS = -x.*GAUSS/sig^2;

How to convolute the image with the kernel:
kernel = GAUSS'*dGAUSS;
Fx = conv2(F,kernel,'same');

How to use interp2:
[rows,cols] = size(F);
[X,Y] = meshgrid(1:cols,1:rows);
Gwarp = interp2(X,Y,G,X+u,Y+v,'bilinear');

How to get rid of NaNs in a matrix:
inds = find(isnan(Gwarp)); Gwarp(inds)=0;


Here's an example quicktime of a successful track (see the small red cross?). Not every region in this image can be tracked for that long!

Quicktime


10/16/00:
Here is an example solution: hw1.m