/normxcorr/trunk

To get this branch, use:
bzr branch http://suren.me/webbzr/normxcorr/trunk

« back to all changes in this revision

Viewing changes to dic_cpcorr3.m

  • Committer: Suren A. Chilingaryan
  • Date: 2009-12-09 13:00:50 UTC
  • Revision ID: csa@dside.dyndns.org-20091209130050-z27djqs8ed68fqnk
Complete elimination of cpcorr

Show diffs side-by-side

added added

removed removed

Lines of Context:
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 $
4
4
 
5
 
ncp = size(xyinput_in,1);
6
 
xyinput = xyinput_in; % initialize adjusted control points matrix
7
 
 
8
 
normxcorr_hw(hwid, 3, xyinput_in(:,1), xyinput_in(:,2));
9
 
normxcorr_hw(hwid, 12, input)
10
 
new_xy = normxcorr_hw(hwid, 4);
11
 
 
12
 
for icp = 1:ncp
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;
16
 
end
17
 
 
18
 
 
19
 
%{
20
 
% Just for validation purposes
21
5
for icp=1:ncp
22
6
    norm_cross_corr = double(normxcorr_hw(hwid, 11, icp, input));
23
7
 
24
8
    subpixel = true;
25
9
    [xpeak, ypeak, amplitude] = findpeak(norm_cross_corr,subpixel);
26
10
 
27
 
    %THRESHOLD = 0.5;
28
 
    %if (amplitude < THRESHOLD) 
29
 
        % low correlation, unable to adjust
30
 
    %    continue
31
 
    %end
32
 
    
33
 
    % offset found by cross correlation
34
11
    corr_offset = [ (xpeak-3*CORRSIZE-1) (ypeak-3*CORRSIZE-1) ];
35
12
 
36
13
    res(icp,1) = corr_offset(1);
37
14
    res(icp,2) = corr_offset(2);
38
 
 
39
 
    % eliminate any big changes in control points
40
 
    ind = find(abs(corr_offset) > (CORRSIZE-1));
41
 
    if ~isempty(ind)
42
 
        % peak of norxcorr2 not well constrained, unable to adjust
43
 
        continue
44
 
    end
45
 
 
46
 
    input_fractional_offset = xyinput(icp,:) - round(xyinput(icp,:)*PRECISION)/PRECISION;
47
 
    
48
 
    % adjust control point
49
 
    %xyinput(icp,:) = xyinput(icp,:) - input_fractional_offset - corr_offset + base(icp).base_fractional_offset;
50
15
end
51
16
 
 
17
new_xy = normxcorr_hw(hwid, 15);
 
18
 
52
19
%o1=res(500:510,:)'
53
20
%n1=new_xy(500:510,:)'
54
21
%o2=res(800:810,:)'
57
24
mydiff = abs(new_xy - res);
58
25
sum(mydiff)
59
26
max(mydiff)
60
 
%}