Page 1 of 1

[Solved] fx operator + while() option doubt

Posted: 2012-04-24T07:55:40-07:00
by markmarques
I am trying to use a small script with the latest version 6.7.6 in windows ...
to calculate the gamma value something like

Code: Select all

 
for /f "tokens=*" %%a in ('convert %1 -format "%%[fx:(log(mean)/log(0.5))]" info: ') DO  set gamma=%%a
for /f "tokens=*" %%a in ('convert null: -format "%%[fx: mgama= %gamma: =% ; while ( mgama > 3.5, mgama = mgama / 2 )  ]" info: ') DO set gamma=%%a
convert %1 -gamma %gamma%  PNG:%1.png
but the previous code does not work ... I get:
"The syntax of the command is incorrect "
If I try something like

Code: Select all

for /f "tokens=*" %%a in ('convert null: -format "%%[fx: while ( %gamma% > 3.5, %gamma% / 2 )  ]" info: ') DO set gamma=%%a
I freezes the batch processing ...
Any ideas ?

According to the docs in fx operator
" while(condition,expression): interate while the condition is not equal to 0 "

What am I doing wrong ?

Re: fx operator + while() option doubt

Posted: 2012-04-24T09:31:03-07:00
by fmw42
try replacing null: with xc:

Re: [Solved] fx operator + while() option doubt

Posted: 2012-04-24T09:56:06-07:00
by markmarques
It worked with the xc: option ...
and something like this :

Code: Select all

for /f "tokens=*" %%a in ('convert xc: -format "%%[fx:  mgama= %gamma2: =% ; while ( mgama > 3.5, mgama = mgama- (mgama / 10)  )  ]" info: ') DO set gamma2=%%a
Thanks ...

Re: [Solved] fx operator + while() option doubt

Posted: 2012-04-24T10:35:48-07:00
by fmw42
Correct.

null: means no image.

xc: by itself means an image of 1x1 that is transparent, I think, but am not positive, or perhaps just a placeholder image?

Convert needs some image to process fx expressions no matter what size or kind.

see
http://www.imagemagick.org/Usage/transf ... fx_escapes

Re: [Solved] fx operator + while() option doubt

Posted: 2012-04-25T20:00:21-07:00
by anthony
Never saw the 'while' expression in FX. I wonder when it was added! It isn't in change log

Re: [Solved] fx operator + while() option doubt

Posted: 2012-04-25T21:07:04-07:00
by fmw42
Magick wrote me on 11/2/2011

I added robust support for scientific notation to -fx as well as new funcs
such as not(), guass(), squish(), while(), and the Phi constant. In all
likelyhood I broke more than I fixed. Send me any expressions that used
to work but fail now and I'll use the expression to debug -fx.

Note, wait an hour before you download 6.7.3-4 Beta.

Re: [Solved] fx operator + while() option doubt

Posted: 2012-04-26T00:19:31-07:00
by anthony
What is the squish function for? From the web docs...
squish(x): squish function; squish(x)=1.0/(1.0+exp(4.0*x))

Note for IMv7 development...
I am trying to decide if I need to remove the % operator from FX, so I can do percent substitutions into the operator before it is processed (perhaps hundreds of times).
The % is the modulus function and mod() function has been in place for some time.

If I allow only multi-character percent escapes, EG: %[...] then their is no conflict as that is a syntax error normally in FX. That is it will not occur naturally! But if you want to be able to do other single letter escapes like %x (X resolution or density) then I will need to remove '%' from normal use.

Note the most useful single letter escapes (width, height, depth, index) are already included as FX varables so that is not a big loss.

I also plan to include some IF type percent escapes, as well as access to things not available at this time like background, and fill colors, and other option settings not currently available. I am surverying the what is available right now, and making improvments before the more serious work.

Re: [Solved] fx operator + while() option doubt

Posted: 2012-04-26T10:26:17-07:00
by fmw42
squish(x): squish function; squish(x)=1.0/(1.0+exp(4.0*x))
Not sure what it is for, but it is just an exponentially decreasing function as shown by

im_graph "-fx 2*squish(u)" squish.gif