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
Actual pixel value
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Actual pixel value
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
snibgo's IM pages: im.snibgo.com
Re: Actual pixel value
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?!
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?!
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Actual pixel value
What is "r.32"? Why is there no percent % symbol there?[fx:p{40,30}*r.32]
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Actual pixel value
[pixel:...] will give you either an srgb triplet or a color name. If you want normalize (0-1) values then use [fx:...]
0.909804,0.211765,0.227451
or scale to range 0-255
232,54,58
Code: Select all
convert rose:[1x1+40+30] -format "%[fx:u.r],%[fx:u.g],%[fx:u.b]\n" info:
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: