Skip to content Skip to sidebar Skip to footer

To Use Opencv/cv2 To Compare And Mark The Difference Between 2 Images (with Pictures)

I want to use Python and cv2 to compare 2 images, like below. (Python 2.7 + Windows) c:\Original.jpg c:\Edited.jpg Pretty straight forward I can do below and save a picture showi

Solution 1:

Thanks to Micka's help above. Below is added, and it works.

im = cv2.imread('c:\\diff.jpg')
im1 = cv2.imread('c:\\Edited.jpg')


imgray = cv2.cvtColor(im,cv2.COLOR_BGR2GRAY)
ret,thresh = cv2.threshold(imgray,127,255,0)
contours, hierarchy = cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)

cv2.drawContours(im1, contours, -1, (0,255,0), 1)
cv2.imwrite("c:\\see_this.jpg", im1)

c:\see_this.jpg

c:\see_this.jpg

Post a Comment for "To Use Opencv/cv2 To Compare And Mark The Difference Between 2 Images (with Pictures)"