Image registration is a digital image processing technique which helps us align different images of the same scene. For instance, one may click the picture of a book from various angles. Below are a few instances that show the diversity of camera angle.
Now, we may want to “align” a particular image to the same angle as a reference image. In the images above, one may consider the first image to be an “ideal” cover photo, while the second and third images do not serve well for book cover photo purposes. The image registration algorithm helps us align the second and third pictures to the same plane as the first one.
How does image registration work?
Alignment can be looked at as a simple coordinate transform. The algorithm works as follows:
- Convert both images to grayscale.
- Match features from the image to be aligned, to the reference image and store the coordinates of the corresponding keypoints. Keypoints are simply the selected few points which are used to compute the transform (generally points that stand out), and descriptors are histograms of the image gradients to characterize the appearance of a keypoint. In this post, we use ORB (Oriented FAST and Rotated BRIEF) implementation in the OpenCV library, which provides us with both keypoints as well as their associated descriptors.
- Match the keypoints between the two images. In this post, we use BFMatcher, which is a brute force matcher.
BFMatcher.match()retrieves the best match, while
BFMatcher.knnMatch()retrieves top K matches, where K is specified by the user.
- Pick the top matches, and remove the noisy matches.
- Find the homomorphy transform.
- Apply this transform to the original unaligned image to get the output image.
Applications of Image Registration –
Some of the useful applications of image registration include:
- Stiching various scenes (which may or may not have the same camera alignment) together to form a continuous panaromic shot.
- Aligning camera images of documents to a standard alignment to create realistic scanned documents.
- Aligning medical images for better observation and analysis.
Below is the code for image registration. We have aligned the second image with reference to the third image.
- Cartooning an Image using OpenCV - Python
- Reading an image in OpenCV using Python
- Image Steganography using OpenCV in Python
- Image Processing without OpenCV | Python
- Image Pyramid using OpenCV | Python
- Python | Image blurring using OpenCV
- Log transformation of an image using Python and OpenCV
- Image Resizing using OpenCV | Python
- Image Translation using OpenCV | Python
- OpenCV Python Program to blur an image
- Python | Detect Polygons in an Image using OpenCV
- Negative transformation of an image using Python and OpenCV
- Python | Detect corner of an image using OpenCV
- Python | OpenCV program to read and save an Image
- OpenCV Python Program to analyze an image using Histogram
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.