I’m trying to take an image taken in through a scanner (or possibly mobile phone camera) of varying quality and distortion, and re-align it with the base image (the one generated through photoshop, before it’s printed and scanned) to be as close as possible.
The image has four thick corner points at each of the corners, which I’ve been using a primitive method to find the four points of, then using a perspective transform on the scanned image. However, my algorithm is completely brute-force and highly breakable.
I’ve tried using cvGoodFeaturesToTrack(), but I can’t come up with an accurate way of making sure the four points for calibration are accurate under all circumstances. I’ve thought of using template matching, but it doesn’t seem like it will work reliably under a variety of distortions. I’m seeing a lot of methods to do specific tasks, like finding contours, key points, lines, etc., but no indications of what do actually do with them.
Is there a better way that I’m just not seeing?
Thanks!
The classical approach is binarization and blob analysis: find the pixels darker than a threshold and group them when they touch (connected components analysis). Keep the groups that have a dot shape (good circularity) and an area in the expected range. Use the center of gravity. This should be accurate enough for your reference points.
You may want to reduce false detections of the corner dots because of the nearby features in the image. An option for better discriminance is to use rings instead of disks and look for blobs with a hole.