Image matching, affine deformation

My problem is shown here: issue report . I have one image of a template that I have to detect in a camera image. After detection, I have to normalize the camera image using the affine transform. The purpose of my work is to identify crosses. I tried using the SURF functions for the image normalization step, but the pattern image is very regular and not suitable for SURF matching. Any ideas how to do this? Maybe some kind of contour mapping?

+4
source share
4 answers

So, I thought about it, and then I realized that you want to take the WHOLE ticket instead of a subset of this ticket and convert it into a regular rectangle. This problem (at least theoretically) is not so complicated, and writing some code to do it yourself is relatively trivial.

The hardest part of this will certainly be the initial angle detection. Since you are only interested in the ticket as a whole, everything in the ticket means nothing. All that interests you is the four corners. You can see in the picture that when the ticket is on top of another ticket, the angle is not obvious. If all your photos were a ticket lying on top of a very dark surface, then it would be trivial again, but the idea is to write an application that, I hope, can handle even ambiguous cases. In doing so, I propose the following approach:

1) Use image filters to lighten light areas of the image and darken dark areas of the image.

I forgot what the name of such a filter is, but basically you want to have more contrasts between the darker and lighter areas of the image.

2) To sharpen all areas above a given brightness, Gaussian blur all areas below a given darkness

Function search algorithms typically rely on image “sharpness” to be able to detect corners and edges. By sharpening all the lighter areas of the image (given that your ticket is white) and blurring all the darker areas of the image, you will increase your chances of algorithmically detecting the angles you are looking for.

3) Use the detection function to detect four corners

Everything will go through the hair here. If you have a bunch of lottery tickets on which you take a picture, and you want them to be able to algorithmically find and display it without distortion, then you are talking about current material. If this is what you are trying to do, I suggest reading some Yanxi Liu documents, primarily the Percendual Group, based on translational symmetry, with applications for urban scenes. Most likely, you will have to create a template from a pre-made ticket image, and then try to match the exact functions of this template with a distorted grid of the same functions in your camera image. If you have a match that exceeds the percentage threshold, you can try to find its four corners. If you find them successfully, you can proceed to the next step.

IF, on the other hand, you are not trying to make a cutting edge, then you can simply perform some book detection functions. To determine the angle, I would recommend using the Harris and Stephens / Plessey / Shi-Tomasi corner detection algorithm. This is the same algorithm that Yanxi uses in many of its documents and does a pretty good job of detecting angles. I'm not sure if the filter accepts a grayscale image or if it accepts the current color scale, but if it does the latter, then using the Canny edge detection filter before using the angle detection algorithm will be beneficial, Once you know the main corners of the ticket ( I hope), you will need to develop some kind of intelligent search algorithm (based on the perspective and content of your photo) to “guess” which corners are REAL, that there are four corners that you care about.

It is also worth noting that “Medium Shift Exemption” can help you identify the most important functions after detection algorithms. Basically, you take a series of points within a given field, average all their coordinates, and then center the window on the resulting coordinate. If new points appear in the field after moving, you do it again. You continue to do this until one point of interest remains in the center of the box. This is a brief description of the idea, so I suggest you study it further, since I do not know the details of averaging.

4) Use two-line interpolation to determine the colors that you need to convey in your final image.

It is important to note that you do not want to take colors from a distorted image. The goal of running all the filters and detection algorithms in the image is to find the points you are interested in. Once you have these coordinates, you will return to the original image to draw the colors.

If you ask this question, I assume that you know what bilinear interpolation is. You think that the top and bottom edges of a distorted ticket start at 0 (left corners) and end at 1 (right corners). You think that the left and right edges start at 0 (upper corners) and end at 1 (lower corners). You would apply the same logic to the size of the output image. Passing through the pixels in the output image, you will find the interpolation coordinates needed to obtain color and use two-line interpolation, you will pull the colors from the input image.

And this! (lol) What you ask is very attractive, and I wish you the best of luck. Creating an algorithm that does this perfectly for all cases without user input is almost impossible, as far as I can tell. Also, the fact that you are looking at lotto tickets raises the question of how ethical this project is. In any case, I hope this is enough to get your brain started. Here are some additional links:

Canny Edge Detection: http://en.wikipedia.org/wiki/Edge_detection

Angle Detection: http://en.wikipedia.org/wiki/Corner_detection

Yanxi Liu docs: http://www.cse.psu.edu/~yanxi/

Average Bias Vera Distribution: Used in the document that I told you about

EDIT

Code for level separation

int threshold = 128; float percentChange = .5; int oldr, oldg, oldb, newr, newg, newb, grayscale; //Assuming that pixels is a 1D array of pixel objects that make up the image you're currently working with. Syntax is of Processing.org for (int i=0; i<pixels.length; i++) { oldr = red(pixels[i]); oldg = green(pixels[i]); oldb = blue(pixels[i]); grayscale = Math.floor((oldr + oldg + oldb) / 3.0); if (grayScale >= threshold) { //Brightness is above threshold, therefore increase brightness newr = oldr + (255-oldr)*percentChange; newg = oldg + (255-oldg)*percentChange; newb = oldb + (255-oldb)*percentChange; } else { //Brightness is below threshold, therefore increase darkness newr = oldr - oldr*percentChange; newg = oldg - oldg*percentChange; newb = oldb - oldb*percentChange; } pixels[i] = color(newr,newg,newb); } 
+5
source

In addition to MoarCodePlz's answer, there are two keywords that are fundamental to your task: homography solution and hough Transformation .

0
source

Direct (pixel) aproaches may be better in your case than function-based.

You can find a good tutorial on Image Alignment here: http://research.microsoft.com/apps/pubs/default.aspx?id=70092

Another idea is to choose a ROI. If you know that the area on the right in your image consisted of red squares, you can try to exclude it from SURF detection. In addition, you can define the shape of the “red square area” and use it to evaluate the transformation.

0
source

Just find the largest (thickest and longest) red lines and make an affine deformation.

0
source

All Articles