Establish an affine transformation model for image registration and evaluate it using RANSAC Algorithm

Source: Internet
Author: User

When the primary direction is selected, GIS is selected instead of the photographic measurement direction because of the small ry and lack of space imagination ability. Yesterday, I asked him to help him with image matching. I understand this. However, I am a person who asks me for help and is always embarrassed to say no. As a result, he started to write the program as soon as he gave it a chapter. Today, he finally finished it for him. It is relatively simple, and many problems are encountered in the middle, especially the large amount of computing. Because the data given by the teacher is rough registration data, RANSAC algorithm evaluation is simplified.

Theoretical content:

Chapter 1 geometric transformation model of Image Registration

 

After the matching relationship is established for the feature points, the next step is to solve the transformation relationship between images. The affine transform can well express the general transformation between images, and can be solved by at least three matching points. Because the previously used matching algorithm cannot ensure that there is no false match (in fact, there is a false match), this article uses the RANSAC method to estimate the relationship between the two images. If there are enough image feature matching to conform to a specific affine transformation, we think the current matching is satisfactory. Otherwise, we will make the next estimation.

5.1 RANSAC Algorithm

RANSAC (RandomSample Consensus), that is, the random sampling consistency algorithm, accurately speaking, it is an algorithm that estimates the parameters of a mathematical model satisfied by the data by means of iteration from a group of observation data containing noise. Proposed by Fischler and Bolles in 1981, it is a widely used method to remove mis-matching points.

5.2 ry Transform

Affine Transform is a transformation from an Affine plane to itself. It can maintain the collinearity of points (Parallelism, that is, the relationship between two-dimensional images remains unchanged, and Parallelism is still parallel, straight line (straight line) and straight line (straight line ). As the most commonly used transformation model in registration, affine transformation has a special branch in the ry, and is considered as a parallel projection chain.

 

An affine transform can be used to represent a matrix of three multiplication and three. The last line is (0, 0, 1 ). The transformation matrix changes the original coordinates (x, y) to (x ', y ').

Transformation Matrix:

In the space ry information test, we think that if the two images describe the same object or scene, because of the different image sizes, positions, and angles, the location information of the corresponding points of interest in the two images must satisfy a certain affine transformation relationship. Therefore, we use feature matching between two images as data to estimate the affine transformation matrix. If we can find an affine transformation that is sufficient for many feature matching, the current matching is considered satisfactory.

 

5.3 RANSAC affine transform space test

The space test uses the RANSAC algorithm to estimate an affined Transformation Model Based on the Feature Matching information between images.

We use the following formula to represent the affine transformation matrix.

M1, m2, m3, and m4 indicate the scale and rotation characteristics. tx indicates the translation in the x direction and ty indicates the translation in the y direction.

Then the coordinates of a matching point can be written

Or write it

Where (x, y) is before transformation, (u, v) is the coordinate after transformation.

To understand how to evaluate the affine transformation parameters, perform the following deformation on the above formula:

The value of model parameter x can be written as A * x = B.

To solve the six parameters, at least three pairs of feature matching are required. Therefore, three pairs of data are required for random RANSAC sampling each time to estimate the affine transform matrix.

 

After introducing related concepts and theories, the following describes how to test RANSAC's Geospatial Information:

1. Data preparation: Find the matching point and coordinate information between the two images (I1 and I2.

2. model estimation: Assume that there are n> 3 matching points, and three matching pairs are randomly selected. Based on the formula, the parameters m1, m2, m3, m4, tx, and ty are obtained.

3. Model Evaluation: perform the above-mentioned affine transformation on all the matched points (x, y) in image i1. then, the transformed coordinates (U', V') are obtained '). Calculate the Euclidean distance between the obtained coordinates and the matching point (u, v) in I2, that is, the estimation error E of the affined transformation. Normalize the scale information of the corresponding feature points in I2, so that each feature matching can obtain a normalized estimation error and finally obtain an estimation error vector.

4. determine an error threshold T based on the estimated error vector (how to determine the threshold ?), In the estimation error vector, the corresponding feature matching below T is Inliers.

5. if the number of Inliers is greater than the current maximum number of Inliers, save the change as if the current best radiation transformation is found (I can see that it needs to be locally optimized on the internet, all the Inliers matching points that meet the current best affine transformations are re-evaluated by the maternal estimation and model, and the information of the affine transformations is saved. In general, there are more Inliers after a Locally Optimized new radiation transformation. What does it mean ?)

6. Repeat steps 2 to 6, and the final affine transformation is considered to be the best radiation transformation model between I1 and I2.

Here we record the process:

(1) Derivation of the formula for calculating the six parameters and compiling the six parameter classes of the affine transformation (since data is not checked before, there are several groups of repeated data, as a result, the error "try to divide by zero" is always reported );

The Code is as follows:

/** Class for Solving Parameters of the affine transformation model * @ */using System; using System. collections. generic; using System. linq; using System. text; namespace ImageMatching {class ParameterHelper {public int [] X_Cor {get; set;} public int [] Y_Cor {get; set;} public int [] U_Cor {get; set;} public int [] V_Cor {get; set;} // set of the six parameters of the affine transform model. public double m1 {get {return (U_Cor [1]-U_Cor [0]) -m2 * (Y_Cor [1]-Y_Cor [0])/(X_Cor [1]-X_Cor [0]);} public double m2 {get {return (U_Cor [1]-U_Cor [0]) * (X_Cor [2]-X_Cor [0]) -(U_Cor [2]-U_Cor [0]) * (X_Cor [1]-X_Cor [0])/(Y_Cor [1]-Y_Cor [0]) * (X_Cor [2]-X_Cor [0])-(Y_Cor [2]-Y_Cor [0]) * (X_Cor [1]-X_Cor [0]);} public double m3 {get {return (V_Cor [1]-V_Cor [0])-m4 * (Y_Cor [1]-Y_Cor [0]) /(X_Cor [1]-X_Cor [0]); }} public double m4 {get {return (V_Cor [1]-V_Cor [0]) * (X_Cor [2]-X_Cor [0])-(V_Cor [2]-V_Cor [0]) * (X_Cor [1]-X_Cor [0]) /(Y_Cor [1]-Y_Cor [0]) * (X_Cor [2]-X_Cor [0])-(Y_Cor [2]-Y_Cor [0]) * (X_Cor [1]-X_Cor [0]);} public double tx {get {return U_Cor [0]-m1 * X_Cor [0]-m2 * Y_Cor [0];} public double ty {get {return V_Cor [0]-m3 * X_Cor [0]-m4 * Y_Cor [0] ;}}}
(2) calculate the number of combinations for all matching points. Three pairs of data are required for random sampling by RANSAC to estimate the matrix of the affine transformation. *Cn3) combination, with a large amount of computing.

(3) After solving the six parameters of the ry transform model, evaluate the model. The normalization error is calculated to obtain the normalization error vector.

(4) determine the threshold and calculate the number of Inliers. Here, we refer to the thesis to take the mean value of all normalization errors for the threshold value (we should say it should be taken from the adaptive threshold value, but I don't understand it ).

(5) compare the number of Inliers in all combinations to obtain the optimal affine transformation and save it.

(6) output of the six parameters of the affine transformation and the matched coordinates


Thank you for leaving a message!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.