## page was renamed from Matlab {{{ %melog.m % ME/MC using four-step log search clear all; close all; load bus_frames frame; figure(1); frame1=frame(:,:,1); imagesc(frame1, [0,255]); colormap(gray); figure(2); frame2=frame(:,:,2); imagesc(frame2, [0,255]); colormap(gray); temp=size(frame); dimy=temp(1); %height of frame dimx=temp(2); %width of frame blockx=16; %block sizes blocky=16; srx=15; %size of search window +- sry=15; %intialize mvf matrix matchy=zeros(dimy/blocky,dimx/blockx); matchx=zeros(dimy/blocky,dimx/blockx); tic; for loopi=2:dimy/blocky-1, %loopi for loopj=2:dimx/blockx-1, ybound1=(loopi-1)*blocky+1; ybound2=loopi*blocky; xbound1=(loopj-1)*blockx+1; xbound2=loopj*blockx; %divide frame2 into blocks block=frame(ybound1:ybound2,xbound1:xbound2,2); %current block currentoffy=0; currentoffx=0; least_mse=inf; for steps=[2 4 8 16], % four step search for offoffy=-ceil(sry/steps):ceil(sry/steps):ceil(sry/steps), %offset vector for offoffx=-ceil(srx/steps):ceil(srx/steps):ceil(srx/steps), offy=currentoffy+offoffy; offx=currentoffx+offoffx; if (ybound1+offy>=1&ybound2+offy<=dimy... &xbound1+offx>=1&xbound2+offx<=dimx) prev_block=frame(ybound1+offy:ybound2+offy,xbound1+offx:xbound2+offx,1); current_mse=sum((prev_block(:)-block(:)).^2); if (current_mse