Model Pipeline - Homography and image alignment
This pipeline aligns two images by finding a transformation called homography. It matches points between images, calculates the homography matrix, and warps one image to align with the other.
Jump into concepts and practice - no test required
This pipeline aligns two images by finding a transformation called homography. It matches points between images, calculates the homography matrix, and warps one image to align with the other.
Loss
0.5 |****
0.4 |***
0.3 |**
0.2 |*
0.1 |*
0.0 +----
1 2 3 4 5 Epochs
| Epoch | Loss ↓ | Accuracy ↑ | Observation |
|---|---|---|---|
| 1 | 0.45 | 0.60 | Initial homography estimation with many outliers |
| 2 | 0.30 | 0.75 | RANSAC removes outliers, homography improves |
| 3 | 0.15 | 0.90 | Stable homography with good alignment |
| 4 | 0.10 | 0.93 | Fine tuning improves alignment slightly |
| 5 | 0.08 | 0.95 | Converged homography with minimal error |
aligned_img after applying homography?
import cv2
import numpy as np
img1 = cv2.imread('img1.jpg')
img2 = cv2.imread('img2.jpg')
pts1 = np.array([[10,10],[100,10],[100,100],[10,100]])
pts2 = np.array([[12,14],[102,12],[98,110],[14,108]])
H, _ = cv2.findHomography(pts1, pts2)
aligned_img = cv2.warpPerspective(img1, H, (img2.shape[1], img2.shape[0]))H, status = cv2.findHomography(pts1, pts2) aligned = cv2.warpPerspective(img1, pts1, (img2.shape[1], img2.shape[0]))