function C=Cx(l,r)

    [sizex,sizey]=size(l);
    l=double(l);
    r=double(r);

    out=zeros(size(l));
    
    N=4;
    
    % the left block is NxN, upper left corner at (lx,ly)
    for (ly=1:3)%sizey-N-1)
        ly
        for (lx=1:sizex-N-1)
            
            % compute a bunch of correlations    
            for (p=1:sizex-N-1)
                C(p)=corr2(l(lx:lx+N,ly:ly+N),r(p:p+N,ly:ly+N));
            end
            
            %out(lx,ly)=
            [val,pos]=max(abs(C));
            
            out(lx,ly)=pos;
        end
    end
end