Normalized n-dimensional cross-correlation with a mask. Similar to normxcorrn, except takes an additional argument that specifies a figure ground mask for the T. That is T_fg must be of the same dimensions as T, with each entry being 0 or 1, where zero specifies regions to ignore (the ground) and 1 specifies interesting regions (the figure). Essentially T_fg specifies regions in T that are interesting and should be taken into account when doing normalized cross correlation. This allows for templates of arbitrary shape, and not just squares. Note: this function is approximately 3 times slower then normxcorr2 because it cannot use the trick of precomputing sums. INPUTS T - template to correlate to each window in A T_fg - figure/ground mask for the template A - matrix to correlate template to shape - [optional] 'valid', 'full', or 'same', see convn_fast help OUTPUTS C - correlation matrix EXAMPLE A=rand(50); B=rand(11); Bfg=ones(11); C1=normxcorrn_fg(B,Bfg,A); C2=normxcorr2(B,A); figure(1); im(C1); figure(2); im(C2); figure(3); im(abs(C1-C2)); DATESTAMP 29-Sep-2005 2:00pm See also NORMXCORRN