Hi Sam, normxcorr2 computes an estimate of the computation time for spatial domain correlation vs. frequency domain. Whichever is the smallest wins.
You could save normxcorr2.m as a different name and then modify the code so that it always did one or the other. For example, to always use spatial domain, you can modify the xcorr2_fast function inside of normxcorr2 as follows
function cross_corr = xcorr2_fast(T,A)
T_size = size(T);
A_size = size(A);
outsize = A_size + T_size - 1;
cross_corr = conv2(rot90(T,2),A);
To only use the Fourier transform:
function cross_corr = xcorr2_fast(T,A)
T_size = size(T);
A_size = size(A);
outsize = A_size + T_size - 1;
cross_corr = freqxcorr(T,A,outsize);
Best Answer