Question

Possible Duplicate:
scale and rotation Template matching

I have a template grayscale image , with white background and black shape over it. I also have several similar test images which vary in rotation and in shape. The test images are not same as template but they are similar.

I want to compare these two images and see if template matches , is most similar to, any of the test images. There are no distortions , no noise and no other defects in the images. Are there any tutorials on this topic ?

Was it helpful?

Solution

Try the easiest method first.

If I understand you correctly you have some model - black shape over white background. You can treat it as blob - find it's mass center and rotation by computing principal axes angle - look there.

Then you must segment out shapes from other images. Then try to find the best corresponding shape with matchShapes() function - see there how to use it.

matchShapes() function makes scale and rotation invariant matching. The smallest match shapes result the better match.

Extending your question you can find mass center and rotation of best matching blob and find rotation, scale and displacement between your model and matched image.

OTHER TIPS

This is quite a complex subject. You generally have options such as Generalized Hough Transform and Normalized Grayscale Correlation to deal with template matching. Problem is they are not scale or rotation invariant in their simplest expression. You need to focus on problem at the time, the generalized solution is complex. I recommend simple template matching first. Then add "hacks" for rotation and scale. For rotation you can downscale (low res. matching) and template match with rotated models. This can also deal with scale.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top