function corrpts=correspond(bmat,wind,thrs,inimage,bwinsize,lev)

for i=1:size(wind,1)
    windpts=wind(i,:);
    windmat=double(inimage(windpts(1,1)-bwinsize:windpts(1,1)+bwinsize, ...
            windpts(1,2)-bwinsize:windpts(1,2)+bwinsize));
    [cbmat,sbmat]=wavedec2(bmat,lev,'db1');
    [cwindmat,swindmat]=wavedec2(windmat,lev,'db1');
    fbmat=fft2(bmat);
    fwindmat=fft2(windmat);
    wcorr=sum(dot(cbmat,cwindmat))/sqrt(sum(dot(cbmat,cbmat))*sum(dot(cwindmat,cwindmat)));
    fcorr=sum(dot(fbmat,fwindmat))/sqrt(sum(dot(fbmat,fbmat))*sum(dot(fwindmat,fwindmat)));
    tempc(i,:) = [windpts,wcorr,fcorr];
end

maxcorr=max(max(tempc(:,3)));
if  maxcorr > thrs
    mcind = find(tempc(:,3)==maxcorr);
    mcind=mcind(1,1);
    corrpts = real(tempc(mcind,:));
else
    corrpts = zeros(1,4);
end