As per wikipedia, ‘Image registration is the process of transforming different sets of data into one coordinate system’. Simply put, image registration is comparing images with a base image and quantifying the changes. For example when a video is streamed, we would like to find out whether the camera is changing its position, and if so, how do you correct it.
We will look at a snippet written in python which compares two images and returns a homography matrix which relates both the images.
A homography matrix is a 3×3 matrix which decides the transformation between two set of coordinate systems.Mathematically, if A is a set of coordinates in one space and B is a set of corresponding coordinates in another space, then
Wher H is our homography matrix.
To calculate our homography matrix,we need a set of corresponding points in the two spaces. For this, SIFT(Scale Invariant Feature Transform) is used. SIFT generates a set of ‘interest’ points which can be used for tracking an image.
Once we get the corresponding points, we can calculate the homography matrix. But we need a good algorithm which will pick the necessary points and discard the outliers. To implement this, we use the RANSAC algorithm. RANSAC(RANdom SAmple Consensus) algorithm picks a minimum number of points from a given set and estimates the model. It then takes into account more points from the set which closely fit the model and then calculates the error in the estimated model. This is done for a predefined number of times to get a good model. This model ensures that only inliers are included and outliers are not taken into account.
Using SIFT implementation in python and calculation of homography matrix in python, we apply a RANSAC algorithm to find the homography matrix and change the first image accordingly so that it matches the orientation of the second image.
You can find the source code here:
Note: SIFT is a patented technique by David Lowe. It is protected by the following patents:
Method and apparatus for identifying scale invariant features in an image and use of same for locating an object in an image
David G. Lowe, US Patent 6,711,293 (March 23, 2004). Provisional application filed March 8, 1999. Asignee: The University of British Columbia