Skip to content

Commit

Permalink
theoretically a more intuitive brighness contrast algorithm (ImageMag…
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristy committed Apr 8, 2023
1 parent e7ce537 commit c9bf349
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions magick/enhance.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ MagickExport MagickBooleanType BrightnessContrastImageChannel(Image *image,
#define BrightnessContrastImageTag "BrightnessContrast/Image"

double
alpha,
intercept,
coefficients[2],
slope;
Expand All @@ -299,11 +298,10 @@ MagickExport MagickBooleanType BrightnessContrastImageChannel(Image *image,
assert(image->signature == MagickCoreSignature);
if (IsEventLogging() != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
alpha=contrast;
slope=tan((double) (MagickPI*(alpha/100.0+1.0)/4.0));
if (slope < 0.0)
slope=0.0;
intercept=brightness/100.0+((100-brightness)/200.0)*(1.0-slope);
slope=100.0*PerceptibleReciprocal(100.0-contrast);
if (contrast < 0.0)
slope=contrast/100.0+1.0;
intercept=brightness/100.0+((100.0-brightness)/200.0)*(1.0-slope);
coefficients[0]=slope;
coefficients[1]=intercept;
status=FunctionImageChannel(image,channel,PolynomialFunction,2,coefficients,
Expand Down

0 comments on commit c9bf349

Please sign in to comment.