letmaik / rawpy

📷 RAW image processing for Python, a wrapper for libraw
https://pypi.python.org/pypi/rawpy
MIT License
587 stars 67 forks source link

How could I do some transform in raw domain and transform it into rgb domain? #223

Closed Luciennnnnnn closed 3 months ago

Luciennnnnnn commented 5 months ago

Hello, I am training a neural network where the input is raw data and the output is RGB data. Therefore, to ensure alignment (see the paper ), I need to make the same transformations in the raw domain for both input and output, such as flip, rotation, crop, and then keep the input data in the raw domain while transforming the output to the RGB domain. However, it seems that the following code does not modify the underlying numpy array of rawpy.

import rawpy
import imageio

path = '/path/to/raw/image.ARW'
with rawpy.imread(path) as raw:
    gt_raw_array = raw.raw_image
    gt_raw_array = gt_raw_array[:, ::-1][:, 1:-1]

    rgb = raw.postprocess()

imageio.imsave('/path/to/rgb/image.png', rgb)
letmaik commented 3 months ago

I'm afraid this is not supported as the underlying library libraw wouldn't support it.