How to convert and get a metric in one command?

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
wobsie

How to convert and get a metric in one command?

Post by wobsie »

I'm comparing, thresholding, and calculating a metric in two steps:

1) generate a grayscale difference image and threshold it:
convert img1.jpg img2.jpg -compose difference -composite gray -threshold 25% diff.jpg

2) get average intensity:
identify -format "%[mean]" diff.jpg

This gives me a single number that summarizes how different the two images are. My question is, is there a way to do this in a single command? And is there a way to do it w/o generating an image? I just want the number.

Thanks.
wobsie

Re: How to convert and get a metric in one command?

Post by wobsie »

I got it!

convert img1.jpg img2.jpg -compose difference -composite gray -threshold 25% -format "%[mean]" info:

Phew. Sorry to take up space here.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How to convert and get a metric in one command?

Post by anthony »

For other notes and methods for getting various image metrics for compareing lots and lots of images, look at IM Examples Metrics.
http://imagemagick.org/Usage/compare/

I have been struggling to find ways of finding matching or simular images of various sorts and thes notes represent my struggles.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply