Good Day,
I have a script that takes screen cap of some of our pages. Then it compares the screen cap from a previous capture. Here is the command I am ussing
compare image1.png image2.png -compose src result.png
Now I am getting a message : compare.im6: image widths or heights differ
Is there a way to still compare the images if the have different widths and heights.
Take Note, I am comparing 1000s of images and I am not sure as to which one might have changed in width or height.
Thank you in advance.
Law
compareing 2 images with different dimension
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: compareing 2 images with different dimension
See the recent thread viewtopic.php?f=1&t=26882
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: compareing 2 images with different dimension
compare can be run with two image that are different sizes using -subimage-search option. That will try to move the smaller image around the larger one and tell you the location for the best match. Once you have that match, you can crop the larger image so that it has the same size as the smaller image. Then you can compare the two same sized images to get a visual of the differences. Actually the subimage-search mode produces two output images. The first shows where the to images match on the larger image size. The second, I believe, gives you the difference image for that location with differences marked in red. But you may want to use -compose difference on the two same sized images to get a better non-binary coloration showing the differences as described in the reference from snibgo above. Or see the -highlight-color and the -lowlight-color for colorizing the compare results.
See
http://www.imagemagick.org/script/compare.php
http://www.imagemagick.org/Usage/compare/
viewtopic.php?f=1&t=14613&p=51076&hilit ... ric#p51076 (but now needs -subimage-search added)
http://www.imagemagick.org/Usage/compose/#difference
It might help us understand your problem, if you upload a pair of images that you want to compare to some place like dropbox.com and put the URL here. Also it is always a good idea to provide your IM version and platform.
See
http://www.imagemagick.org/script/compare.php
http://www.imagemagick.org/Usage/compare/
viewtopic.php?f=1&t=14613&p=51076&hilit ... ric#p51076 (but now needs -subimage-search added)
http://www.imagemagick.org/Usage/compose/#difference
It might help us understand your problem, if you upload a pair of images that you want to compare to some place like dropbox.com and put the URL here. Also it is always a good idea to provide your IM version and platform.
Re: compareing 2 images with different dimension
Here 2 sample images i have
https://www.dropbox.com/s/j8nxfzoty47ll ... 1.png?dl=0
https://www.dropbox.com/s/3dv3ny1tnb72d ... 2.png?dl=0
What is the proper syntax to use -subimage-search?
I am on a linux mint machine.
ImageMagick version is 6.7.7
Cheers,
Law
https://www.dropbox.com/s/j8nxfzoty47ll ... 1.png?dl=0
https://www.dropbox.com/s/3dv3ny1tnb72d ... 2.png?dl=0
What is the proper syntax to use -subimage-search?
I am on a linux mint machine.
ImageMagick version is 6.7.7
Cheers,
Law
Last edited by lkawcab on 2015-01-27T15:53:12-07:00, edited 1 time in total.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: compareing 2 images with different dimension
Code: Select all
compare -metric rmse -subimage-search image1.png image2.png cmp1.png cmp2.png
The larger image must be listed first.
Look at cmp2.png. It is the size of the larger image1.png and shows the best match with differences in red.
The values returned are
rmse difference in 0 to 65535 graylevel range and (rmse difference in range 0 to 1) and the offset coordinates of the small image relative to the top left corner of the large image. The rmse values show a 5.08551% error or difference.
If you just want the match score and don't care about the difference image, then just do
Code: Select all
compare -metric rmse -subimage-search image1.png image2.png null:
The proper syntax is
Code: Select all
compare -metric rmse -subimage-search image1.png image2.png cmp.png
Re: compareing 2 images with different dimension
I ran the command compare -metric rmse -subimage-search image2.png image1.png cmp2.png cmp1.png (because image2 is bigger for my case.) I got the results below:
compare.im6: unable to open image `cmp2.png': No such file or directory @ error/blob.c/OpenBlob/2638.
compare.im6: unable to open file `cmp2.png' @ error/png.c/ReadPNGImage/3667.
compare.im6: image size differs `image2.png' @ error/compare.c/SimilarityMetricImage/1794.
compare.im6: unable to open image `cmp2.png': No such file or directory @ error/blob.c/OpenBlob/2638.
compare.im6: unable to open file `cmp2.png' @ error/png.c/ReadPNGImage/3667.
compare.im6: image size differs `image2.png' @ error/compare.c/SimilarityMetricImage/1794.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: compareing 2 images with different dimension
My mistake, the command needs only one output, but makes two from the same name with -0 and -1 appended. So try
and look at cmp-0.png
I will edit my command above.
P.S. If you are using the same images as posted, then image1 is larger than image2! The larger image must be listed first.
Code: Select all
compare -metric rmse -subimage-search image2.png image1.png cmp.png
I will edit my command above.
P.S. If you are using the same images as posted, then image1 is larger than image2! The larger image must be listed first.
Re: compareing 2 images with different dimension
Thank you! It works like a charm!
For clarification, will this work when both images have the same size?
For clarification, will this work when both images have the same size?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: compareing 2 images with different dimension
Yes it appears to do so. But if for some reason it does not, then for same size images, leave off the -subimage-search.