Why do pure red, green, and blue values in a synthetic RAW shift when converted to JPEG?

Asked 8/6/2019

5 views

2 answers

0

I created a synthetic RAW/DNG by taking a Nikon D200 RAW, converting it to uncompressed DNG, and overwriting the sensor data with Python. The image contains red, green, and blue gradient strips. After converting to JPEG in Lightroom and LightZone (default settings, daylight white balance), the red and blue areas are no longer “pure” and show contamination from other channels.

I expected white balance to only scale channels, not mix them. Why does RAW conversion introduce color mixing instead of preserving pure RGB values?

Originally by Photography Stack Exchange contributor. Source · Licensed CC BY-SA 4.0

Photography Stack Exchange contributor

6y ago

2 Answers

4

Here are some causes for non-zero values that you expect to be zero. The most relevant to your problem are listed first.

  • Your synthetic raw does not account for the input color profile of the camera, which is based on how the specific colors filter in the Bayer matrix interact with lighting sources when photographing calibration targets (with a lens, which may have its own color shift). Here is the histogram and output with the D200 profile (using RawTherapee):

    Histogram: DCP

    Result: DCP

    Compare with when no camera profile is used.

    Histogram: sRGB → sRGB

    Result: sRGB → sRGB

    See RawPedia: What Are DCP Profiles and Why Do I Need Them?

  • Some people refer to how manufacturers design their cameras to render colors to deviate from "reality" in a pleasant manner as their "color science".

These are configured in cameras via settings often labeled "color profiles" or "film simulations". They often have names such as Standard, Neutral, Vivid, Portrait, Landscape, and Flat. Some raw processors may attempt to replicate these profiles in a layer of color modification separate from color-correction profiles, camera input color profiles, and color spaces.

  • The working color space may not match the output color space. Make sure the working and output color spaces match. If that is not possible, selecting a different conversion method may produce "better" results because out-of-gamut colors are converted differently by different algorithms. Here are histograms to illustrate:

    • Adobe RGB → sRGB:

      Histogram: Adobe RGB → sRGB

    • sRGB → sRGB:

      Histogram: sRGB → sRGB

Less relevant possibilities:

  • Highlight Recovery using CIELab Blending can affect the colors at the bright end of the gradients. Other methods (Blend, Color Propagation, and Luminance Recovery) had no apparent effect on the gradients.

    Result: CIELab Blending

  • The demosaicing algorithm can affect interpretation of colors.

    See RawPedia: Demosaicing

  • Some programs add noise or dithering when converting color from higher bit depths to 8-bit/channel.

... the red shift is towards the actual color of the "red" filter in a typical Bayer mask - somewhere between yellow and orange. – Michael C

Ideally, "pure" input colors would result in output colors that match the Bayer filter of the selected camera. However, in practice, that is not what happens.

The color shift appears to be caused by camera profiles used by the raw processors, along with other contributing factors. They are created by processing photographs of calibration targets, taken with real lenses, under different lighting sources, as described at RawPedia. So the color filter does contribute, to the extent that it is involved in profile creation. However, each program produces different output, so it cannot be said which, if any, of them shifted toward, or away from, the actual colors of the Bayer filter used in any particular camera.

Regardless of the actual color in the Bayer array, select a different profile, and the output colors change. Use a different program, which uses different profiles, and the colors change. Use a synthetic profile, and the colors may be entirely unrelated to any real Bayer array.

Yet another layer of color modification that dissociates the actual colors of the Bayer array from the output image is "color profiles", such as Standard, Neutral, Vivid, Portrait, Landscape, Flat, which some raw processors may attempt to replicate.

Lightroom image Lightzone image RawTherapy image

Originally by user75526. Source · Licensed CC BY-SA 4.0

user75526

6y ago

0

AI Answer

Generated from our catalog & community — verify before relying on it.

Because RAW sensor data is not stored in the same color space as display RGB.

A camera’s Bayer filters labeled red, green, and blue are broad, overlapping spectral sensitivities, not the same primaries used by monitors or JPEG color spaces. So a “pure red” value in your synthetic RAW is only pure in terms of one sensor channel, not in a standard RGB output space.

To make a viewable image, the RAW converter applies more than white balance:

  • demosaicing
  • a camera color profile / input profile
  • a color transformation matrix from camera space to output RGB space

That color transform commonly mixes channels, so output red may include some green or blue, and vice versa. This is normal and necessary for accurate color rendering.

In your case, the synthetic data also doesn’t match the Nikon D200’s real spectral response and camera profile assumptions, so the converter’s profile can produce unexpected mixtures. One community test showed that disabling the camera profile reduced the effect.

So: white balance alone is mostly scaling, but RAW conversion as a whole includes profile-based channel mixing, and that’s why your “pure” RAW channels do not remain pure in JPEG.

UniqueBot

AI

6y ago

Your Answer