letmaik / rawpy

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

Use main/calculated color structure for metadata binding instead of b… #73

Closed kmilos closed 5 years ago

kmilos commented 5 years ago

…ackup raw one parsed from file

letmaik commented 5 years ago

Thanks for this! Can you give an example or what the behaviour is before and after your change? And for both cases before/after postprocessing. Based on that it's easier to understand API semantics changes and possibly writing test cases.

kmilos commented 5 years ago

Can do, if you provide a win-64 wheel please. No toolchain here, sorry...

letmaik commented 5 years ago

You can download the wheel from continuous integration. Just click on the green tick next to your commit and go to Appveyor. Then select the right build configuration and download the wheel from the artifacts tab.

kmilos commented 5 years ago

Nice... Unfortunately the patch is not doing what I hoped...

Before:

import rawpy

with rawpy.imread('./sony.ARW') as raw:
    print(raw.black_level_per_channel)
    print(raw.color_matrix)
    rgb = raw.postprocess()
    print(raw.black_level_per_channel)
    print(raw.color_matrix)

with rawpy.imread('./huawei.dng') as raw:
    print(raw.black_level_per_channel)
    print(raw.color_matrix)
    rgb = raw.postprocess()
    print(raw.black_level_per_channel)
    print(raw.color_matrix)

[512, 512, 512, 512]
[[0. 0. 0. 0.]
 [0. 0. 0. 0.]
 [0. 0. 0. 0.]]
[512, 512, 512, 512]
[[0. 0. 0. 0.]
 [0. 0. 0. 0.]
 [0. 0. 0. 0.]]
[0, 0, 0, 0]
[[ 0.92103994  0.43409887 -0.35513884  0.        ]
 [-0.20845512  1.1323496   0.07610554  0.        ]
 [ 0.00490609 -0.4078749   1.4029689   0.        ]]
[0, 0, 0, 0]
[[ 0.92103994  0.43409887 -0.35513884  0.        ]
 [-0.20845512  1.1323496   0.07610554  0.        ]
 [ 0.00490609 -0.4078749   1.4029689   0.        ]]

After:

import rawpy

with rawpy.imread('./sony.ARW') as raw:
    print(raw.black_level_per_channel)
    print(raw.color_matrix)
    rgb = raw.postprocess()
    print(raw.black_level_per_channel)
    print(raw.color_matrix)

with rawpy.imread('./huawei.dng') as raw:
    print(raw.black_level_per_channel)
    print(raw.color_matrix)
    rgb = raw.postprocess()
    print(raw.black_level_per_channel)
    print(raw.color_matrix)

[512, 512, 512, 512]
[[0. 0. 0. 0.]
 [0. 0. 0. 0.]
 [0. 0. 0. 0.]]
[0, 0, 0, 0]
[[0. 0. 0. 0.]
 [0. 0. 0. 0.]
 [0. 0. 0. 0.]]
[0, 0, 0, 0]
[[ 0.92103994  0.43409887 -0.35513884  0.        ]
 [-0.20845512  1.1323496   0.07610554  0.        ]
 [ 0.00490609 -0.4078749   1.4029689   0.        ]]
[0, 0, 0, 0]
[[ 0.92103994  0.43409887 -0.35513884  0.        ]
 [-0.20845512  1.1323496   0.07610554  0.        ]
 [ 0.00490609 -0.4078749   1.4029689   0.        ]]

So it actually removes the black level in the ARW case, no impact on the DNG one...

Cancelling this PR for now, sorry.