Page 1 of 1

Actual pixel value

Posted: 2016-04-05T23:41:46-07:00
by mikjsmith
Version: ImageMagick 6.9.1-2 Q16 x86 2015-04-14

I using the following to extract a pixel value (I think this is a normalised percentage value)

convert t_mean.tif -precision 20 -format '%[pixel:p{40,30}]' info:-

Is there an easy way to get the actual pixel value itself?

thanks

mike

Re: Actual pixel value

Posted: 2016-04-06T00:09:23-07:00
by snibgo
There is one value per channel. We often use a suffix ".r", ".g" or ".b". I generally use fx, and multiply by QuantumRange if I (rarely) want the actual number instead of a percentage. For example:

Code: Select all

f:\web\im>%IM%convert rose: -precision 20 -format [fx:p{40,30}.r*QuantumRange] info:

59624

Re: Actual pixel value

Posted: 2016-04-12T05:10:41-07:00
by mikjsmith
I tried this
convert t_mean.tif -precision 20 -format '%[pixel:p{40,30}]' info:-
srgb(3.464815393896963

which was OK, then this

convert t_mean.tif -precision 20 -format [fx:p{40,30}*r.32] info:-
convert: unable to open image `p30*r.32]': No such file or directory @ error/blob.c/OpenBlob/2702.
convert: no decode delegate for this image format `[FX' @ error/constitute.c/ReadImage/501.

have I done something stupid here?!

Re: Actual pixel value

Posted: 2016-04-12T05:21:56-07:00
by snibgo
[fx:p{40,30}*r.32]
What is "r.32"? Why is there no percent % symbol there?

Re: Actual pixel value

Posted: 2016-04-12T09:47:12-07:00
by fmw42
[pixel:...] will give you either an srgb triplet or a color name. If you want normalize (0-1) values then use [fx:...]

Code: Select all

convert rose:[1x1+40+30] -format "%[fx:u.r],%[fx:u.g],%[fx:u.b]\n" info:
0.909804,0.211765,0.227451

or scale to range 0-255

Code: Select all

convert rose:[1x1+40+30] -format "%[fx:round(255*u.r)],%[fx:round(255*u.g)],%[fx:round(255*u.b)]\n" info:
232,54,58