public override ColorBgra Apply(ColorBgra color) { float colorAverage = color.GetAverageColorChannelValueF(); float scale = (colorAverage - BackAverage) / (ForeAverage - BackAverage); byte alpha = Utility.ClampToByte(scale * 255); return(color.NewAlpha(alpha)); }