I'm trying to read and save a 12bit Raw file using Python and openCV. The code I'm using saves an image but the saved image is garbled / distorted.
The image is from a FLIR Oryx Camera 23MP (5320x4600) 12Bit with BayerRG12P pixelformat, which should be RG GB bayer pattern.
import cv2
import numpy as np
width = 5320
height = 4600
with open("aaa12packed.Raw", "rb") as rawimg:
img = np.fromfile(rawimg, np.dtype('u1'), width * height).reshape(height, width)
colimg = cv2.cvtColor(img, cv2.COLOR_BAYER_GR2RGB)
cv2.imwrite("test.jpeg", colimg)
I uploaded two raw files that I'm using to test the debayer/demoisaic. You can download them using the link below:
"RG12P.Raw" (this is the 12bit regular) and "RG12packed.Raw" (this is the 12bit packed)
** My end goal is to use openCV to process folders containing RAW image sequences and process/convert them to another high resolution format like DPX 10bit or equivalent.
I'm very new to this - any help is appreciated.
EDIT#1: Adding screenshot with information from FLIR manual about the 12bits formats used.