Image Recognizer |
Consider an Image represented by a matrix of digits, each digit represents the brightness of a pixel, as shown below. In early image processing, one could detect a particular feature in the image by finding the location where the feature (template) best matches the image.
Image: 0 1 0 1 1 0 0 Template: 0 0 1 1 1 1 0 0 0 0 1 1 1 0 2 0 0 2 0 0 1 2 0 1 2 0 3 3 3 3 0 0 0 3 3 2 3 3 0 0 1 1 1 0 0 1
To do this, you have to calculate, for each point y in the image where the template can fit entirely within the image, the cross-correlation
where i and t are the image and template light function respectively and x runs over all points in the image. The point with maximum cross-correlation is accepted as the location of the feature in the image.
Notes: The image and templates sizes are variable and never will be greater than 50 by 50 points. The x-axis is horizontal and the y-axis is vertical. A character F in the input file indicates the end of pairs of images. If a template fits equally in more than one place, the correct answer will be the closest to the upper-left corner. You can take the exact format from the example below.
I 0 1 0 1 1 0 0 0 0 0 0 1 1 1 0 1 2 0 1 2 0 0 3 3 2 3 3 0 0 1 1 0 0 0 1 T 0 0 1 1 1 1 0 2 0 0 2 0 3 3 3 3 0 0 F
(1,1)