I am doing a gamma correction on an image of dimensions 5000x3000x3.
The formula is
value ^ (1 / gamma)
for RGB values from 0.0 to 1.0
My input gamma values range from 0.0 to 10.0 while gamma = 0.0 always outputs 0.0.
The trouble is that the involved pow computation is so slow.
Doing this takes about 1300 milliseconds on a float[, ,]:
for (int y = 0; y < 3000; y++)
{
for (int x = 0; x < 5000; x++)
{
for (int z = 0; z < 3; z++)
{
arr[x, y, z] = (float)Math.Pow(arr[x, y, z], 0.3);
}
}
}
And using NMathFunctions.Pow on a FloatMatrix this takes about 1100 milliseconds:
a = NMathFunctions.Pow(a, 0.3f);
Any idea how to speed things up?