Camera Profiles define how a raw image is rendered by image processing software. Specifically, they contain a definition of exactly what the color of a particular pixel should be, relative to the raw data in the original image. Previous generations are Adobe’s image processing software (Photoshop/Camera Raw and Lightroom), had camera profiles for a wide variety of camera embedded within them. The latest generation of this software however has separated out theses profiles into DNG Camera Profiles. Although called DNG Camera Profiles, actually they apply to any raw file that an Adobe product loads.
DNG Camera Profiles in effect provide a recipe for getting from raw data in a file to real colors on a screen or printer.
Note: this is based on our interpretation of the DNG 1.2 specification. Your interpretation and/or mileage may vary.
In very simplified form, what they contain is: (there’s an example of a file here)
The ColorMatrix tables
Color matrixes are the very basics of how to get from a raw file to a displayable image.
- Each color matrix has nine data points; for each displayed color is a combination of the raw values. So “Displayed Red” is some combination of “Raw Red”, Raw Green” and “Raw Blue”. Likewise “Displayed Green” and “Displayed Blue”.
- Why a combination of raw values? - basically because the RGB sensors in cameras aren’t perfect - colors as sensed overlap. So, if you shine a red light at the sensor, you'd get a big reading from the red pixel, but you’d also get readings from the green and blue pixels. So if you look at the matrix, the red-to-red (0,0), green-to-green(1,1) and blue-to-blue(2,2) elements of the matrix are close to 1, but the other (off-diagonal) elements are a lot lower, and some of them are actually negative, so as to subtract out overlaps in color rendition.
- Why are there two matrixes? - that’s where it gets complicated - see later.....
The HueSatDeltas tables
If the ColorMatrix is the basis of getting from raw data to image data, the HueSatDeltas are the basis of profiling the camera. Once the data from the sensor has been converted via the ColorMatrix to RGB image data, it is then transformed into HSV format. HSV format is a “cylinder” of color - the hue is given by the angle measured from the center, the saturation by the length of the radius from the center, and the actual value by the height in the “cylinder”
The diagram shows the “top” of the cylinder.
What the HueSatDeltas do, is to break up all the colors available into a grid. That grid is a series of circles on the diagram, and a series of radius lines.
The next diagram shows the basic structure of the grid. For a profile generated by the current version of the DNG profile editor, there are 90 radius lines (so hue points at every 4 degrees), and 25 saturation divisions (so 25 “circles” on the diagram).
For each point is this grid, the HueSatDelta table then defines a hue shift, a saturation scaling factor, and a value scaling factor. These are then used to shift the color value. Colors between the grid points are interpolated from the closest points on the grid. So effectively a kind of a look-up table of “color before” and “color after”. Easy!!!
And now the complicated bit........
There are a few things left out of the description above that complicate this simple picture:
- There are actually two ColorMatrix tables and two HueSatDelta tables. The reason is that in order to perform color temperature compensation, you need two of these tables, at different ends of the color temperature spectrum. Then, the actual table that you use at the temperature of the image is the results of an interpolation between the two tables.
- The HueSatDelta tables have third dimension - value. So you can effectively embed a color dependent tone curve. Or perhaps a tone dependent color map. Or......something. So good-luck-with-that. On this subject, the DNG specification states, with what I regard as masterly understatement that “The most common case has ValueDivisions equal to 1, so only hue and saturation are used as inputs to the mapping table”. However, this third dimension is exactly what Adobe use to implement the “hue twists” in their new generation profiles. See this page, and my blog, for more.
- There is also a LookTable, which is exactly the same as a HueSatDelta Table, but is intended to be applied later in the processing pipe, “after any exposure compensation and/or fill light stages, but before any tone curve stage”
- There can also be Forward and Reduction Matrixes - these supplement the ColorMatrixes, but are often not present
- Likewise, there is provision for a tone curve.
The processing pipe
So, this is how, in vastly simplified form, you process your raw data in context of a DNG Camera Profile, assuming the Forward and Reduction Matrixes are not present (see the specification for more detail):
- Linearize, rescale, do black level compensation, clip, etc.
- Derive interpolated ColorMatrix and HueSatDelta matrixes based on the color temperature.
- Get to an XYZ (absolute color space) via the interpolated ColorMatrix.
- Convert to HSV.
- Apply the interpolated HueSatDelta mapping table to get new colors.
- Convert back to XYZ.
- Do your exposure compensation, fill light, etc in whatever color space you want
- Convert to HSV, apply the LookTable and ToneCurve, convert back. Or, if I read the spec right, use the LookTable and the ToneCurve as the basis for your adjustment settings