How may I get the value of a subtraction between two images? It can definitely display the difference, since there is even an output image which shows which parts of the picture is different from another.
I would appreciate your kind intellect to assist me
The value is a matrix, which you can view as a image, but obviously you could print out the values as well (though a million numbers in a listing is challenging for humans to interpret), or figure out some summary function that suits your goals, and make do with outputting one number.
Super simply explained this code takes two images (and removes most of the pictures colours, since I’m mostly interested in shapes) and subtracts them from each other
import cv2
ix = cv2.imread("test/default1.jpg")
iy = cv2.imread("test/default1_edited.jpg")
gx = cv2.cvtColor(ix, cv2.COLOR_BGR2GRAY)
gy = cv2.cvtColor(iy, cv2.COLOR_BGR2GRAY)
tmin = 192
tmax = 255
_, tx = cv2.threshold(-gx, tmin, tmax, cv2.THRESH_BINARY)
_, ty = cv2.threshold(-gy, tmin, tmax, cv2.THRESH_BINARY)
sb = tx - ty
out = sb
while True:
cv2.imshow("Output :)", out)
key = cv2.waitKey(1) & 0xFF
if key == ord("q"):
break
You’re so right! I’ve tried with something like this, however with no luck but what you said will be useful I need to make a “summary function” somehow if there is not a way to do this Thank you so much for the help