Calculate optical flow using Lucas & Kanade. Fast, parallel code. Note that the window of integration can either be a hard square window of radius win_n or it can be a soft 'gaussian' window with sigma win_sig. In general the soft window should be more accurate. INPUTS I1, I2 - input images to calculate flow between win_n - window radius for hard window (should be [] if win_sig is provided) win_sig - [optional] sigma for soft 'gauss' window (should be [] if win_n is provided) sigma - [optional] amount to smooth by (may be 0) thr - [optional] ABSOLUTE reliability threshold (min eigenvalue), [default: 3e-6] show - [optional] figure to use for display (no display if == 0) OUTPUTS Vx, Vy - x,y components of optical flow [Vx>0 -> flow is right, Vy>0 -> flow is down] reliab - reliability of optical flow in given window (cornerness of window) EXAMPLE % create square + translated square (B) + rotated square (C) A=zeros(50,50); A(16:35,16:35)=1; B=zeros(50,50); B(17:36,17:36)=1; C=imrotate(A,5,'bil','crop'); optflow_lucaskanade( A, B, [], 2, 2, 3e-6, 1 ); optflow_lucaskanade( A, C, [], 2, 2, 3e-6, 4 ); % compare on stored real images (of mice) load optflow_data; [Vx,Vy,reliab] = optflow_lucaskanade( I5A, I5B, [], 4, 1.2, 3e-6, 1 ); [Vx,Vy,reliab] = optflow_corr( I5A, I5B, 3, 5, 1.2, .01, 2 ); [Vx,Vy] = optflow_horn( I5A, I5B, 2, 3 ); DATESTAMP 29-Sep-2005 2:00pm See also OPTFLOW_HORN, OPTFLOW_CORR