I am trying to process multiple RAW DNG images by stacking them to produce 1 stacked RAW DNG image. First, I get the DNG pixel data into byte array, since DNG is digital negative, I then flipped the byte values using "~" and convert them into unsigned integer, now I calculate the average. With the average result, I flipped it back with "~" and save in "newData" byte array.
Below is the snippet on averaging 2 DNG images. The images are shot from OnePlus 3 in RAW (16MP DNG).
byte[] previousData //from previous DNG image
ByteBuffer rawByteBuffer = mImage.getPlanes()[0].getBuffer();
byte[] data = new byte[rawByteBuffer.remaining()];
rawByteBuffer.get(data); // from current DNG image
for(int i=0; i<data.length; i++){
int currentInt = Byte.toUnsignedInt((byte) ~data[i]);
int previousInt = Byte.toUnsignedInt((byte) ~previousData[i]);
int sumInt = currentInt + previousInt;
int averageInt = sumInt/2;
newData[i] = (byte) (~averageInt); // store average into newData
}
// save newData into storage in DNG format
However, the result image(link below) always show green tint on white color portion. Any ideas what went wrong in the process?