function xyinput = dic_cpcorr3(CORRSIZE, PRECISION, OPTIMIZE, hwid, ncp, input)
%   Copyright 1993-2004 The MathWorks, Inc.
%   $Revision: 1.16.4.4 $  $Date: 2004/10/20 17:54:13 $

for icp=1:ncp
    norm_cross_corr = double(normxcorr_hw(hwid, 11, icp, input));

    subpixel = true;
    [xpeak, ypeak, amplitude] = findpeak(norm_cross_corr,subpixel);

    corr_offset = [ (xpeak-3*CORRSIZE-1) (ypeak-3*CORRSIZE-1) ];

    res(icp,1) = corr_offset(1);
    res(icp,2) = corr_offset(2);
end

new_xy = normxcorr_hw(hwid, 15);

%o1=res(500:510,:)'
%n1=new_xy(500:510,:)'
%o2=res(800:810,:)'
%n2=new_xy(800:810,:)'

mydiff = abs(new_xy - res);
sum(mydiff)
max(mydiff)
