identify -format %[mean] gives 65535 on 8-bit gray 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
inwelkin@gmail.com
Posts: 8
Joined: 2015-03-13T14:35:09-07:00
Authentication code: 6789

identify -format %[mean] gives 65535 on 8-bit gray image

Post by inwelkin@gmail.com »

Hi,

I have an image with following info:
gray.jpg JPEG 12558x8776 12558x8776+0+0 8-bit PseudoClass 256c 1.937MB 0.000u 0:00.000
I am using identify to get mean gray value and standard deviation of this image:

Code: Select all

identify -format %[mean]%[standard-deviation] gray.jpg
The results returned are: 65535, 1396.33

Why is the max and std exceeding 2^8 - 1? Please advise.

Thank you,
Muye
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: identify -format %[mean] gives 65535 on 8-bit gray image

Post by snibgo »

I assume you are using Q16 ImageMagick. When it reads images, it expands values to 16 bits, and shows those values.
snibgo's IM pages: im.snibgo.com
inwelkin@gmail.com
Posts: 8
Joined: 2015-03-13T14:35:09-07:00
Authentication code: 6789

Re: identify -format %[mean] gives 65535 on 8-bit gray image

Post by inwelkin@gmail.com »

Hi,

Thanks! Yes, I use IM 6.7.8 Q16. Though when I run

Code: Select all

identify -verbose gray.jpg 
,
I got the output in desired range:
Channel statistics:
Gray:
min: 0 (0)
max: 255 (1)
mean: 5.43318 (0.0213066)
standard deviation: 16.1351 (0.0632749)
Why's the output from the two commands different? Is there a way I can get mean = 5.43318 from "identify -format %[mean]"?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: identify -format %[mean] gives 65535 on 8-bit gray image

Post by fmw42 »

try

Code: Select all

identify -format %[fx:255*mean]" yourimage
inwelkin@gmail.com
Posts: 8
Joined: 2015-03-13T14:35:09-07:00
Authentication code: 6789

Re: identify -format %[mean] gives 65535 on 8-bit gray image

Post by inwelkin@gmail.com »

This worked, thanks a lot!
Post Reply