Reputation: 5566
I have a set of training images consisting of binary rectangles. I need to write a program that takes in another binary image (with noise, scale, rotation and slight shifting of rectangle positions) and find the closest matching image in the training set
e.g. Input image:
Trained image: Should be matched with this
Trained image: Should not be matched with this
To my knowledge, there are 3 approaches.
Template matching: I generate a set of scaled and rotated variants of the training image for template matching. The problem I faced with this approach is that the training images that has the highest score is always the scaled down example with most white rectangles (since a near perfect match will be found if the whitest example fits into one of the white rectangles in the input image)
Feature matching: To my understanding, feature matching relies on the fact that certain pixels (or small region of pixels) in an image is unique. However, since every edge / corner looks exactly like any other edge / corner, feature matching would fail in this case. (Please correct me if I am wrong)
Manually encode the rectangle information (e.g. orientation, position, etc.), basically creating my own descriptor for the templates and try to match. (is there a way to generate a descriptor for large images / templates?)
Can anyone advice me on how to handle this?
Upvotes: 0
Views: 1843
Reputation: 5566
I ended up using my first approach
Template matching: I generate a set of scaled and rotated variants of the training image for template matching. The problem I faced with this approach is that the training images that has the highest score is always the scaled down example with most white rectangles (since a near perfect match will be found if the whitest example fits into one of the white rectangles in the input image)
But to tackle the problem of it blindly matching mostly white templates to the white regions of the query image, I padded the scaled down images with black space to penalize matching of a white template when it's surrounding is also white.
Works fairly well for my needs.
Upvotes: 0