## Copyright (C) 2000 Dave Cogdell ## Copyright (C) 2000 Paul Kienzle ## Copyright (C) 2012 CarnĂŤ Draug ## Copyright (C) 2014 Benjamin Eltzner ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . function c = xcorr2coeff_alt (a, b) %%%%% as lines 69-71 %%%%% [ma,na] = size(a); [mb,nb] = size(b); c = conv2 (a, conj (b (mb:-1:1, nb:-1:1))); %%%%% %%%%% insert this instead of lines 94-98 %%%%% a = double (a); b = double (b); b = b.-mean2(b); c = conv2 (a, conj (b (mb:-1:1, nb:-1:1))); means_a = conv2 (a, (ones (size (b))) ./ (mb*nb)); squares_a = conv2 (a.^2, ones (size (b))); a = squares_a .- (mb*nb) .* means_a.^2; b = sumsq (b(:)); c(:,:) = c(:,:) ./ sqrt (a(:,:) * b); c(isnan(c)) = 0; %%%%%