Luminous Landscape Forum

Raw & Post Processing, Printing => Adobe Camera Raw Q&A => Topic started by: capital on February 01, 2014, 07:37:06 pm

Title: DNG Spec for RAW Bayer Only vs 3 Color Raw Formats
Post by: capital on February 01, 2014, 07:37:06 pm
Can anyone point me towards a resource about how DNG spec handles native 3 color channels per pixel that does not require debayering. I know DNG supports a "linearized" output but it is not clear if the raw processor is smart enough to distinguish between a raw linearized file and a 3 raw color TIFF. Indeed, loading a raw tiff of an SD14 x3f file and that of a native x3f file show drastically different processed results in Adobe Camera Raw.

From reading over the DNG spec, the DNG spec seems to be geared towards data sets that are bayer-like in nature. I am interested to know if DNG can accommodate files like Multi-shot backs or Foveon sensors. As a related aside, I notice Camera Raw can natively handle foveon files up to a Sigma SD14, yet you can not actually use the Adobe DNG converter to convert these SD14 x3f files into DNG files. And the default "look" of an SD14 files looks very similar to that outputted from DCRaw which leads me to believe Adobe did an implementation of that DCRaw code as opposed to a generic 3 raw colors per channel file processing.

I was looking through the documentation and I see the following flags that can be set, though DNG seems to assume you actually have a CFA:

Quote
CFAPlaneColor provides a mapping between the values in the CFAPattern tag and the plane numbers in LinearRaw space. This is a required tag for non-RGB CFA images.
Quote
CFALayout describes the spatial layout of the CFA. The currently defined values are:
1 = Rectangular (or square) layout
2 = Staggered layout A: even columns are offset down by 1/2 row
3 = Staggered layout B: even columns are offset up by 1/2 row
4 = Staggered layout C: even rows are offset right by 1/2 column
5 = Staggered layout D: even rows are offset left by 1/2 column
6 = Staggered layout E: even rows are offset up by 1/2 row, even columns are offset left by 1/2 column
7 = Staggered layout F: even rows are offset up by 1/2 row, even columns are offset right by 1/2 column
8 = Staggered layout G: even rows are offset down by 1/2 row, even columns are offset left by 1/2 column
9 = Staggered layout H: even rows are offset down by 1/2 row, even columns are offset right by 1/2 column
Note that for the purposes of this tag, rows and columns are numbered starting with one.
Layout values 6 through 9 were added with DNG version 1.3.0.0.

Quote
ColorMatrix1 defines a transformation matrix that converts XYZ values to reference camera native color space values, under the first calibration illuminant. The matrix values are stored in row scan order.
Title: Re: DNG Spec for RAW Bayer Only vs 3 Color Raw Formats
Post by: Vladimirovich on February 01, 2014, 08:05:38 pm
I know DNG supports a "linearized" output but it is not clear if the raw processor is smart enough to distinguish between a raw linearized file and a 3 raw color TIFF.

for example "PhotometricInterpretation" in http://www.adobe.com/content/dam/Adobe/en/products/photoshop/pdfs/dng_spec_1.4.0.0.pdf : 32803 = CFA (Color Filter Array), 34892 = LinearRaw and the rest is in TIFF specs, so if tag is not 32803 or 34892 raw converter shall assume that it is dealing with tiff converted to dng and proceed accordingly (and TIFF spec has description what other values mean).
Title: Re: DNG Spec for RAW Bayer Only vs 3 Color Raw Formats
Post by: capital on February 02, 2014, 06:03:44 pm
I looked for the phrase LinearRaw PhotometricInterpretation in the PDF and it does indeed reference that snippet you posted. I am not sure how this flag interprets each color channel.

Mystery 1:
I did some more tinkering with the Adobe DNG converter, it seems to be able to convert SD14 x3f files, however pipping the outputted dng into dcraw's -D parameter, the dcraw actually renders a real color image as opposed to the raw "foveon" color image. So DNG conversion is doing something to the raw data.

Mystery 2:
Some other interesting tidbits, taking 3 different versions of the raw file (x3f, DNG, DNG Demosaiced) into lightroom and applying identical extreme color balance changes to each file and then comparing, I see no difference. Since some of this it a bit black box testing the thing I find most odd is that a "demosaiced" x3f produces identical results to a standard x3f. One would think that color information would be lost after demosaicing.
Title: Re: DNG Spec for RAW Bayer Only vs 3 Color Raw Formats
Post by: Vladimirovich on February 02, 2014, 06:36:13 pm
Some other interesting tidbits, taking 3 different versions of the raw file (x3f, DNG, DNG Demosaiced) into lightroom and applying identical extreme color balance changes to each file and then comparing, I see no difference. Since some of this it a bit black box testing the thing I find most odd is that a "demosaiced" x3f produces identical results to a standard x3f. One would think that color information would be lost after demosaicing.

Adobe's model of raw conversion is based on the following : in your workflow there will be no difference between using native raw or DNG converted from native raw (lossless, linear or not), *1... so basically you can think (it is easy to use this model mentally) that Adobe raw converter always does the following : {raw -> dng -> linear dng} -(operations available for you through UI)-> output ... certainly codewise it is not exactly so, but then it is earier for you to comprehend that no matter what is the starting point : raw, converted (lossless) DNG, converted (lossless) linear DNG - the final output will be same *1

*1 provided that raw->dng conversion was done with Adobe software of the same generation that Adobe software used for raw conversion

PS: so even Adobe is using a very old legacy code for Foveon raws (which apparenly was not updated for eons, and probably predates process 2010) it is still true even for .x3f
Title: Re: DNG Spec for RAW Bayer Only vs 3 Color Raw Formats
Post by: sandymc on February 03, 2014, 06:45:07 am
I looked for the phrase LinearRaw PhotometricInterpretation in the PDF and it does indeed reference that snippet you posted. I am not sure how this flag interprets each color channel.

In simplified form, if the PhotometricInterpretation is set to LinearRaw, the each pixel location has a value for each color (typically 3 values, RBG). If the file is in CFA mode, then each pixel location has only a value for a single color (which color is defined by the layout tags), and the file must be demosaiced to get to a "normal" image.

Sandy
Title: Re: DNG Spec for RAW Bayer Only vs 3 Color Raw Formats
Post by: madmanchan on February 21, 2014, 07:58:38 pm
The DNG spec covers both mosaic (color filter array, or CFA) and non-mosaic (e.g., RGB) formats.  As noted above, for mosaic (CFA) images the PhotometricInterpretation tag needs to be CFA and the # of samples per pixel is usually 1, whereas in the latter case it would be LinearRaw and the # of samples per pixel could be variable (1 for a monochrome image like the Leica M MONOCHROM, 3 for a RGB image, 4 for a GMCY image from a Sony F828, etc.). 

In the case of a CFA image, there are additional tags to specify the mosaic pattern and plane layout (CFARepeatPatternDim, CFAPattern, CFAPlaneColor, and CFALayout).

You mentioned the difference between a raw RGB image versus, say, a TIFF (which is typically already rendered).  This is specified via the ColorimetricReference tag.  For raw files (typically scene referred) this value should be 0.  For rendered files like most JPEGs or TIFFs  this value should be 1 (output referred, using the ICC profile perceptual dynamic range).
Title: Re: DNG Spec for RAW Bayer Only vs 3 Color Raw Formats
Post by: capital on April 01, 2014, 07:49:23 pm
Eric, thank you (belated) for your reply. This makes the most sense to me.