-
Notifications
You must be signed in to change notification settings - Fork 1
AVGContrast
George Plotnikov edited this page Mar 15, 2018
·
2 revisions
Generates image with calculating average contrast pixels with normalization.
ImageBlendingAlgorithms/IBALib/BlendingAlgorithms/AVGContrast.cs
public override Color Calculate(IEnumerable<Color> colors)
{
var r = 0.5f + (colors.Average(c => c.R) - 0.5f) * 2f;
if (r < 0) r = 0;
else if (r > 1f) r = 1f;
var g = 0.5f + (colors.Average(c => c.G) - 0.5f) * 2f;
if (g < 0) g = 0;
else if (g > 1f) g = 1f;
var _b = 0.5f + (colors.Average(c => c.B) - 0.5f) * 2f;
if (_b < 0) _b = 0;
else if (_b > 1f) _b = 1f;
return new Color(r, g, _b, 1f);
}
example of normalization:
a = 0.75
b = 0.34
c = 0.5 + (0.545 - 0.5) * 2 = 0.5 + 0.09 = 0.59
the results of handling 3 source images