Find unchanged areas on multiple images

I'm trying to detect the areas that don't change between 40-50 images (basically the unchanged pixels). For simplicity I'll provide an example with only 3 images:

This could be the output of the program, a mask showing what was untouched in those 3 images.

I've tried with compare from ImageMagick:

compare *.png -fuzz 20 -compose src mask.png

but doesnt seem to support an array of files, as it only produces the differences between the first two images: mask.png

Iterating trough all the images and joining the masks is discarded because it would generate lots of unwanted files (and probably be slow)

I'm aware that this is the same question as "how to get differences between images", but all the solutions given on those questions doesn't apply when there is more that 2 images

Is there any simple way to do it?


  • You can do that by computing the standard deviation across all the images and then taking the darkest region. (Low standard deviation means similar). Threshold at some level and negate so that those regions are white. This can be done using one of my bash unix shell scripts for imagemagick, called stdimage, which does the std across all the input images. Then threshold and negate.


    enter image description here

    enter image description here

    enter image description here

    stdimage image1.png image2.png image3.png miff:- | convert - -threshold 0 -negate result.png

    enter image description here

    Without my script, one could compute the std across all images by using -fx.

    If you have one image that is just the background, then you could subtract that from every image and threshold. Then multiply all the thresholded image together using -evaluate-sequence multiply. That would get the same result after negating.