I'm using a feature point detection algorithm I found in a tutorial as shown below. The output of this code are lines drawn between the two images where feature points match.
Here's what I would like to know: Is there a way to return some value (floating point value) to determine if the two images are almost same, somewhat similar or not same?
def feature_matching():
img1 = cv2.imread('image1.jpeg', 0)
img2 = cv2.imread('image2.jpeg', 0)
# Initiate SIFT detector
sift = cv2.SIFT()
# find the keypoints and descriptors with SIFT
kp1, des1 = sift.detectAndCompute(img1,None)
kp2, des2 = sift.detectAndCompute(img2,None)
# BFMatcher with default params
bf = cv2.BFMatcher()
matches = bf.knnMatch(des1,des2, k=2)
# Apply ratio test
good = []
for m,n in matches:
if m.distance < 0.75*n.distance:
good.append(m)
#gray1 = cv2.cvtColor(img1,cv2.COLOR_BGR2GRAY)
#gray2 = cv2.cvtColor(img2,cv2.COLOR_BGR2GRAY)
# cv2.drawMatchesKnn expects list of lists as matches.
img3 = drawMatches(img1,kp1,img2,kp2,good)
plt.imshow(img3),plt.show()