# BAD EXAMPLE! # #This bad code shows the problems with underflow/overflow that result # if you do math with 8 bit images... # # Jay Summet - Summer 2015 # # Python 2.7, OpenCV 2.4.x import cv2 a = cv2.imread("a.jpg") b = cv2.imread("b.jpg") #Doing math with uint8 images will suffer from overflow and underflow! #Pure subtraction: c = a-b cv2.imshow("pure subtract", c) cv2.waitKey(0) c = a+b cv2.imshow("add", c) cv2.waitKey(0) c = a+b/2 cv2.imshow("avg", c) cv2.waitKey(0)