function cory = correlation_matching(left, right,x,y) % This function creates a disparity map from a pair of stereo images. % Use left as reference. left = double(left); right = double(right); % Parameters based on a 419x419 grayscale image. w = 5; %pixels wide %x = 210; %fixed in the middle %y = 120; %about a third into the image fy = y; %limit = y+w lw = y-w; upr = y+w; k = 30; %iterations best = 0; for j = 0:k cum = 0; for i = lw:upr %buff(x,i) = left(x,i)*right(x,i+j); cum = cum + (left(x,i) - right(x,i+j))^2; end %y = y+1; if cum < best | best == 0 best = cum; besty = y+j; end end %buff best; y; cory = besty;