Hello,
Is there a way to apply a LUT ( Look Up Table ) by passing Red, Green and Blue arrays ?
I didn't find a function to achieve that directly.
Many thanks.
Kind regards,
Frédéric
LUT Look Up Table
Re: LUT Look Up Table
Hello,
Here is my proposal solution to code a LUT function.
Tell me if you find an optimization on it:
Here is my proposal solution to code a LUT function.
Tell me if you find an optimization on it:
Code: Select all
public void ApplyLut(int[] lookupTableRed, int[] lookupTableGreen, int[] lookupTableBlue)
{
int imageWidth = _gdPictureImaging.GetWidth(_image);
int imageHeight = _gdPictureImaging.GetHeight(_image);
byte[] bytes = new byte[imageWidth * imageHeight * 4];
_gdPictureImaging.GetPixelArrayByte(_image, ref bytes, 0, 0, imageWidth, imageHeight);
for (int x = 0; x < imageWidth - 1; x++)
{
for (int y = 0; y < imageHeight - 1; y++)
{
int blueIndex = y * 4 * imageWidth + x * 4;
int greenIndex = blueIndex + 1;
int redIndex = blueIndex + 2;
byte blueValue = bytes[blueIndex];
byte greenValue = bytes[greenIndex];
byte redValue = bytes[redIndex];
bytes[blueIndex] = (byte)lookupTableBlue[blueValue];
bytes[greenIndex] = (byte)lookupTableGreen[greenValue];
bytes[redIndex] = (byte)lookupTableRed[redValue];
}
}
_gdPictureImaging.SetPixelArrayByte(_image, bytes, 0, 0, imageWidth, imageHeight);
}
Re: LUT Look Up Table
Hi,
You can increase speed by using parallelization: https://msdn.microsoft.com/en-us/librar ... .110).aspx
You can increase speed + memory usage using unsafe block, getting image back buffer and also using parallelization. (more tricky since you will have to handle the pixel format of the bitmap).
I forgot to tell you that your request is into our whist list. We should implement such feature this year.
Kind regards,
Loïc
You can increase speed by using parallelization: https://msdn.microsoft.com/en-us/librar ... .110).aspx
You can increase speed + memory usage using unsafe block, getting image back buffer and also using parallelization. (more tricky since you will have to handle the pixel format of the bitmap).
I forgot to tell you that your request is into our whist list. We should implement such feature this year.
Kind regards,
Loïc
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 1 guest