- Reading
.dng
file tonp.array
- Saving raw image as
.dng
file - Demosaicing (by rawpy)
- Demosaicing with gamma correction (for raw image > 8bit)
Install
pip install process_raw
Run demo:
python -m process_raw.process_raw
Then, the browser will automatically open a visual web page, like demo.html
For document, please see example code of DngFile.test()
at process_raw/process_raw.py
Python example:
import cv2
import numpy as np
from process_raw import DngFile
# Download raw.dng for test:
# wget https://github.com/yl-data/yl-data.github.io/raw/master/2201.process_raw/raw-12bit-GBRG.dng
dng_path = "./raw-12bit-GBRG.dng"
dng = DngFile.read(dng_path)
raw = dng.raw # np.uint16
raw_8bit = np.uint8(raw >> (dng.bit-8))
cv2.imwrite("raw_8bit.png", raw_8bit)
rgb1 = dng.postprocess() # demosaicing by rawpy
cv2.imwrite("rgb1.jpg", rgb1[:, :, ::-1])
rgb2 = dng.demosaicing(poww=0.3) # demosaicing with gamma correction
cv2.imwrite("rgb2.jpg", rgb2[:, :, ::-1])
DngFile.save(dng_path + "-save.dng", dng.raw, bit=dng.bit, pattern=dng.pattern)
Source referenced from:
- rawpy: For read
.dng
file - PiDNG: For save raw as
.dng
file - colour_demosaicing: Provide demosaicing algorithms