/normxcorr/trunk

To get this branch, use:
bzr branch http://suren.me/webbzr/normxcorr/trunk
8 by Suren A. Chilingaryan
Complete elimination of cpcorr
1
function xyinput = dic_basecorr3(CORRSIZE, PRECISION, OPTIMIZE, hwid, base_points_x, base_points_y, base)
2
3
base_points_for(:,1)=reshape(base_points_x,[],1);
4
base_points_for(:,2)=reshape(base_points_y,[],1);
5
6
ncp = size(base_points_for, 1);
7
rects_base = dic_calc_rects(base_points_for,2*CORRSIZE,base);
8
9
n = 2*CORRSIZE + 1;
10
mn = n*n;
11
12
for icp = 1:ncp
13
    if isequal(rects_base(icp,3:4),[0 0])
14
	continue
15
    end
16
17
    sub_base = imcrop(base,rects_base(icp,:));
18
    
19
    if sum(sub_base(:)) == sub_base(1)*numel(sub_base)
20
	eid = sprintf('Images:%s:sameElementsInTemplate',mfilename);
21
	msg = 'The values of TEMPLATE cannot all be the same.';
22
	error(eid,'%s',msg);
23
    end
24
    
25
26
    double_sub_base = double(sub_base);
27
    local_sum_A = dic_local_sum(double_sub_base,n,n);
28
    local_sum_A2 = dic_local_sum(double_sub_base.*double_sub_base,n,n);
29
    denom_A = sqrt( max(( local_sum_A2 - (local_sum_A.^2)/mn ) / (mn-1), 0) );
30
    i_nonzero = find(denom_A~=0);
31
    normxcorr_hw(hwid, 2, icp, sub_base, single(local_sum_A), single(denom_A), uint16(i_nonzero));
32
end