Paint the image magick comparision output

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
shahire
Posts: 4
Joined: 2019-12-04T17:51:30-07:00
Authentication code: 1152

Paint the image magick comparision output

Post by shahire » 2019-12-04T17:56:52-07:00

Hello,
I am using ImageMagick 7 for our visual testing framework.i am using below command to compare the images,

Code: Select all

magick compare -highlight-color magenta -lowlight-color transparent  -metric RMSE -fuzz 10% image1.png image2.png -compose exclusion diff.png
However i want to paint the difference instead of source and destination content overlapping with magenta color.
Could you please provide some pointer how i can achieve using image magick.

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

Re: Paint the image magick comparision output

Post by fmw42 » 2019-12-04T18:04:50-07:00

Perhaps you would be better using -compose difference -composite and then color the result

Code: Select all

magick image1.png image2.png -compose difference -composite -auto-level +level-colors black,red result.png
or

(unix syntax)

Code: Select all

magick image1.png image2.png -compose difference -composite -auto-level \
\( xc:red xc:orange xc:yellow xc:green1 xc:cyan xc:blue xc:blueviolet xc:black \
+append -flop -filter Cubic -resize 600x1! \) -clut result2.png
Please always provide your exact IM version and platform/OS as syntax may vary

shahire
Posts: 4
Joined: 2019-12-04T17:51:30-07:00
Authentication code: 1152

Re: Paint the image magick comparision output

Post by shahire » 2019-12-04T22:53:09-07:00

Thanks for quick solution.

Following is the IM version,
Version: ImageMagick 7.0.9-5 Q16 x86_64 2019-11-18 https://imagemagick.org
Operating Systems - unix

Actually i want to highlight the diff with magenta color so that all content would be visible,

Could you please check diff images on below URL, i am looking for the similar output from ImageMagick
https://help.applitools.com/hc/en-us/ar ... iff-Images

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

Re: Paint the image magick comparision output

Post by fmw42 » 2019-12-05T11:37:13-07:00

Perhaps this is what you want.

Input:

Image

Image

Unix syntax (highlight color is blue)

Code: Select all

convert lena_text.png -write mpr:img lena.png \
-compose difference -composite -threshold 0 \
\( +clone -fill blue -colorize 100 \) \
mpr:img \
-reverse \
-compose over -composite \
lena_diff.png
Image

shahire
Posts: 4
Joined: 2019-12-04T17:51:30-07:00
Authentication code: 1152

Re: Paint the image magick comparision output

Post by shahire » 2019-12-05T17:55:25-07:00

With given command close to what i am looking for, however the difference is overlapping with base image text/content.I want figure out the difference and paint region on base image.
Could please check below URLs with expected output and what we are getting by your command,
https://drive.google.com/drive/folders ... p=sharing

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

Re: Paint the image magick comparision output

Post by fmw42 » 2019-12-05T19:13:19-07:00

Imagemagick cannot do that, since it cannot identify text words. You could conceivably find the bound of the difference and fill that in. But you cannot highlight individual words with any reliability, in my opinion without some kind of OCR character recognition.

shahire
Posts: 4
Joined: 2019-12-04T17:51:30-07:00
Authentication code: 1152

Re: Paint the image magick comparision output

Post by shahire » 2019-12-05T23:24:31-07:00

Really appreciate your quick help.

Post Reply