Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 17945

technical drawing comparison with python PIL

$
0
0

I would like to compare two technical drawings (both are JPGs with the same size):

In a first step I started to compare the images with the following code:

from PIL import Image, ImageChopsimg1 = Image.open('IMGA.jpg')img2 = Image.open('IMGB.jpg')diff = ImageChops.difference(img1, img2)im1 = diff.save("difference.jpg") 

The result represents perfectly the differences between the images.

enter image description here

Combining the "difference.jpg" with "IMGB.jpg" and a completely red image (red.jpg) leads to the following result: (like shown in this thread: How can i use a black and white image to mask an image to another image in python using Pillow?)

av1  = Image.open('red.jpg').convert('RGB').resize(img1.size)av2  = Image.open('IMGB.jpg').convert('RGB').resize(img1.size)mask = Image.open('difference.jpg').convert('L')Image.composite(av1,av2,mask).save('result_preview.jpg')

This is nearly what i want to achieve. All the differences are marked red however you are not able to see if something was added or removed from the second image.

enter image description here

Is there any possibility to generate an image where all things added are represented e.g. in blue and all the things removed in red like in this photoshop example?

enter image description here


Viewing all articles
Browse latest Browse all 17945

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>