Possible bug/limitation of fx string formats

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/limitation of fx string formats

Post by fmw42 »

IM 7.0.7.1 Q16 HDRI Mac OSX Sierra.

If I do the following I think I get correct results.

Code: Select all

magick -size 64x64 gradient:            -blur 1x1 -define quantum:format=floating-point -depth 64 gradient_u.tif
magick -size 64x64 gradient: -rotate 90 -blur 1x1 -define quantum:format=floating-point -depth 64 gradient_v.tif
magick gradient_u.tif gradient_v.tif -fx 'u/v' -define quantum:format=floating-point -depth 64 divide.tif
magick identify -verbose -precision 15 divide.tif
min: 291.016 (0.00444061)
max: 1.47581e+07 (225.194)
mean: 268324 (4.09437)


However, -precision does not affect the min, max, mean verbose information.



More importantly, fx string formats do not seem to give the same answers. Perhaps there is clamping?

Code: Select all

magick -size 64x64 gradient:            -blur 1x1 -define quantum:format=floating-point -depth 64 gradient_u.tif
magick -size 64x64 gradient: -rotate 90 -blur 1x1 -define quantum:format=floating-point -depth 64 gradient_v.tif
magick gradient_u.tif gradient_v.tif -fx 'u/v' -precision 15 -format "min=%[fx:min]\n max=%[fx:max]\n mean=%[fx:mean] \n" info:
min=0
max=0
mean=4.09436179140917




But non-fx string format seem correct.

Code: Select all

magick -size 64x64 gradient:            -blur 1x1 -define quantum:format=floating-point -depth 64 gradient_u.tif
magick -size 64x64 gradient: -rotate 90 -blur 1x1 -define quantum:format=floating-point -depth 64 gradient_v.tif
magick gradient_u.tif gradient_v.tif -fx 'u/v' -precision 15 -format "min=%[min]\n max=%[max]\n mean=%[mean]\n" info:
min=291.015655517578
max=14758093
mean=268324.489530727
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Possible bug/limitation of fx string formats

Post by magick »

Fixed the precision problem. And here is the command you want to use to get expected results:

Code: Select all

magick gradient_u.tif gradient_v.tif -fx 'u/v' -precision 15 -format "minima=%[fx:minima]\n maxima=%[fx:maxima]\n mean=%[fx:mean] \n" info:
Max() and min() are functions, see https://www.imagemagick.org/script/fx.php.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Possible bug/limitation of fx string formats

Post by fmw42 »

magick wrote: 2017-09-13T06:26:16-07:00 Fixed the precision problem. And here is the command you want to use to get expected results:

Code: Select all

magick gradient_u.tif gradient_v.tif -fx 'u/v' -precision 15 -format "minima=%[fx:minima]\n maxima=%[fx:maxima]\n mean=%[fx:mean] \n" info:
Max() and min() are functions, see https://www.imagemagick.org/script/fx.php.
Thanks. I keep forgetting that fx uses different forms of min and max (minima and maxima). Sorry for the false alarm.
Post Reply