written 2.1 years ago by |
Solution:
Template Matching:
Template matching is a technique that is used to recognize whether a given part belongs to a a particular class of parts.
The characteristic features of each class of parts are placed in front of the camera, one at a time and their images are obtained and stored in a library of parts.
$ \text { LIBRARY }=\text { LIB }=\{\mathrm{Ti}(\mathrm{k}, \mathrm{j}): 1 \leq \mathrm{k} \leq \mathrm{m} 0,1 \leq \mathrm{j} \leq \mathrm{n} 0,1 \leq \mathrm{i} \leq \mathrm{N}\}\\ $
The $\mathrm{i}^{\text {th }}$ representative image $T_i(k, j)$ is referred to as a template or mask for a class i. The objective is to search for a translation $(x, y)$ which will minimize the performance index $\rho_{\mathrm{i}}(x, y)$.
If $\rho_{\mathrm{i}}(\mathrm{x}, \mathrm{y})=0$, then an exact match has been detected. The algorithm determines the part $\mathrm{i}$ contained in the image $\mathrm{I}(\mathrm{k}, \mathrm{j})$ and also the location of the part $(\mathrm{x}, \mathrm{y})$ is also identified.
Algorithm for Template matching:
- Initialize $i=1, x=0, y=0, \varepsilon\gt0$, found $=$ true. - Compute performance index $\rho_i(x, y)$ using - $ \rho_i(x, y) \triangleq \sum_{k=1}^{m 0} \sum_{j=1}^{m 0}\left|I(k+x, j+y)-T_i(k, j)\right| \quad 1 \leq i \leq N $ - If $\rho_i(x, y) \leq \varepsilon$, stop - Set $x=x+1$.If $x \leq m-m 0$, go to step 2 - Set $x=0, y=y+1$. If $y \leq n-n 0$, go to step 2 - Set $x=0, y=0, i=i+1$.If $i \leq N$, go to step 2 - Set found $=$ false