Page 1 of 1

%[mean] vs verbose info for a specific channel

Posted: 2010-08-20T01:34:21-07:00
by benjay
Hi

I want to find out the mean of a specific channel (red, in this case). But doing this

Code: Select all

identify -format "%[mean]" -channel Red image.png
returns a number that does not correspond to my own calculation. (It returns 29126.7, but it should be 6.2222 instead)
I used a 3 by 3 pixel image, where I calculated the mean by hand.

On the opposite, if I do this:

Code: Select all

identify -verbose image.png
the numbers for the mean value under Red, Green and Blue do correspond to my results.
Shouldn't this be the same?
Thank you in advance

Re: %[mean] vs verbose info for a specific channel

Posted: 2010-08-20T09:58:20-07:00
by fmw42
identify -format "%[mean]" info:

returns the global mean from all channels combined.

you want (so as to match the verbose info statistics)

identify -format "%[fx:mean.r] info:

to get the red channel. or mean.g or mean.b to get the green or blue channels.

Note that [fx:mean] returns values in the range 0 to 1 whereas [mean] returns values in range 0 to quantumrange (255 for 8-bit and 65535 for 16-bit IM compiles)