/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_local_sum.m

  • Committer: Suren A. Chilingaryan
  • Date: 2009-01-15 13:50:29 UTC
  • Revision ID: csa@dside.dyndns.org-20090115135029-wleapicg9a4593tp
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
%-------------------------------
 
2
% Function  local_sum
 
3
%
 
4
function local_sum_A = dic_local_sum(A,m,n)
 
5
 
 
6
% We thank Eli Horn for providing this code, used with his permission,
 
7
% to speed up the calculation of local sums. The algorithm depends on
 
8
% precomputing running sums as described in "Fast Normalized
 
9
% Cross-Correlation", by J. P. Lewis, Industrial Light & Magic.
 
10
% http://www.idiom.com/~zilla/Papers/nvisionInterface/nip.html
 
11
 
 
12
[mA,nA]=size(A);
 
13
 
 
14
B = [zeros(m,nA+2*n-1);
 
15
     zeros(mA,n) A zeros(mA,n-1);
 
16
     zeros(m-1,nA+2*n-1)];
 
17
s = cumsum(B,1);
 
18
c = s(1+m:end,:)-s(1:end-m,:);
 
19
s = cumsum(c,2);
 
20
local_sum_A = s(:,1+n:end)-s(:,1:end-n);