Clear Filters
Clear Filters

normalized cross-correlation for analytic signals

2 views (last 30 days)
I am trying to write a function for template matching using normalized cross-correlation. The normxcorr2 function seems to be an ideal solution but it does not accept non-real template and it returns only double result:
??? Error using ==> iptcheckinput Function NORMXCORR2 expected its first input, T, to be real.
Error in ==> normxcorr2>ParseInputs at 242 iptcheckinput(T,{'logical','numeric'},{'real','nonsparse','2d','finite'},mfilename,'T',1)
Error in ==> normxcorr2 at 61 [T, A] = ParseInputs(varargin{:});
Unfortunately my data are 2D analytic signals and to find the best match for the template I should use the zero crossing of the normalized cross-correlation (complex) phase in the vicinity of the maximum of the normalized cross-correlation (complex) magnitude.
Is it possible to slightly modify the normxcorr2 function so that it will accept complex images? Or the best solution is to use the xcorr2 function, however then abs(xcorr2) will not be normalized.

Answers (1)

Sean de Wolski
Sean de Wolski on 2 Dec 2011
You could perhaps normalize xcorr2 by dividing by the product of the standard deviations. I'd recommend against trying to modify normxcorr2.
  1 Comment
BLP
BLP on 2 Dec 2011
Thanks for the fast response. I do have one more question. As far I understand when normxcorr2 function do the calculations in the space domain the corss-correlation is calculated using not xcorr2 but conv2 function which works well for complex numbers. I guess, what is calculated further is the normalization. In what is conv2 better xcorr2?

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!