comparing images of different sizes

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
dwlaw17

comparing images of different sizes

Post by dwlaw17 »

I need to remove the margins in pdf files and make sure that the resulting pdfs still visually look the same as the original ones (eg I want to make sure that no part of the content has been accidentally removed). I use convert to convert the original and new pdfs into a set of images and try to compare them.

However after removing the margins, the geometry and print size (as revealed by the command identify) are different. So I can't use compare to compare the two.

Does anyone have any suggestion on how I can compare them?

Also, there are many metrics that compare supports. Ideally I would like a number that indicates "degree of similarity" so I can double check on those who don't pass a certain threshold. What metric(s) would be suitable?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: comparing images of different sizes

Post by fmw42 »

post links to example images. I am not sure what the issue is that causes the two images to be different sizes? Is it a scaling issue? You can either crop one image to be the same size as the other and compare or resize one image to be the same size as the other and compare. I generally use -metric rmse which tells how different they are. So just threshold on the amount of difference you can tolerate. Alternately, you can try my script, similar, to get the normalized cross correlation metric, which will be 1 if the same and 0 if totally different (but they need to be the same size). See my signature link.

also see topic viewtopic.php?f=1&t=15264
Post Reply