Normxcorr2 and xcorr2

30 ビュー (過去 30 日間)
richard
richard 2011 年 11 月 29 日
コメント済み: RITIKA MALIK 2022 年 6 月 30 日
Hi
I'm trying to perform a 2D autocorrelation using the two functions. The problem is that I am getting different results using the seemingly same functions. The help document although mentions that Normxcorr2 requires the size of the image to be larger than the template. Does this mean that normxcorr2 doesn't work for autocorrelation and returns incorrect results? I don't understand how a correlation function cannot work for autocorrelation. I need a normalized 2D autocorrelation and Normxcorr2 is getting me really confused. Any help will be really appreciated.
  1 件のコメント
RITIKA MALIK
RITIKA MALIK 2022 年 6 月 30 日
https://in.mathworks.com/matlabcentral/answers/95436-why-are-my-results-different-in-xcorr2-and-normxcorr2-in-matlab-7-7-r2008b#answer_104789

サインインしてコメントする。

回答 (2 件)

David Young
David Young 2011 年 11 月 29 日
The functions are not the same: normxcorr2 normalises (i.e. divides by the product of the local standard deviations) but xcorr2 does not.
EDIT: add
In addition, normxcorr2 subtracts the mean of the template before performing the multiplications. This changes the results greatly - for example, it can easily change the sign of some of the values. On top of this, when the functions are used for autocorrelation calculations, mean removal interacts with zero-padding of the arrays to change the results in quite hard-to-understand ways.
All the same, there's no question of normxcorr2 being unreliable. It just implements a different function to xcorr2. Which one of them does autocorrelation depends on how you define autocorrelation.
What you have to do is decide exactly what you want to compute and compare it to the equations given in the documentation for the functions. The terminology round autocorrelation/autocovariance isn't used consistently, so it is essential to look at the equations.
  2 件のコメント
richard
richard 2011 年 11 月 30 日
Thanks but I am well aware of that. I am getting different results that can't be explained by normalization and my key question is whether Normxcorr2 can be used for autocorrelation reliably.
David Young
David Young 2011 年 11 月 30 日
Yes, there are other differences too. I'll edit my answer rather than putting them in a comment.

サインインしてコメントする。


Dirk Padfield
Dirk Padfield 2013 年 12 月 26 日
This is exactly the same problem I noticed with normxcorr2, and this was the reason I contributed the following file
Hopefully this helps solve your issue.

カテゴリ

Help Center および File ExchangeCorrelation and Convolution についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by