adityajain07 / Homography_DLT_RANSAC

This project has the implementation of DLT along with RANSAC from scratch to find homography between two image scenes. Results have been shown on test images too.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

About

The aim of the project is to find homography between two image scenes using DLT along with RANSAC. Everything has been coded from scratch. The 'Collage Image' folder contains a collage of book images (skewed, rotated, translated, distorted) and some of the raw book images are present in 'Test Images' folder. The aim is to find homography between the test images and the collage image and given a test image, find its bounding box in the collage image.

Note: The code can be easily modified to find homography between any two image scenes.

Collage Image

Collage Image

Technique

Following is the process implemented to find the bounding box of a test image in the collage image:

  1. Given a test image and the collage image
  2. Find SIFT features in both test and collage image
  3. Find the feature matches using any matcher (used BF matcher in this project)
  4. Pick any four random pairs of matches and normalise them (to have their centroid at (0,0) and average distance from the origin is sqrt(2))
  5. Find homography using the above points using DLT
  6. Find the reprojection error using the homography calculated and store all the inliers (inliers are those points whose reprojection error is below the threshold decided)
  7. Repeat steps 4-6 for N iterations (used 4000 in the results, though 1000 is good enough too)
  8. Store the maximum no. of inliers in the N iterations
  9. Again normalise the inlier points in the above step
  10. Find homography in the above using DLT in least-squared sense
  11. Apply the homography obtained above on the corner points of the test image to get their corresponding positions in the collage image
  12. Draw lines between the mapped corners to get the bounding box of the test image in the collage

Results

Test Image 1

Top 200 Matches

Alt Text

Inlier/Outlier Matches

Green: Inlier matches
Red: Outlier matches
Alt Text

Bounding Box

Alt Text

Test Image 2

Top 200 Matches

Alt Text

Inlier/Outlier Matches

Green: Inlier matches
Red: Outlier matches
Alt Text

Bounding Box

Alt Text

Test Image 3

Top 200 Matches

Alt Text

Inlier/Outlier Matches

Green: Inlier matches
Red: Outlier matches
Alt Text

Bounding Box

Alt Text

About

This project has the implementation of DLT along with RANSAC from scratch to find homography between two image scenes. Results have been shown on test images too.


Languages

Language:Jupyter Notebook 60.1%Language:Python 39.9%