Skip to content

Commit

Permalink
0 & 1 are special cases for pow()
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristy committed Jan 19, 2025
1 parent 056ccdb commit be3b73d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion MagickCore/statistic.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ static double ApplyEvaluateOperator(RandomInfo *random_info,const Quantum pixel,
}
case PowEvaluateOperator:
{
if (PerceptibleReciprocal(value) <= MagickEpsilon)
if (fabs(value) <= MagickEpsilon)
break;
if (((double) pixel < 0.0) && ((value-floor(value)) > MagickEpsilon))
result=(double) -((double) QuantumRange*pow(-(QuantumScale*(double)
Expand Down
5 changes: 3 additions & 2 deletions MagickWand/operation.c
Original file line number Diff line number Diff line change
Expand Up @@ -2477,14 +2477,15 @@ static MagickBooleanType CLISimpleOperatorImage(MagickCLI *cli_wand,
if (IsGeometry(arg1) == MagickFalse)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
constant=StringToDouble(arg1,(char **) NULL);
#if 1
#if 0
/* Using Gamma, via a cache */
if (IfPlusOp)
constant=PerceptibleReciprocal(constant);
(void) GammaImage(_image,constant,_exception);
#else
/* Using Evaluate POW, direct update of values - more accurate */
if (IfNormalOp)
if (IfNormalOp && (fabs(constant) <= MagickEpsilon) &&
((constant-1.0) > MagickEpsilon))
constant=PerceptibleReciprocal(constant);
(void) EvaluateImage(_image,PowEvaluateOperator,constant,_exception);
_image->gamma*=StringToDouble(arg1,(char **) NULL);
Expand Down

0 comments on commit be3b73d

Please sign in to comment.