everyone! I need to update the entire ushort[] array very quickly
Right now I am using the following code:
public ushort[] ImageUpdatePixels(ushort[] data)
var uMax = 65535d;
var w = someValue;
var l = someOtherValue;
for (int y = 0; y < height; y++)
for (int x = 0; x < width; x++)
{
var index = y * width + x;
var pixelValue = data[index] / uMax;
pixelValue = pixelValue / w + 0.5f - l / w;
pixelValue = Math.Min(1, Math.Max(0, pixelValue));
pixelValue = Math.Pow(pixelValue, 1 / imageSettings.Gamma);
data[index] = (ushort)(pixelValue * uMax);
}
return data;
When image resolution is 1000x1000 - everything works fine, but if 2k*2k or more - CPU resources of computer are already not enough.
Are there any other ways to go through the whole array very fast and apply the right conversions?