Mobile app version of vmapp.org
Login or Join
RJPawlick971

: Imagemagick: how to compare two images and obtain a third image with the differences? Anyone knows how to make imagemagick output an image with the differences between two other images? Similar

@RJPawlick971

Posted in: #Imagemagick

Anyone knows how to make imagemagick output an image with the differences between two other images? Similar to a diff, but not exactly the same. Any other Windows/Linux commandline tool that can be scripted would be good too (because I need to do this with hundreds of images).

Quick and dirty example:
Let's say I have these two images:




And I need to obtain only the curtain (and any other differences if there were), with everything else transparent.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @RJPawlick971

1 Comments

Sorted by latest first Latest Oldest Best

 

@Gail6891361

It's the first example in the ImageMagick documentation:

magick compare -compose src du2SX.png ejUjy.png difference.png
magick difference.png -transparent "#CCCCCC" alpha.png


In "difference.png" the identical pixels are rendered in mid-gray:


The second command makes those pixels transparent:


Using +transparent instead of -transparent inverts things so you get:



Finally, use this as a mask

magick composite -compose copy_opacity alpha.png du2SX.png result.png


to get:

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme