1
$\begingroup$

I am studying the Zero Mean Normalized Cross Correlation (ZNCC) method for pattern matching. I would like to match the pattern of a square region of size $N \times N$ from two different images. Hence I define two vectors $P$ and $Q$, each of size $N \times N$, for storing the pixel intensity inside each of the two regions. The calculation of the ZNCC is then as follows:

(1) $P' = P - \bar{P}$, where $\bar{P} = \sum {P_i} / N$. Similarly, $Q' = Q - \bar{Q}$, where $\bar{Q} = \sum{Q_i} / N $

(2) $P'' = P' / |P'|$ and $Q'' = Q' / |Q'|$

(3) ZNCC = Dot product of $P''$ and $Q''$

The problem is, when one of the selected regions contain pixels all with the same intensity (which can happen occasionally in my image, especially when N is small), $P'$ or $Q'$ become a zero vector and it is impossible to proceed to calculate $P''$ or $Q''$. What should we do in this case?

$\endgroup$
  • $\begingroup$ Note that you can use LaTeX here to typeset mathematics in a more readable way. See here for a short introduction. $\endgroup$ – D.W. Oct 23 '15 at 5:17
  • 1
    $\begingroup$ If (say) $P' = 0$ then you can define arbitrarily $P'' = 0$, and so the ZNCC equals zero. Don't forget to check whether $P''=Q''=0$, which indicates high correlation even though the dot product is zero. $\endgroup$ – Yuval Filmus Oct 23 '15 at 7:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.