# Normalized cross correlation vs Euclidean distance in template matching

What is the difference between normalized cross-correlation and Euclidean distance in pattern recognition? -- especially if we want to do recognition with template matching.

I understand about Euclidean distance. It's like calculate $\sqrt{\sum(x_2-x_1)^2+..+(x_n-x_{n-1}))}$

And the small distance in Euclidean distance is recognised as the new label of the test image. But how about normalized cross correlation??

How to calculate it, what does is it represent, what are the drawbacks and the advantage of using that method? Which method is the best???

• I suggested some edits to your post but I didn't change the meaning. Can you please check your formula for Euclidean distance -- I think you have missed out a $^2$ at the end? And you don't need to write a sum $\sum$ as well as $+\ldots+$. Something like $\sqrt{(x_2-x_1)^2+\ldots+(x_n-x_{n-1})^2}$. – TooTone Mar 23 '14 at 12:03

For two vectors $v_i$ and $v_j$ with length $n$,
1, when the two vectors are normalized to zero mean and unit length ($v \leftarrow \frac{v-\bar{v}}{||v-\bar{v}||_2}$), their Pearson correlation coefficient $r(=corr(v_i, v_j))$ relates to their Euclidean distance $d(=||v_i-v_j||_2)$ by $r=1-d^2/2$, or equally $r=v_i^Tv_j$. Reference: http://t.cn/RL5JcKt.
2, when the two vectors are normalized to zero mean and unit standard deviation (or unit variance) ($v \leftarrow \frac{v-\bar{v}}{std(v-\bar{v})}$), then $r=1-d^2/(2*(n-1))$, or equally $r=v_i^Tv_j/(n-1)$.