request enhancement -evaluate exp

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

request enhancement -evaluate exp

Post 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.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: request enhancement -evaluate exp

Post by magick »

Look for -evaluate exp in ImageMagick 6.6.5-1 Beta by sometime tomorrow. Thanks.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: request enhancement -evaluate exp

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: request enhancement -evaluate exp

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: request enhancement -evaluate exp

Post 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.
Post Reply