python - To use OpenCV/cv2 to compare and mark the difference between 2 images (with pictures) -


i want use python , cv2 compare 2 images, below.

(python 2.7 + windows)

c:\original.jpg

c:\original.jpg

c:\edited.jpg

edited.jpg

pretty straight forward can below , save picture showing difference:

import cv2   original = cv2.imread("c:\\original.jpg") edited = cv2.imread("c:\\edited.jpg")  diff = cv2.subtract(original, edited)  cv2.imwrite("c:\\diff.jpg", diff) 

the result like:

c:\diff.jpg

c:\diff.jpg

further, want difference shown in picture, based on files compared. in word, want have picture circle or mark difference, based on “edited.jpg”. possible?

(thinking 1 of ways be, identify visible area in "diff.jpg", draw circle area in "edited.jpg"?)

thanks micka's above. below added, , 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


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -