Extracting statistical information of image

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
kebs
Posts: 1
Joined: 2018-07-05T04:20:36-07:00
Authentication code: 1152

Extracting statistical information of image

Post by kebs »

Hello (first post here)

I have a large set of 3 channels images. I want to get the dynamic range of each of them.

Final objective: a csv file holding something like:

Code: Select all

#file;red-min;red-max;red-mean;red-stddev;green-min;green-max;....
"Identify" gives me all these informations:

Code: Select all

$ Identify -verbose myimage.png
but I can't figure out how to extract what I want.

I have checked this
https://www.imagemagick.org/script/identify.php
where it says that I can extract some information, for example using the "features" option:
https://www.imagemagick.org/script/comm ... p#features
But this is pretty much unclear.

On the other hand, I see this topic:
viewtopic.php?f=1&t=32127
where it says that this:

Code: Select all

$ identify -format "%[fx.mean.r]" myimage.png
should get me the mean value of red channel.
Unfortunately, it does not work (empty output).

Same empty output with:

Code: Select all

$ identify -format %[fx.mean.r] myimage.png
Is this a version problem? Or did I miss something in the syntax ?

FWIW:

Code: Select all

$ identify --version
Version: ImageMagick 6.7.7-10 2018-06-11 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP  
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Extracting statistical information of image

Post by snibgo »

I would use fx, for example:

Code: Select all

identify -format "%[fx:mean.r],%[fx:standard_deviation.r]" myimage.png
... but it needs colon ":" after "fx".

However, your version 6.7.7-10 is very old. I suggest you upgrade.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Extracting statistical information of image

Post by fmw42 »

Linux distributions do not upgrade the version number, they just patch. The latest patch was on 6/11/2018. So it should be more or less up to date if they patched for everything and not just security changes.

Personally, I don't think that is a wise approach, since one never knows how well they patch things.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Extracting statistical information of image

Post by snibgo »

Ah, yes, thanks, Fred. I forgot to look at the date.

Perhaps you mean, "I do not think that is a wise approach...".
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Extracting statistical information of image

Post by fmw42 »

I have fixed it. I have a spell checker that changes what I want to write while I am typing it and this happens often. I have to go back and proof read afterwards.
Post Reply