how to perform template matching in matlab??

How to get the correct match for the template in the image? I have attached a template here and i need to find its match in images which are similar to the one from which i cropped the template.
<<
<<
>>
>>

2 Comments

Fisrt You make the Imagefile for your fonts in this file every font image must be in 1 bit depth. Seond Create your Font Template..
Third Apply Template Matching for ur testing data and get your Result.
For More Information Visit
Can you move this down to the Answer section, instead of up here which is used to ask posters for clarification? Thanks in advance.

Sign in to comment.

 Accepted Answer

You can use normalized cross correlation. See attached demo.
Or use the Computer Vision System Toolbox. See the Feature-Based Object Detection section on this page: http://www.mathworks.com/products/computer-vision/features.html#feature-detection%2C-extraction%2C-and-matching

10 Comments

computer vision toolbox is not available in r2011a??
Probably not. Time to upgrade if your version is 4 years old.
can I know how to calculate the accuracy for different template matching methods, like:
Fast Template Matching using SSDXCORR
Performance index Method
Pseudo Correlation
Cross Correlation method
???
Maybe immse(), psnr(), or ssim()?
I tried normxcorr2_demo.m, and the demo seems to be fine. When I rotated the template by 45 degrees, it failed to locate it in the image correctly.
I guessed that normxcorr2() may not be the choice if there is orientation difference. I am wondering if there is any MATLAB function that can do this correlation or matching but accounts also for rotation. In my application, I have the object is taking many different orientation in the images.
Thanks!
Thanks a lot for the reply. I will definitely look into this.
@Image Analyst This is probably the millionth time I've seen you upload this very answer with the exact same code. Would you mind putting some effort in ACTUALLY answering the question?
No, because it's not something that can be answered in a few minutes. I could work literally weeks or months on this and it still wouldn't be robust enough to handle all conditions of bills, from perfect uncirculated to very worn to damaged/torn to color changes due to wear, being counterfeit, using different cameras, etc. This could be a Ph.D. project and even then it wouldn't be perfect because even if the counterfeit note is a visually perfect match to a real bill, it could still be counterfeit due to non-visible attributes such as type of paper, chemical properties, or optical properties that can't be resolved in a digital image, such as holograms, super fine print or texture, etc. So you cannot say from a digital image whether a bill is real or counterfeit unless it's an extraordinarily bad counterfeit.
So I just gave some code to start with and let them finish the work. If you think you can provide code that's more robust than mine, feel free.
Yeah my bad for that comment, I was in a bad place.

Sign in to comment.

More Answers (0)

Asked:

on 19 Mar 2015

Commented:

on 27 Feb 2025

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!