0

I'm porting an existing application to .net core and I need to adjust the gamma of an image using ImageSharp.

I've tried image.Mutate(i => i.Brightness(value)); but it's not quite the same result as the original code which changes the gamma.

The original code uses imgAttribs.SetGamma(value, ColorAdjustType.Bitmap); but I can't use System.Drawing.Common as it's missing a dependency on AWS Lambda.

Is it possible to change the gamma using ImageSharp, if yes, how?

cracanut
  • 3
  • 2

1 Answers1

1

Gamma adjustment is simply a non linear adjustment of individual pixel values. You don't need a built in function to do it. Loop through the pixels and adjust each one.

Th algorithm, from memory, is something like Math.Pow(component, gamma); for each r, g, b component of a pixel.

James South
  • 10,147
  • 4
  • 59
  • 115