Template matching not necessarily invariant to rotation and scale, but should detect artifacts (of 3X3 pixels or more)

14 views (last 30 days)
I want to compare a specific pattern (as on template image) and output "yes"/"no" according to the match. I don't require the method to be scale invariant. It just has to be translation invariant and rotation invariant (only till +/-2 degrees maximum).
Also, even if there's a slight mismatch between the template image and runtime image, the output should be "no".
So far, here are a couple of codes I have tried:
  1. Template Matching by Alaa Eleyan: This detects even if the pattern has noise, which I don't want.
  2. Simple template match. in matlab: This outputs a score of the match. The variation of scores of images with and without noise didn't seem to vary much.
  3. Fast/Robust Template Matching by Dirk-Jan Kroon: This too detects the pattern even if it's noisy.
  4. Template Matching using Correlation Coefficients by Yue Wu: It is similar to #3 but takes more time.
Many of them are not invariant to rotation. So at present, I match SURF features and calculate how much the runtime image has been rotated wrt template pattern. I then rotate it in the opposite direction so I need not apply an algorithm which is invariant to rotation (this is why I don't need rotation invariance).
In many cases even if there's no pattern present, it's still falsely detected. Here is a screenshot of output using #3:
Here is another such wrong output:
I have also worked on a couple of Algorithms based on SIFT/ASIFT Features earlier. They are very robust and obviously match patterns even if it's noisy. Hence, I am not using these in the present application.
I have attached an example Template image, and Yes and No images for your reference.
Please let me know an algorithm for this purpose. I thought it was a simple template match, but in many cases, it was falsely detected.
At present I think I can use #3 algorithm to at least detect the position of pattern in runtime image (as shown in 2nd screenshot above) and match this region. Is this possible? I can't use image subtraction because it's not exactly a pixel-to-pixel match. There may be very slight variations.
Any inputs will be appreciated.
Regards,
Meghana.
  1 Comment
Meghana Dinesh
Meghana Dinesh on 10 Mar 2015
Edit: I tried using Zernike Moments by Amir Tahmasbi. Although I got two outputs for each image, A and phi, I am not sure if I can count on this output. The value for A seems to be very close for good ('yes') and bad ('no') images. I have the screen shot posted here, along with the two outputs for each image. For my issue, is there any other way to infer these two outputs of each image so I can categorise them as good/bad?
This is for good image:
This is for three bad images:

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!