-
Notifications
You must be signed in to change notification settings - Fork 39
Produces black(ish) output dng file #75
8000New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Can you include a screenshot or sample of the image? What camera is it from? |
Same problem here, I ran the provided example directly, raw2dng.py, and it successfully reads the image and stores it as custom.dng, but using various tools it reads an all-black image (including using rawpy). Env: windows 10 + python 3.8.17 (anaconda) |
Any update on this issue? Env: windows 10 + python Python 3.12.1 Latest version of PiDNG installed from GitHub: python3 -mpip install git+https://github.com/schoolpost/PiDNG.gi |
I can confirm this issue on debian12 too, both with python3.11 and 3.12. raw2dng.py with the supplied scene_daylight_211ms_c2.raw16 yields a completely black image. |
So I just came around to fiddle with it again and I have an interesting observation: For now that'll do as a workaround for me, I'll report back should I find something else regarding this. |
@OParczyk Tried your change, but now it generates a corrupted output. Any luck in making this code work ? |
I am trying to convert a raw photo using the following code (from the example)
`from pidng.core import RAW2DNG, DNGTags, Tag
from pidng.defs import *
import numpy as np
import struct
import rawpy
import sys
load raw data into 16-bit numpy array.
raw_file = sys.argv[1]
output_file = sys.argv[2]
with rawpy.imread(raw_file) as raw:
width, height = raw.raw_image.shape
bit_depth = raw.raw_image.dtype.itemsize * 8 # bytes to bits
raw_image = raw.raw_image
num_pixels = width * height
uncalibrated color matrix, just for demo.
ccm1 = [
[19549, 10000],
[-7877, 10000],
[-2582, 10000],
[-5724, 10000],
[10121, 10000],
[1917, 10000],
[-1267, 10000],
[-110, 10000],
[6621, 10000],
]
set DNG tags.
t = DNGTags()
t.set(Tag.ImageWidth, width)
t.set(Tag.ImageLength, height)
t.set(Tag.TileWidth, width)
t.set(Tag.TileLength, height)
t.set(Tag.Orientation, Orientation.Horizontal)
t.set(Tag.PhotometricInterpretation, PhotometricInterpretation.Color_Filter_Array)
t.set(Tag.SamplesPerPixel, 1)
t.set(Tag.BitsPerSample, bit_depth)
t.set(Tag.CFARepeatPatternDim, [2, 2])
t.set(Tag.CFAPattern, CFAPattern.GBRG)
t.set(Tag.BlackLevel, (4096 >> (16 - bit_depth)))
t.set(Tag.WhiteLevel, ((1 << bit_depth) - 1))
t.set(Tag.ColorMatrix1, ccm1)
t.set(Tag.CalibrationIlluminant1, CalibrationIlluminant.D65)
t.set(Tag.AsShotNeutral, [[1, 1], [1, 1], [1, 1]])
t.set(Tag.BaselineExposure, [[-150, 100]])
t.set(Tag.Make, "Camera Brand")
t.set(Tag.Model, "Camera Model")
t.set(Tag.DNGVersion, DNGVersion.V1_4)
t.set(Tag.DNGBackwardVersion, DNGVersion.V1_2)
t.set(Tag.PreviewColorSpace, PreviewColorSpace.sRGB)
save to dng file.
r = RAW2DNG()
r.options(t, path="", compress=True)
r.convert(raw_image, filename=output_file)
`
and it's producing an image - but the image is just a black blur. I suspect it's because I'm not changing the color matrix settings? I don't know how to configure that - any guidance on that? or anything else that could be causing this?
The text was updated successfully, but these errors were encountered: