© 2010 Science Publications Robust Template Matching Using Orthogonal Legendre Moment Invariants

Problem statement: Template matching is a famous methodology that has a wide range of applications in image and signal processing. For a template and input image, template matching methodology finds the partial input image that is m ost closely matches the template image in terms of specific criterion such as the Euclidean distance o r cross-correlation. Approach: In this study, a fast and robust template matching algorithm was proposed where exact Legendre moment invariants were used where a cross-correlation was employed to dete ct the most similar partial input image regardless of location, width and height. Results: Experimental results showed that template matching by using exact Legendre moment invariants achieve higher degree of robustness. Conclusion: Template matching by using exact Legendre moment invariants is very efficient where the high accuracy ensure the matching process and avoids any mismatching.


INTRODUCTION
Template matching measures the degree of similarity between two images. The first image is called template image while the second is called the input image. Template matching is one of the most important and challenging problems in object recognition, stereo matching, feature tracking, remote sensing and computer vision (Brunelli, 2009;Yazdi and Hosseini 2008;Bentoutou et al., 2005;Peng et al., 2003;Bimbo and Pala, 1997). It relies on calculating at each position of the image under examination a correlation or distortion function that measures the degree of similarity to the template image and the best matching is obtained when the similarity value is maximized.
However, conventional template matching methods using a template image consume a large amount of computational time. A number of techniques have been proposed in order to speed up the template matching process (Lai et al., 2008;Stefano et al., 2004;Stefano and Mattoccia, 2003;Gharavi, 2001).
Template matching involves two typical aspects: similarity measurement and search strategy. Among the similarity measurements, Normalized Cross-Correlation (NCC) is widely used due to its robustness in template matching.
Orthogonal moments were first introduced by (Teague, 1980). Legendre moments are proved to represent an image with a minimum amount of information redundancy (Teh and Chin, 1988). Invariance to scaling and translation could be achieved thought image normalization or directly by using the original Legendre polynomials (Hosny, 2010).
Recently, (Omachi and Omachi, 2007) proposed a new approach for fast template matching. This approach called algebraic template matching. They employed approximate Legendre moments to reconstruct template image and then use the NCC to find the most similar partial image in the input image regardless the width or height. They compare their results with that obtained from the least-square method. In fact, their approach is promising. Unfortunately, approximate Legendre moments represent the main weak point in their approach.
In this study, we proposed a robust and fast template matching algorithm. In this algorithm, low order exact translation and scaling Legendre moment invariants are employed as image features. The high accuracy ensures the matching process and avoids any mismatching. Fast computation and low complexity requirements ensure the efficiency of the proposed method. Numerical experiments are performed to show the robustness and the efficiency of the proposed template matching algorithm with different gray level images.
Legendre moments: The 2D Legendre moments of order (p + q) for image intensity function f(x, y) are defined as: (1) Legendre polynomial, P p (x), of order p is defined as: where, x∈[-1,1] and the Legendre polynomial P p (x) obeys the following recursive relation: with P 0 (x) = 1, P 1 (x) = x and p>1. The set of Legendre polynomials, P p (x), forms a complete orthogonal basis set on the interval [-1,1]. The orthogonality property is defined as: Based on the orthogonality of Legendre polynomials, the process of image reconstruction from Legendre moments only adds the individual components of each order to generate the reconstructed image. The image function f(x, y) could be written as an infinite series expansion in terms of the Legendre polynomials over the square [-1,1] × [-1,1] as follows: where the Legendre moments L pq are computed over the same square. If only Legendre moments of order smaller than or equal to Max are given, then the function f(x, y) in Eq. 5 can be approximated as follows: Where the total number of independent Legendre moments are: For the discrete-space version of the image, Eq. 1 is usually approximated by the Zeroth-Order Approximation (ZOA) form (Liao and Pawlak, 1996):

MATERIALS AND METHODS
Equation 8 is so-called direct method for Legendre moments computations. As proved by (Hosny, 2007b), Eq. 8 is inaccurate approximation of Eq. 1. In order to improve its accuracy, an alternative approach is employed. In this approach a digital image of size M×N is represented as an array of pixels. Centers of these Where: Translation-scale Legendre moment invariants: In this subsection, the computational process of translation-scale 2D Legendre moment invariants is presented in details. This process consists of two stages: The exact central Legendre moments which are invariant to translation are computed by using a modified version of our novel method (Hosny, 2007b). This step is followed by the second step in which the called Legendre moment invariants are computed. It is the 2D Legendre moment invariants are computed exactly without the need of original 2D Legendre moment computation. The set of 2D central Legendre moment could be exactly computed by: , are fully described in (Hosny, 2010). Fast computation of the exact 2D central Legendre moments is desirable especially in the applications required online computational process. The set of 2D central Legendre moments of the order-(p+q) could be computed in a very fast way by employing successive computation of the 1D q-th order moment for each row. This approach was successfully implemented in (Hosny, 2007a;2007b). Non-uniform scale Legendre moments are defined as: where, a and b are unequal non-zero real numbers representing the scaling factors in x-and y-direction respectively. Chong et al. (2004) expressed the scaled Legendre polynomials in terms of the original Legendre polynomials as follows: ( ) ( ) p p p p n n p n n n 0 n 0 P a x a P x where the matrix δ pn is defined by using the following equations: where, ns is the length of both vectors of the selected features. The moment invariants of the same orders are used for both template and selected partial input image.
Since we compute the translation and scale Legendre moment invariants, the size of the template image is used as a reference size in the input image (Fig. 1). The sweeping process started by the first image block with size equal to the size of the template image. This first block must be located at the top left corner of the input image. Similar partial image blocks of the same size are considered in horizontal and vertical directions.

RESULTS AND DISCUSSION
Numerical experiments are conducted by using different gray level images. In the first experiment, the standard image of pirate is used. The face of the pirate is considered as the template image. Both input and template images are depicted in Fig. 2. In the second experiment, a gray level image of interstate roads is used as input image where the image of 66 interstate road is the template image. Figure 3 display the two images. The third experiment is concerned with a template image which contains a mixture of Arabic and English languages. The input image is a gray level image with complicated background as displayed in Fig. 4. Vehicles, different signs with different languages are all displayed in the input image. Such image could be a challenging problem for any template matching algorithm.
The proposed method successfully matched all templates with their corresponding input images. No mismatching encountered. The highly accurate Legendre moment invariants play the essential role in the matching process where the accuracy of the crosscorrelation completely depends on the accuracy of the computed moment invariants. Computational time of computing Legendre moment invariants is very important where the matching process required computational of the same set of invariants for different locations in the input image. The very fast proposed method overcomes the challenging problem of computational process. The third attractive property of the proposed method is concerned with the mixture of different languages.