possible bug in fx calcs in HDRI Q32

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

possible bug in fx calcs in HDRI Q32

Post by fmw42 »

If I do the following in IM 6.6.3.4 Q16 HDRI Mac OSX Tiger,


gain1=`convert xc:gray -format "%[fx:1/maxima]" info:`
echo "gain1=$gain1"

convert xc: -format "%[fx:quantumrange]" info:
max=`convert xc:gray -format "%[max]" info:`
echo "max=$max"
gain2=`convert xc: -format "%[fx:quantumrange/$max]" info:`
echo "gain2=$gain2"


Then I get gain1=gain2=2

But if I do the same in Q32 HDRI, I get

gain1=2.02381
gain2=2.02381e+18

I think the fx calc has problems with both numerator and denominator are in scientific notation, as here we have:

QuantumRange=4.29497e+09
and
max=2.12222e+09


and

gain2=4.29497e+09/2.12222e+09

which should be about 2, but ends up as 2.02381e+18. Looks like the two e+9 are added to get e+18 rather than subtracted to get e+0
Last edited by fmw42 on 2010-08-12T12:29:01-07:00, edited 2 times in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug in fx calcs scientific notation

Post by fmw42 »

Here is a simple test:


val1=2e+6
val2=1e+5
convert xc: -format "%[fx:$val1/$val2]" info:
2e+11

but it should be 20 or 2e+1

This may just be a case of FX calcs using scientific notation and not related to HDRI or Q32.

PS. I get the same bad result above in Q16 HDRI AND Q16 non-HDRI. So it looks like it is an fx calc problem that is not HDRI limited.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: possible bug in fx calcs in HDRI Q32

Post by magick »

We can reproduce the problem you posted and have a patch in ImageMagick 6.6.3-5 Beta available by sometime tomorrow.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug in fx calcs in HDRI Q32

Post by fmw42 »

This works in IM 6.6.3.6 Q16 HDRI

val1=2e+6
val2=1e+5
convert xc: -format "%[fx:$val1/$val2]" info:
20

Thanks.
Post Reply