1
function xyinput = dic_cpcorr(CORRSIZE, PRECISION, OPTIMIZE, hwid, base, xyinput_in, input)
1
function xyinput = dic_cpcorr3(CORRSIZE, PRECISION, OPTIMIZE, hwid, ncp, input)
2
2
% Copyright 1993-2004 The MathWorks, Inc.
3
3
% $Revision: 1.16.4.4 $ $Date: 2004/10/20 17:54:13 $
5
ncp = size(xyinput_in,1);
6
xyinput = xyinput_in; % initialize adjusted control points matrix
8
normxcorr_hw(hwid, 3, xyinput_in(:,1), xyinput_in(:,2));
9
normxcorr_hw(hwid, 12, input)
10
new_xy = normxcorr_hw(hwid, 4);
13
corr_offset = new_xy(icp,:);
14
input_fractional_offset = xyinput(icp,:) - round(xyinput(icp,:)*PRECISION)/PRECISION;
15
xyinput(icp,:) = xyinput(icp,:) - input_fractional_offset - corr_offset + base(icp).base_fractional_offset;
20
% Just for validation purposes
22
6
norm_cross_corr = double(normxcorr_hw(hwid, 11, icp, input));
25
9
[xpeak, ypeak, amplitude] = findpeak(norm_cross_corr,subpixel);
28
%if (amplitude < THRESHOLD)
29
% low correlation, unable to adjust
33
% offset found by cross correlation
34
11
corr_offset = [ (xpeak-3*CORRSIZE-1) (ypeak-3*CORRSIZE-1) ];
36
13
res(icp,1) = corr_offset(1);
37
14
res(icp,2) = corr_offset(2);
39
% eliminate any big changes in control points
40
ind = find(abs(corr_offset) > (CORRSIZE-1));
42
% peak of norxcorr2 not well constrained, unable to adjust
46
input_fractional_offset = xyinput(icp,:) - round(xyinput(icp,:)*PRECISION)/PRECISION;
48
% adjust control point
49
%xyinput(icp,:) = xyinput(icp,:) - input_fractional_offset - corr_offset + base(icp).base_fractional_offset;
17
new_xy = normxcorr_hw(hwid, 15);
52
19
%o1=res(500:510,:)'
53
20
%n1=new_xy(500:510,:)'
54
21
%o2=res(800:810,:)'