# Jay Summet #Calculating the difference/error between a 100 pixel "overlap" #strip of two images. import cv2 import numpy as np #Used for final output display def scaleTo8Bit(image, displayMin = None, displayMax=None ): if displayMin == None: displayMin = np.min(image) if displayMax == None: displayMax = np.max(image) np.clip(image, displayMin, displayMax, out=image) image = image - displayMin cf = 255. / (displayMax - displayMin) imageOut = ( cf * image).astype(np.uint8) return imageOut #Linux window/threading setup code. cv2.startWindowThread() cv2.namedWindow("A") cv2.namedWindow("B") cv2.namedWindow("Error") A = cv2.imread("A.jpg", cv2.IMREAD_GRAYSCALE) B = cv2.imread("B.jpg", cv2.IMREAD_GRAYSCALE) #Select the 100 rightmost pixels of A and leftmost of B: A100 = A[:, -100: ] B100 = B[:, 0:100 ] #Display the output cv2.imshow("A", A100) cv2.imshow("B", B100) #Convert to float: A100 = A100.astype(float) B100 = B100.astype(float) diff = A100-B100 diff = np.square(diff) error = scaleTo8Bit(diff) cv2.imshow("Error", error) cv2.imwrite("overlap_error.png", error) cv2.waitKey(0)