ello,
I am looking for the most efficient way to do the following:
Take an input image in bitmap form, inputIMG. Map each pixel from the
input image, inputIMG(x,y), to a new value using a lookup table,
lookupTable, which is basically an 256×3 element array.
If the input pixel is valued at RGB [192,123,154] the output pixel
value would be the value at lookupTable(192,123,154).
I can easily code this going through the input bitmap pixel by pixel using Bitmap.setPixel(), but there would likely be a lot of overhead associated with that approach due to many repeated calls and I was wondering if there was a more efficient way to do it?
Thanks in advance.
If you don’t want to set each pixel individually you have two options.
One is to set patches of pixels at the same time with
setPixels(int[], int, int, int, int, int, int):The other is to create a new bitmap using an array of colors:
createBitmap(int[] colors, int offset, int stride, int width, int height, Bitmap.Config config)Both methods are explained in the Android Bitmap docs