1

My understanding of the rendering of a typical RAW file, which contains 14 bits per channel, is that it is simply clipped to the 8 bits per channel used by most image viewers. Presumably camera defaults are to take the middle slice of that range, whereas processing programs allow the user to shift the 8-bit "window" left and right.

RAW data can be looked at as a special case of HDR data, which can be constructed with 16 or more bits per channel. With HDR techniques we don't want to clip the data and so instead we "tone map" it. My understanding of tone mapping is that it's a surjective transformation but that it requires user construction. I.e., there is no default tone mapping.

What I'm wondering is whether any programs provide a default mapping from HDR to 8-bit images one might call "compression," which would just transform each HDR pixel to an 8-bit pixel without clipping (but obviously losing dynamic detail across the spectrum).

So, for example, can one ask for a "compressed" rendering of a RAW file in Lightroom? For each channel this would map 0 to 0 and 2^14 to 2^8, with other values mapped linearly in between.

I have a suspicion that some contrast setting effectively does this, but I'm looking for a full understanding.

  • 1
    14-bit data is subject to demosaicking and tone curve (order may be in reverse), with applying a colour transform somewhere after demosaicking (that is, before the tone curve application or after it). The output is typically 16 bit, intermediate calculations are done in 16-bit space minimum (now more and more converters use floating point). I never seen clipping to 8 bit in converters since 2001. – Iliah Borg May 17 '15 at 0:53
  • Your understanding of the "middle slice" is a little flawed. The data from the sensors is linear, but S-shaped tone curves are applied by the viewers. The bottom third or so gets compressed to near the same dark shades, the middle is only compressed a little, and the highlights are compressed more highly again. – Michael C May 17 '15 at 2:25
  • @MichaelClark: thanks. So for RAW at some stage there is a nonlinear but monotonic transformation. Let's assume that's applied before any clipping/mapping/compression, and then I believe the original question stands. – feetwet May 17 '15 at 2:32
  • Not necessarily. Many viewers will give you a "flat" image that compresses pretty much all 14 bits down to 8 bits – Michael C May 17 '15 at 2:47
  • 2
    Any of the light curve adjustments affect it to one degree or another. I guess one way of looking at it is the white level and black level sliders set the "boundaries" on each side, the contrast sliders set how much displayed difference there is between each boundary and the brightness sliders adjust where the center will be. – Michael C May 17 '15 at 20:20
2

RAW data linearly scaled down to 8-bits would result in a very flat, dull image lacking good contrast. For this reason RAW converters apply an S-curve to give much greater contrast in the mid-tones (unless you specifically ask for something else). Depending on where the end points and shoulders of the curve are placed you move the area which gets maximum contrast around (contrast is determined by the steepness of the curve at that point) whilst increasing/decreasing brightness etc.

It's important to separate dynamic range and bit depth. The two only ever depend on each other when the encoding is perfectly linear. In all other cases they are completely independent - if you choose an encoding which massively compresses the mid-tones then you can record a huge dynamic range using very few bits.

What I'm wondering is whether any programs provide a default mapping from HDR to 8-bit images one might call "compression," which would just transform each HDR pixel to an 8-bit pixel without clipping (but obviously losing dynamic detail across the spectrum).

A "high dynamic range image" in the purest sense is no different to a RAW image (aside from the Bayer pattern), they both have more dynamic range than can be displayed, just one has greater DR than the other.

When most people look at "HDR" images, they're really looking at low dynamic range images that have been generated by tonemapping the HDR data. This operation attempts to preserve some of the dynamic range by using the full range available in the LDR image to display each different area in the HDR image.

Imagine the scenario you mention earlier where you take a slice out of the data to go from HDR to LDR, now imagine that window is shifted left or right depending on where you are in the image. That's the fundamentals of tonemapping. There's a whole load of other stuff going on but that's what makes it possible to display an HDR image on a low dynamic range device (like a typical LCD monitor).

So, for example, can one ask for a "compressed" rendering of a RAW file in Lightroom? For each channel this would map 0 to 0 and 2^14 to 2^8, with other values mapped linearly in between.

You might be able to by selecting the minimum possible contrast settings, it's hard to say how much of a curve is being applied. But you certainly wouldn't want to do this in most cases as your image would look very dull.

  • Do you know whether RAW data are "clipped" by cameras rendering JPGs, or by Lightroom? Sounds like you're saying they probably never are. – feetwet May 17 '15 at 18:22
  • @feetwet The camera's JPEG engine probably clips the shadows a bit, as for lightroom it depends on what settings you apply - if you crank the exposure slider all the way up then it's going to clip the highlights! – Matt Grum May 18 '15 at 10:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.