0

I have the following issue. I have two images. Image 2 is basically Image 1 with an overlay. It's something that we added using a darkening blend-mode. The images are just grayscale images btw.

Now I'd like to create an new image, that contains only the difference between image 1 and 2. So a transparent png that if I just lay it over Image 1 without any blend mode, I'd have the same result as looking at image 2.

This is Image 1:

Image1

And this is Image 2:

Image2

I already played around a little bit with imagemagicks compare, but maybe I was missing the correct parameters, but I didn't get the result I am looking for...

The solution would need to be something that we can automate. So imagemagick would be awesome!

Georg
  • 3,664
  • 3
  • 34
  • 75
  • you can treat the images as matrices, just calculate the diference between them: img3 = img1 - img2. then you can recover: img1 = img3 + img2 also, take a look at https://stackoverflow.com/questions/27035672/cv-extract-differences-between-two-images – Hugo Apr 08 '21 at 19:04

1 Answers1

0


i don't know a lot about imagemagicks.
however, there is a python library that is super-simple to understand and implement for your wishes: pillow

you can :

  • import the Image package : from PIL import Image
  • upload images : img = Image.open("image.png") (works with a lot of file formats)
  • read its dimensions : width, height = img.size
  • read its pixels : color = img.getpixel((x, y)) (returns (r, g, b, a))
  • etc...

you can even generate a new image from this matrix and save it in OS...
so with a bit of manipulation, getting the difference of pixels between two images should not be too difficult...
hope it helped :)
kyros

Kyros
  • 43
  • 8