The R code underlying the functions in this vignette were borrowed with permission from Vinces Gaitan’s blog post: https://www.kaggle.com/vicensgaitan/image-registration-the-r-way/notebook

I have modified the code where necessary in order to make it more pipeline-friendly and function oriented.

Image which will be used throughout this tutorial

Image which will be used throughout this tutorial

We need to pad image a so that it is the same size as image b:

We can then overlay the two images to see how far apart they are:

Step 1: Keypoint Detection

Use the image_surf() function in the image.dlib package to identify keypoints for alignment

With SURF, we can skip the image orientation and feature detection steps, as features are generated with an angle as part of the SURF algorithm.

Step 2: Match points

Match points are calculated using the K nearest neighbors algorithm, combined with some thresholding by distance.

match_points <- knn_points(kpf_a, kpf_b, centers_a, centers_b, show_plot = F)

Step 6: Image Warping

The homography can be used to warp one image onto the other:

We can then overlay the two images:

Areas that are in the first image only are shown in red; areas in the second image only are shown in blue. Areas in both images are shown in black.