Skip to content

A python package to process raw and dng file, supporting demosaicing with gamma correction.

Notifications You must be signed in to change notification settings

cuiziteng/process_raw

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

process_raw: A python package to process raw and dng file

Features

  • Reading .dng file to np.array
  • Saving raw image as .dng file
  • Demosaicing (by rawpy)
  • Demosaicing with gamma correction (for raw image > 8bit)

Usage

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)

Credits

Source referenced from:

About

A python package to process raw and dng file, supporting demosaicing with gamma correction.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%