RELIABLE REJECTION OF MISMATCHING CANDIDATES FOR EFFICIENT ZNCC TEMPLATE MATCHING Stefano Mattoccia, Federico Tombari, Luigi Di Stefano Department of Electronics Computer Science and Systems (DEIS) Advanced Research Center on Electronic Systems (ARCES) Viale Risorgimento 2 - Bologna, Italy {stefano.mattoccia, federico.tombari, luigi.distefano}@unibo.it ABSTRACT This paper presents a method that reduces the computational cost of template matching based on the Zero-mean Normal- ized Cross-Correlation (ZNCC) without compromising the accuracy of the results. A very effective condition is deter- mined at a small and ſxed cost that allow to rapidly detect a large number of mismatching candidates with no need to compute the ZNCC score. Then, thanks to the use of an additional set of conditions, the computation of the whole ZNCC function is typically required only for a very small number of candidates. Experimental results demonstrate the effectiveness of our approach. Index TermsTemplate matching, ZNCC, cross corre- lation, fast, exhaustive 1. INTRODUCTION AND RELATED WORK The purpose of template matching is to detect which part of an image is most similar to a given template. Template match- ing is widely deployed for tasks such as quality control, de- fect detection, robot navigation, face and object recognition, edge detection [1]. Zero-mean Normalized Cross Correla- tion (ZNCC) has been successfully employed as a function to measure the degree of similarity between two image patches due to its invariance with regards to afſne photometric distor- tions. The standard algorithm, or Full-Search (FS), used to per- form ZNCC-based template matching simply scans the image and at each point (x, y) it computes the ZNCC-score between the template vector and the portion of the image centered in (x, y) having the same size as the template (image candi- date vector). Then the image coordinates of the global ZNCC maximum locate the candidate most similar to the template. Denoting as I , I c and T , respectively, the image, candidate and template vectors, and having each candidate and template the same size M × N , the ZNCC function at pixel position (x, y) is given by: ZNCC(x, y)= (I c (x, y) μ Ic (x, y)) (T μ T ) ||I c (x, y) μ Ic (x, y)|| · ||T μ T || (1) with μ Ic (x, y) and μ T being respectively the mean intensity value computed over I c (x, y) and T , representing the dot product between two vectors, and the two terms at the de- nominator being respectively the L 2 norm of zero-mean im- age candidate and zero-mean template vectors. Hereinafter the numerator of (1) will be referred to as η(x, y). The FS algorithm turns out to be an expensive task: even if incremental techniques [2], [3] can be adopted to efſciently compute for each point the image candidate mean values and norms in (1), the complexity of η(x, y) is still of the order of O(WHMN ). A common alternative [4] computes the cross- correlation in the frequency domain by means of the well- known Fast Fourier Transform (FFT), yielding a complexity of the order of O (WHlog 2 (WH )). This approach is exhaus- tive, i.e. it guarantees to yield exactly the same results as the FS, and turns out to be faster than the FS as the template size approaches the image size and with large templates and im- ages [4]. Another exhaustive approach aimed at speeding up ZNCC- based template matching is the Zero-mean Bounded Par- tial Correlation (ZBPC) technique [5]. This method relies on two computationally efſcient upper-bounding functions for η(x, y), β ZBPC (x, y) and β  ZBPC (x, y), that allow for rapidly pruning mismatching candidates by testing: min(β ZBPC (x, y)  ZBPC (x, y)) ||I c (x, y) μ Ic (x, y)|| · ||T μ T || ZNCC max (2) with ZNCC max being the ZNCC maximum found among previously evaluated candidates. If (2) holds then the cur- rent candidate is guaranteed not to be the global maximum and ZNCC computation need not being carried out. Nev- ertheless, since the computation of both β ZBPC (x, y) and β  ZBPC (x, y) involves calculating a partial cross-correlation term on a subset of template and candidate vectors (i.e. on n ZBPC rows), then the speed-ups yielded by ZBPC on FS are upper-bounded by N nZBPC . Moreover, very recently a fast exhaustive scheme for ZNCC-based block matching was proposed in [6]. By deter- mining a monotonically decreasing equivalent expression of 849 978-1-4244-1764-3/08/$25.00 ©2008 IEEE ICIP 2008