bzr branch
http://suren.me/webbzr/normxcorr/trunk
2
by Suren A. Chilingaryan
Support for different optimization modes |
1 |
function C = dic_normxcorr2(OPTIMIZE, hwid, icp, T, base, sum_T, denom_T) |
2 |
% Copyright 1993-2004 The MathWorks, Inc.
|
|
3 |
% $Revision: 1.12.4.6 $ $Date: 2004/10/20 17:54:20 $
|
|
4 |
||
5 |
% We normalize the cross correlation to get correlation coefficients using
|
|
6 |
% the definition of Haralick and Shapiro, Volume II (p. 317), generalized
|
|
7 |
% to two-dimensions.
|
|
8 |
||
9 |
[m n] = size(T); |
|
10 |
mn = m*n; |
|
11 |
||
12 |
outsize = size(base.sub_base_fft); |
|
13 |
||
14 |
if (OPTIMIZE > 1) |
|
15 |
FT = fft2_cuda(double(rot90(T,2)),outsize(1),outsize(2)); |
|
16 |
xcorr_TA = real(ifft2_cuda(FT .* base.sub_base_fft)); |
|
17 |
else
|
|
18 |
FT = fft2(double(rot90(T,2)),outsize(1),outsize(2)); |
|
19 |
xcorr_TA = real(ifft2(FT .* base.sub_base_fft)); |
|
20 |
end
|
|
21 |
||
22 |
denom = denom_T*base.denom_A; |
|
23 |
||
24 |
numerator = (xcorr_TA - base.local_sum_A*sum_T/mn ) / (mn-1); |
|
25 |
||
26 |
i_nonzero = base.i_nonzero; |
|
27 |
||
28 |
% We know denom_T~=0 from input parsing;
|
|
29 |
% so denom is only zero where denom_A is zero, and in
|
|
30 |
% these locations, C is also zero.
|
|
31 |
C = zeros(size(numerator)); |
|
32 |
C(i_nonzero) = numerator(i_nonzero) ./ denom(i_nonzero); |