Page 1 of 1

request enhancement -evaluate exp

Posted: 2010-10-18T17:54:52-07:00
by fmw42
I would like to request an addition to the list of -evaluate functions. This is open for discussion and feedback is welcome. Right now I only need this functionality for a script I working on. But this could be done using -function if more arguments are desired.


This would be

-evaluate exp arg

where this would be equivalent to


convert image -fx "$arg<0?exp($arg*u):1-exp(-$arg*u)" result

If arg is positive, one gets a rising exponential. If arg is negative, one gets a decaying exponential.

Image

Image

Note: by squaring the image first, one can get a Gaussian profile.

Re: request enhancement -evaluate exp

Posted: 2010-10-18T18:23:43-07:00
by magick
Look for -evaluate exp in ImageMagick 6.6.5-1 Beta by sometime tomorrow. Thanks.

Re: request enhancement -evaluate exp

Posted: 2010-10-19T10:32:34-07:00
by fmw42
OK, I will test it when I see the new beta.

By the way, the rising form of the exponential is just the -negate of the negative form. So I took a look at the other form of a rising exponential. But it appears to be too linear when restricted to the range 0 to 1. So if someone has another way of normalizing it with only one argument that show more variation in the exponential rise, let us know.

Here is what I have:


Image


If more arguments are needed to do a proper job of getting more variation, then this will wait until a -function exp can be created.

Re: request enhancement -evaluate exp

Posted: 2010-10-19T13:55:28-07:00
by fmw42
I have tested -evaluate exp value

but it only works for negative values. Looking at the code, it appears that only one part of the suggested code was implemented.


case ExponentialEvaluateOperator:
{
result=(MagickRealType) (QuantumRange*exp((double) (value*QuantumScale*
pixel)));
break;
}


This is OK with me (as the other side of the equations that I suggested is just -negate of the this).

Note that if one puts in positive values, the results will always be greater than quantumrange. So this form is really only an exponential decay function. As I pointed out above, the other exponential increase, exp(a*x)-1, is very linear and probably of little benefit.

Therefore is there are no objections, I will try to document what we have and emphasize it needs negative values (only) to get meaningful results.

Re: request enhancement -evaluate exp

Posted: 2010-10-19T14:26:02-07:00
by fmw42
I have updated the documents at http://www.imagemagick.org/script/comma ... p#evaluate, but this may take a day to filter over to the public web site.