fmw42 wrote: ↑2018-10-15T10:04:59-07:00
What you want is to do a difference and use that as a mask image to either make the difference transparent or red, for example.
Code: Select all
convert image1.jpg \
\( -clone 0 image2.jpg -compose difference -composite -threshold 10% -negate \) \
-compose copy_opacity -composite \
result.png
Code: Select all
convert image1.jpg \
\( -clone 0 image2.jpg -compose difference -composite -threshold 10% -negate \) \
-compose copy_opacity -composite \
-background red -compose over -flatten \
result2.png
Note that you could have used compare also to show only where they are different. But JPG is lossy and the two images won't be identical even where they look the same due to JPG compression. So that is why I had to threshold above and have to use -fuzz below.
Code: Select all
compare -fuzz 15% -metric rmse image1.jpg image2.jpg diff.png
The red shows the difference and the rest of the image is subdued in contrast simply to show the image, but if it is not red, then it means the two are the same (within the fuzz value).
Thanks for the quick reply, Fred.
Is there any way you could do a quick explanation of what your second convert script is doing? That's pretty similar to what I want to do. If not, that's understandable and I can dissect the pieces myself.
Another question: Could that convert script support more than two inputs? Or is the -compose difference limited to one image compared to one other?
Ultimately, I want to build a script that will accept ~1000 images (in batches), and create a "template" image that contains only the pixels present in all images, except where there was variance between the images a color would be displayed such as red below. After this template is obtained, I want to check if another input image contains at least all the pixels present in the template, including white pixels.
I apologize if my posts have been unclear, English isn't my first language and I'm new to IM!