## Materials and Methods
### Matched Filters and Template Matching  
The problem of finding parts of a search image which match a template image is just a bi-dimensional extension of the common unidimensional Signal Processing (SP) problem of detecting the presence of a template signal in a search signal, typically a noise-affected measurement. This problem was first solved in the mid-40s by [PERSON], [PERSON], and [PERSON] [43; 44; 45; 46] as a response to the immediate need to improve radar performance during World War II [43]. In the original framework, the issue with radar is to highlight the presence of an echo (i.e., a known template) exhibiting little power and obscured by noise in a received signal (i.e., the search signal). Assuming a Gaussian white noise (i.e., with a flat power spectrum), the noise contributes with equal undesired power at all frequencies, while the signal, on the contrary, shows a bandlimited spectral content. Considering a transmitted pulse (i.e., a rectangular function), its spectrum is described by a sinc pulse (i.e., a sinc function) which is theoretically defined over the whole frequency axis but has practically most of the power bound to low frequencies. A matched filter is then a linear time invariant filter that maximizes the signal-to-noise power ratio highlighting then the presence of the template in the search signal. Intuitively, it is then a filter that emphasizes the frequency where the template power is contained (i.e., the low frequencies) while attenuating those where the only noise is present. If the template is known then, it is sufficient to use the template spectrum for designing the best filter frequency response. The filter impulse response to be convolved with the search signal (i.e., for discrete signals, \(s[n]\), where \(n\) is the sample index related to time by the sampling period) is then just the time-reversed version of the template \(\hat{t}[n]\) of finite length \(N\) (N.B., more in general, for complex search signals, the conjugated time-reversed). The filter is then said to be \"matched\" to the template. See Equations (3) and (4) for the discrete Matched Filter impulse response definition (\(h[n]\)). In the Matched Filter output a peak occurs (i.e., the amplitude goes \"considerably\" greater than the rest of the output signal \(y[n]\) in the time domain) when the template signal is detected. By playing a bit with the notation, the convolution of the search signal with the time-reversed version of the template (\(s[n]*h[n]\) in Equation (5)) is equivalent to the cross-correlation of the template (as it is) with the search signal (\(r_{\text{Is}}[n]\) in Equation (6)). In the same way, if the cross-correlation shows a peak for a given delay (or lag) \(k\), then the template is detected. \[ \begin{array}{ll}&s[k]\quad-K<k<K\\ \left\{\begin{array}{ll}t[n]=\hat{t}[n]&n=0,\ldots,N-1<K\\ t[n]=0&-K<n<0\;\;\vee\;N-1<n<K\end{array}\right.\\ \\ &h[n]=t[-n]\\ \\ y[n]=s[n]*h[n]=\sum\
olimits_{k=-K}^{K}h[n-k]s[k]\\ \\ y[n]=\sum\
olimits_{k=-K}^{K}t[k-n]s[k]=\sum\
olimits_{k=-K}^{K}t[k]s[k+n]=r_{ \text{Is}}[n]\end{array}  \tag{3}\]  
The same consideration holds also when the problem is extended to a discrete 2D search signal such as a monochromatic image where the light intensity \(s[n,m]\) is a function of the spatial coordinatesand \(m\) over the pixel grid (i.e., a matrix). This problem is referred to as TM. Given a known template \(\hat{t}[n,m]\) of size \(N\times M\), it is possible to perform cross-correlation by simply moving the center of the template over each pixel of the search image pixel-grid of size \(J\times K\) and calculate the sum of the pixel-wise products of \(s\) and \(\hat{t}\) over the area spanned by the template \(\hat{t}\). In a more rigorous formulation:  
1. The template \(\hat{t}\) is placed at \((n_{0}+N/2,m_{0}+M/2)\) in a matrix \(t\) of the same size \([n,m]\) of the search matrix \(s[n,m]\) (Equation (7)),
2. The entrywise product (also known as Hadamard or Schur product, here \"\(\circ\)\") is performed finding the matrix \(st[n,m]\) (Equation (8))
3.