12-bit linear ~= 8-bit sRGB. RAW files are not HDR.

In the previous post I argued that 8-bits with an sRGB color profile is still not enough precision for typical LDR display. There are a lot of factors that determine whether you see banding or not such as dithering/noise and the contrast ratio of your monitor.

But there is a lot of wiggle room for defining what an LDR display/camera is. And there is even more room for arguing what an HDR display/camera is. Is it 2 stops better than LDR? Is it 5 stops better than LDR. Is it 15 stops? We can argue over how much range an HDR display/camera should have to be called “HDR”, but first I think it’s important that we nail down what an LDR display is. I think the following definition (which I’m making up) is fair:

An LDR display/camera is a device that can accurately display/capture an 8-bit sRGB image/scene.

By far the most common display that we see is an 8-bit sRGB display, and the most common cameras are 8-bit sRGB. So to me, it’s a fair definition. That should leave most of you with two questions:

  1. What exactly is an “sRGB” display?
  2. Does a typical RAW file have more range than an LDR camera?

First, let’s talk about gamma. Check out this image:



The left and right sides are alternating lines of white and black. If you stand back and squint the left and right sides should look like a solid gray color about equal to the middle-bottom square. On an 8-bit display, black is the color (0,0,0) and white is the color (255,255,255). If you have never heard of gamma before, you would think that the middle-bottom square is the color (127,127,127). The rest of you know that the bottom square is the color (187,187,187).

As you can see, the value that is linearly half-way between white and black is 187, not 127. This happens because our displays are designed to be perceptually linear, and the human eye has more precision in the blacks.

(By the way, if the lines on the left or the right seem like they are yellow-ish, then you need to calibrate your monitor.)

You may have heard of this thing called a “gamma curve”. We would expect that if you displayed the value 200 to your monitor that it would emit 2x as many photons as if you displayed the value 100. In reality, 200 is about 4.6x brighter.

Let’s check out the gradient image.

Perceptually the value in the middle looks about half way between black and white. That value in the middle is about 20% as bright as white. Btw, your monitor’s output curve isn’t truly perceptually linear. Most studies have shown that humans percieve 18% brightness as “half”. That’s why you always hear about “18% grey”. The red stripe shows where the linear middle-point is. I.e. the color that shows the average number of photons between black and white.

As you increase the value that you send to the screen, the actual intensity goes up according to this curve. The red curve is the sRGB curve. The black dotted line is a a gamma of 2.2. The blue line is the slope of the sRGB curve in log-log space. If you don’t understand the blue line, that’s ok. We’ll just be talking about the red one. Btw, I got this image from wikipedia.

Being a gamma curve, the black dotted line is just the formula f(x)=pow(x,2.2). The sRGB curve has two parts. It starts with a linear section (the toe) with a slope of 1/12.92. And the second part has a power of 2.4. The two curves look the same on a graph, but the sRGB curve is much brighter in the blacks than the gamma 2.2 curve.

Here’s where things get interesting. Suppose that we have a linear curve with a slope of 1.0, and it has 256 output values. How many input values (at even steps) would you need to have coverage of every output value? Well, 256 of course.

Now let’s think about that sRGB curve. The toe has a slope of 1/12.92. So if we want a linear curve that matches all 256 output values then how many values do we need? Well, we would need 12.92*256 = 3307.52, which we can round up to 3308. Thus, we would need 3308 linear values to represent the same precision as the 8-bit sRGB curve.

Most digital SLRs store their RAWs as 12-bit linear. That means it has 2^12=4096 unique values. And since we only need 3308, a 12-bit linear curve is enough precision to represent an 8-bit sRGB curve. If we want to be a bit more precise we can observe that 2^11.69=3308. So a perfect 12-bit linear image has 12-11.65 = 0.31 more stops of dynamic range than an 8-bit sRGB image. And cameras are perfect, right?

Reasons why cameras lose dynamic range.

  1. All cameras have at least a little noise, so you can’t really trust the very bottom of your 12-bit input range.
  2. The three sensors don’t actually show you the direct RGB image. Rather, there is a linear transformation to your output space.
  3. Your camera tries to store enough range for all possible white balance values. Once you choose your white balance you will maximize one channel but have to clamp the other two.
  4. Many RAW formats don’t even use all possible values that 12-bits gives them. For exmaple, some Fuji cameras only use the range 256-4096.
  5. This one is a little bit out there, but you could argue that you lose range from vignetting. If the pixel at the corner of your sensor is 50% as bright as the pixel in the middle then the pixel at the corner has lost a full stop of dynamic range in the blacks.

But all hope is not lost. There are several other reasons why cameras actually have more dynamic range.

Reasons why cameras have more dynamic range.

  1. Most digital cameras don’t have “true” linear curve. Rather they have a little bit of a toe at the bottom end. This ends up giving your more range in your bottom end.
  2. You gain range from downsizing your image. If you are not displaying your image at full resolution then you gain precision (especially in your blacks) from downsizing the image.
  3. You also gain range at the bottom end back from noise reduction. If you go for agressive noise reduction techniques you are basically trading detail for less noise and more dynamic range.

That’s where we stand. In practice I’ve found that I can salvage an extra half-stop or so by tweaking a RAW file as opposed to just using an 8-bit sRGB image with no tweaking, and most people that I’ve talked to seem to have the same experience. So these are my conclusions.

The Three Rules of LDR Cameras and Displays:

  1. An LDR display/camera is a device that can accurately display/capture an 8-bit sRGB image/scene.
  2. A perfect 12-bit linear curve has 0.31 more stops of dynamic range than an 8-bit sRGB curve.
  3. A digital camera with a 12-bit ADC (analog to digital converter) has about the same range as an 8-bit sRGB image. But in practice it has slightly more range if you spend time tweaking the curve.

Now that we’ve gone over what I consider an LDR display to be, the next post will go over how much range various HDR-ish cameras actually give you.

  • http://www.HDRLabs.com Blochi

    Excellent article, thank you for this clear train of thought.

    I would like to add a reminder for your readers that this 8-bit sRGB to 12-bit linear comparison only works lossless in one direction. Expanding sRGB, that is. The bright parts, those that would be expanded the most, are where original RAW files have the upper hand. Because they have original data there, smooth graduations that would be compressed when you go the other way. Gamma compression is a destructive process, that’s why it’s sorta evil.

    But here’s another conclusion: LCD devices are technically linear devices. And your math shows very well that it was a crude mistake to build the early LCD displays with 8 bit in mind. It needs to have at least 12 bit processing at some point, otherwise it will shows banding when you try to expand the sRGB signal. Because when you’re only shuffling bits from gamma to linear in this 8 bit soup, without properly expanding them, you’re making a mess. I believe that’s part of why the latest generations of monitors are so much better and show less banding – because they finally got it working in higher bit depths.

    Cheers,
    Christian Bloch

  • http://blog.19lights.com John Hable

    Hi Christian,

    Great point. It’s a one-way street, and once you do it, you can’t go back.

    Good point about the LCDs too. It’s easy to forget that gamma started as an artifact. With CRTs, as you linearly increase the amount of time you are shooting electrons at a CRT screen the intensity increases as a power curve. It was only later that they realized that this artifact was actually a good thing because it made the output curve perceptually linear. Then when LCDs first came out we took a huge step backwards in color management. The natural response curve for LCDs is this S-shaped thing so you need good, high-recision processing to match the curve that CRTs do naturally. LCDs are finally getting better though.

    John

  • http://19lights.com/wp/2011/10/16/how-hdr-is-that-camera/ How “HDR” is that camera? | 19lights

    [...] Post navigation ← Previous [...]