4

I have an image, which I can obtain at better quality (e.g. higher size). The problem is that I can't do template match on default size, only on a higher one. And the higher one is not fixed - it can be anything from 1.0 to 2.5x of original image.

I was thinking of retrieving templates in higher resolution and then depending on what's the size of the image, resize down the templates. However, that might yield completely wrong results, when I use different resize algorithm.

What do you suggest? How should I proceed, when I want to do template matching in such circumstances?

Edit: Just note - templates will always be the same and their counterparts in images too (images are computer-generated).

mnn
  • 1,952
  • 4
  • 28
  • 51

1 Answers1

2

So are you saying you have an image template at nominal scale of 1.0 and target image in which you want to match ranging from 1.0 to 2.5x?

Scale invariant pattern matching algorithms are pretty complex. The simplest thing to do is to scale down your target image to multiple intermediate resolutions and try to match it with your template. For better performance, try to reduce the scale of your template (say 0.5) so that your target will fall in the 0.5-1.75 range. When working on different resolutions, try to smooth your images a bit.

Finally to make sure your template match is accurate, increase your scale of your target image and template image tracking the last {x, y} position up to your new res. You can do this until greatest resolution is attained. Normalized grayscale correlation is a pretty good and fast algo for pattern matching.

code-gijoe
  • 6,949
  • 14
  • 67
  • 103
  • I would try scaling down the templates, but they're already really small, and I'm doing also thresholding on them, so that's not really option. So, if it helps, I'm doing kind of OCR, however standard techniques/libraries (tessnet) won't help. – mnn Mar 20 '11 at 15:20
  • So you're binarizing your templates and matching them against bin targets? You could down size your targets then, you don't have much choice anyways. The problem with bin, images is your correlation is very weak... try doings it in grayscale. You can also look at more advanced techniques such as adaboost and SVMs (both pretty advanced but if you know matlab you should get small tests working in a few days). – code-gijoe Mar 20 '11 at 21:47
  • I load original color image, convert it to grayscale, and threshold it (254). The results are pretty good, if the sizes of template and search image match, but if I resize the search image, results get worse and worse. – mnn Mar 24 '11 at 20:47
  • You have to tackle the multi-resolution problem! Speed == low accuracy and low res. So you can start at low res. and update your position as you increase your resolution and reduce your search area. Look for multiresolution / multiscale image processing and template matching on Google. There is a lot of stuff. – code-gijoe Mar 24 '11 at 22:09