Display difference of two images

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
ertank
Posts: 13
Joined: 2018-06-19T08:27:55-07:00
Authentication code: 1152

Display difference of two images

Post by ertank »

Hello,

I have rather odd request. Below are two images, there is seemingly a software which produces 3rd image (the difference). I could not understand what method they use. Asking in here with the hope someone may understand it better than me.

Background information: There are car repair shops or maintenance places. They are taking picture of the bottom of a car. Next visit, another picture taken and people would like to see what has changed. How that picture taken is not known to me. Seems like a fish eye lens, or a stitch of several pictures.

Image 1: https://imgur.com/a/qABBRjD
Image 2: https://imgur.com/a/TH9xVoz
Difference of 1 and 2: https://imgur.com/a/LXsQkKx

Any help is appreciated.

Thanks.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Display difference of two images

Post by fmw42 »

Please, always provide your IM version and platform when asking questions, since syntax may differ. Also provide your exact command line and if possible your images.

See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at http://www.imagemagick.org/discourse-se ... f=1&t=9620

For novices, see

http://www.imagemagick.org/discourse-se ... f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown

If the two images are perfectly aligned with each other, you can use the compare function or -compose difference -composite.

See
http://www.imagemagick.org/script/compare.php
http://www.imagemagick.org/Usage/compare/
http://www.imagemagick.org/Usage/compose/#compose
http://www.imagemagick.org/Usage/compose/#difference


Your images are not well aligned nor the same size. So you will see lots of differences.

Unix syntax:

Input:
Image

Image


Darker Red is more different:

Code: Select all

compare -metric rmse image1.jpg image2.jpg diff.png
Image

Blue is more different than red:

Code: Select all

convert image1.jpg image2.jpg -compose difference -composite \
\( xc:red xc:orange xc:yellow xc:green1 xc:cyan xc:blue xc:blueviolet \
+append -filter Cubic -resize 512x1! \) \
-clut diff2.png
Image
Post Reply