I’m trying to add support for lossy DNG in my quickraw library.
Now the JPEG tiles can be decoded(directly though a general JPEG decoder to RGB values) and the whole photo can be viewed.
But I cannot figure out how to correctly convert the colorspace of the decoded image.
[decode → CameraToXYZ(by using ColorMatrix2) → XYZtoSRGB]
This looks closer to the thumbnail.
Lossy DNG contains general YCbCr JPEG tiles. So I just put the raw tile bytes into a general JPEG decoder to get the [decode only] result.
The PhotometricInterpretation is 38492. According to the DNG spec doc, the colorspace of the pixel data should be the same color space as the raw image data. So I don’t know why the image appears like the [decode only] one.
A quick look shows that those lossy DNGs claim to be scene-referred/linear encoded. That might mean you’ll need also a log transform (plus possibly a tone curve) for your data.
But as you didn’t post the DNG file, that’s just a guess.
Thanks for the reply. I’ve appended the dng file in the main thread.
I can understand that usually a linear raw file needs a tone curve(or gamma correction) to “brighten” the image. But this decoded one seems to have already brightened.
I think you’re still expected to apply the color matrix and white balance to LinerRaw data (there are also other DCP lookup tables present, but I’d start w/ the basics).
I got the impression that you are using a program you wrote. In that case, shouldn’t you know what is done with the image? For instance, my understanding was that demosaicing needs at least an approximate white balance applied to function well. Then again, does this type of image need demosaicing?
No, lossy DNG contains general YCbCr JPEG tiles, so there is no demosaicing part in processing. When you put the raw tile bytes into a general JPEG decoder, it’ll just output an uint8 array data contains RGB values. The image is the [decode only] in the first post.