Hey,
I'm having a problem generating DNG files from raw image files. The problem relates to the demosaicing parameters. I have a raw image from each of two different cameras (Cannon D200 and Panasonic Lumix). Using dcraw.exe (to display the EXIF info) I find that the Bayer filter pattern for each of these images is RGGB. I take this to mean RG/GB for row1/row2 of 2x2 pattern.
Using the DNG SDK, I have written code to modify and then write the raw pixel values to a DNG file. I set the mosaic parameters using negative->fSetBayerMosic(phase), where phase is 0 for GRBG, 1 for RGGB, 2 for BGGR and 3 for GBRG. (As a side point I also set the fCFAPattern[][] values to the equivalent values, e.g. 01/12 for RGGB, but this doesn't seem to change the Bayer mosaic pattern in the DNG EXIF?). The problem is that when I view the DNGs, the DNG from the Panasonic is correctly displayed in Photoshop, but the DNG for the Canon image is clearly demosaiced incorrectly. By setting phase to 0, the Canon DNG image is demosaiced correctly (but not the Panasonic).
What is really confusing me is that by writing the same images to DNGs using libtiff, I set the Bayer pattern to RGGB as TIFFSetField (tif, TIFFTAG_CFAPATTERN, 4,"\0\001\001\002" ) and the DNG's for the images from both cameras are displayed correctly in Photoshop.
So even though dcraw says the Bayer pattern is RGGB for both camera images, using fSetBayerMosaic(1) only causes the Panasonic image to be correctly decoded. Is there some other parameter that can affect the demosaicing that occurs when building the DNG images? I'm taking the Bayer pattern value from the decoded raw image using libraw (imgdata.idata.filters parameter). Libraw is just an api for dcraw.
Also, can anyone explain to me the significance of the stage1, stage2 and stage3 images? Must all three be built to creat a valid DNG? I understand that demosaicing occurs when builing the stage3 image, and this is where I have been focussing my debugging time for the above problem. Does this make sense?
Hoping someone can help with this,
aubrey