Page 1 of 1

"distortion" can't be used in fx

Posted: 2019-07-18T16:19:27-07:00
by snibgo
We can do a "compare" in a magick command like this:

Code: Select all

magick rose: rose: -metric RMSE -compare -format %[distortion] info:

0
The "distortion" is always a number, but for some reason we can't use it in an fx expression:

Code: Select all

magick rose: rose: -metric RMSE -compare -format %[fx:distortion] info:

magick: unable to parse expression `distortion' @ error/fx.c/FxGetSymbol/1833.
Being able to use it in an fx expression would simplify things when we need to compare the distortion number to a limit. Can this be corrected, please?

Tested with IM v7.0.7-28 on Windows 8.1.

Re: "distortion" can't be used in fx

Posted: 2019-07-18T16:40:20-07:00
by fmw42
None of the %[xxx] can be used in an expression in fx: computations. You need to store them in a variable and then use the variable in the fx: computation. I would agree that it is too bad. I think it was done that way, since most of the single lower and upper case letters were used already in the string formats. I am not sure if it is even possible to add more names to -fx. If possible that would be nice. But note that for example %[mean] has range 0 to quantum range and %[fx:mean] is in the range 0 to 1. Though that is not something that could not be overcome as %[fx:mean*quantumrange].

Re: "distortion" can't be used in fx

Posted: 2019-07-18T18:05:01-07:00
by snibgo
I think the change required is simple, in FxGetSymbol() in fx.c. But I could be wrong. I can multiply by QuantumRange if I need to. For example:

Code: Select all

magick rose: rose: -metric RMSE -compare -format %[depth] info:
8

magick rose: rose: -metric RMSE -compare -format %[fx:depth] info:
0.000244144

magick rose: rose: -metric RMSE -compare -format %[fx:depth*quantumrange] info:
16
(I don't know why the last result is 16, not 8?)