## Materials and Methods
### GA-adaptive Template Matching
#### 2.4.2 Objective Function  
The change of paradigm from traditional TM to GA-adaptive TM is related to the use of GA for the estimation of the optimal parameters maximizing the match of the parametric template to the search image. In order to evaluate \"how good\" a reconstructed template is (N.B., reconstructed on the basis of the selected parameters), an objective function (commonly called utility function when referred to maximization problems or cost function when dealing with minimizations) is needed. In order to keep the link between TM and GA-adaptive TM, a possible utility function is the correlation function (i.e., \(r\) in Equation (11)). Nevertheless, in the literature, other commonly found functions \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Parameter** & **Description** & **Parameter** & **Description** \\ \hline \(X_{c},Y_{c}\) & Center of the outer hexagon (OH) & \(R^{*}\) & Distance of 8.8 logo from \((X^{\prime}_{c},Y^{\prime}_{c})\) \\ \(R\) & Radius of the inscribing circle (OH) & \(d\theta\) & Deviation from _ax_ slope direction \\ \(\theta\) & Rotation of the OH & \(s=r_{2}\) & Logo size = hollow circles radii \\ \(t\) & Thickness of OH & \(r_{1}\) & Logo’s circles radii \(r_{1}=4,5s\) \\ \(X^{\prime}_{c},Y^{\prime}_{c}\) & Center of the inner hexagon (IH) & \(r_{3}\) & Logo’s dot radius \(r_{3}=2,25s\) \\ \(R^{\prime}\) & Radius of the inscribing circle (IH) & \(h\) & Logo’s height \(h=5,5s\) \\ \(\theta^{\prime}\) & Rotation of the IH & \(w\) & Logo’s width \(w=w_{1}+w_{2}\) \\ \(t^{\prime}\) & Thickness of the IH & \(w_{r}\) & Logo’s width ratio \(w_{r}=w_{1}/w\) \\ \(ax\) & 8.8 intercepting diagonal of IH & \(w_{1},w_{2}\) & Distance of “\(8\)” from Logo’s dot \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Characteristic variables of the three parametric templates. The 13 independent variables are highlighted in red, \(t\) and \(t^{\prime}\) parameters are constants, while the other parameters are derived. Figure 7: Binary templates after Genetic Algorithm (GA) optimization on the first frame (Figure 3a) with characteristic parameters highlighted in red (overall, 13 independent parameters, as reported in Table 1): (**a**) Outer hexagon template; (**b**) Inner hexagon template; (**c**) 8.8 logo template. N.B., The pictures “quantization” effect is determined by the 191 × 191 px grid of the search image, which dictates the final template resolution. are the Sum of Absolute Differences (i.e., SAD) or the Sum of Squared Differences (i.e., SSD), usually implemented as cost functions for a minimization problem. In order to select the best objective function for this particular implementation, two considerations are fundamental. First, in this work the template is reconstructed to the same size (\(J\times K=191\times 191\)) of the search image so that all the objective functions can be easily implemented as:  
\[r(param) =\sum\
olimits_{j=1}^{J}\sum\
olimits_{k=1}^{K}t[j,k|param|s[j,k] \tag{11}\] \[SAD(param) =\sum\
olimits_{j=1}^{J}\sum\
olimits_{k=1}^{K}\bigl{|}t[j,k|param ]-s[j,k]\bigr{|}\] (12) \[SSD(param) =\sum\
olimits_{j=1}^{J}\sum\
olimits_{k=1}^{K}\bigl{(}t[j,k|param ]-s[j,k]\bigr{)}^{2} \tag{13}\]  
where \(t[j,k|param]\) is the reconstructed template as a function of the corresponding parameters (i.e., _param_, see Figure 7) and \(s[j,k]\) is the search image (e.g., a frame processed to obtain the result in Figure 4c). Second, the \(t\) and \(s\) are binary, so that the possible results for single pixel information can be summarized as in Table 2:  
From Table 2, it is clear that SAD and SSD are equivalent in the case of binary images. Another relevant consideration regards the fact that correlation can be used for maximizing the match (i.e., the similarity), while SAD and SSD are suitable for minimization of the mismatch (i.e., the difference). Nevertheless, correlation rewards the similarity of white pixels (i.e., the 1) only, but neglects the black pixels (i.e., the 0).