Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/sunsided/convolution-template-matching

Template Matching by Convolution in MATLAB
https://github.com/sunsided/convolution-template-matching

feature-detection image-processing matlab template-matching

Last synced: 4 months ago
JSON representation

Template Matching by Convolution in MATLAB

Awesome Lists containing this project

README

        

# Template Matching by Convolution

*Template matching* attempts to find instances of a given template in an existing image by finding areas of maximum correspondence. While this can be done in terms of a cross correlation, care has to be taken to normalize both input and template, as cross correlation by itself is not invariant to mean shifts.

This experiment follows the idea that **convolution** is the same operation as **cross correlation**, when all axes of the template (i.e. the kernel) have been flipped; in terms of a two-dimensional correlation with a template, this results in a two-dimensional convolution of the same template, rotated by 180°; so

```matlab
xcorr2(image, template)
```

is conceptually the same as

```matlab
conv2(image, fliplr(flipud(template)) % or
conv2(image, rot90(template, 2))
```

Finding the template matches is then a question of finding the local minima (i.e. areas of maximum correspondence).