SIFT Algorithm for Image Comparison

Images for Test
import cv2
img1 = cv2.imread("Path to image 1",0)
img2 = cv2.imread("Path to image 2",0)
# check for similaritiessift = cv2.xfeatures2d.SIFT_create()# check keypoints and descriptions of imageskp_1,desc_1 = sift.detectAndCompute(img1,None)
kp_2,desc_2 = sift.detectAndCompute(img2,None)
index_params = dict(algorithm=0, trees=5)
search_params = dict()
flann = cv2.FlannBasedMatcher(index_params, search_params)
matches = flann.knnMatch(desc_1, desc_2, k=2)
result = cv2.drawMatchesKnn(img1,kp1,img2,kp2,matches,None)
cv2.imshow("Correlation", result)
cv2.imshow("Image 1", img1)
cv2.imshow("Image 2", img2)
Correlated Images
  1. Rotation
  2. Scaling
  3. Image Brightness

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store