Is there a simple way to use the -fx command with raw values rather than normalised, i.e. 0-1
for example
convert rose: -fx 'debug(u)' null
I would like to work with the raw 16bit value stored, or even its 8-bit equivalent, if possible.
-fx return raw values?
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: -fx return raw values?
The constant Fred give, 65535, is correct for Q16 IM. For portability across any Q-number IM, use QuantumRange.
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: -fx return raw values?
Good point.
But if he is on Q16 and wants 8-bit values, then it would need to be
Code: Select all
convert rose: -fx 'debug(255*u)' null:
Re: -fx return raw values?
Thanks for those, was just wondering if there was switch as it can be a bit laborious, with long fx statements.
With the precision of the value give by of u, will i get the exact value when I do 65535*u?
With the precision of the value give by of u, will i get the exact value when I do 65535*u?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: -fx return raw values?
u is a float in the range of 0 to 1. So multiplying by 65535 would produce a floating point value. I do not know if it is being rounded or truncated to an integer. But I suspect that the IM developers have done whatever is correct to make it properly an integer.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: -fx return raw values?
It isn't deliberately rounded or truncated to an integer, but the current "-precision" setting may round it to an integer. The output may not be an integer, eg it could be "29183.999999999996". If an integer is required, a common technique is to add 0.5 and take the floor of the result, egfmw42 wrote:I do not know if it is being rounded or truncated to an integer. But I suspect that the IM developers have done whatever is correct to make it properly an integer.
Code: Select all
convert toes.png -precision 19 -fx debug(floor(QuantumRange*u+0.5)) null:
snibgo's IM pages: im.snibgo.com