10

In another answer user Ilmari writes, in the context of preventing overexposure:

In general, I would also recommend always shooting RAW, both to better capture the full dynamic range of your camera, and also to avoid the ugly digital clipping of overexposed areas. For the latter, it helps to underexpose your shots a little (say, ...) and then pull the exposure up on your computer, ...

How does RAW prevent clipping of overexposed areas?

  • 1
    Shooting in RAW doesn't guarantee the elimination of highlight clipping. However, RAW files contain the full information captured by the image sensor, which generally includes highlight detail beyond what would be captured in a JPEG image. Keep in mind that RAW files typically have 12 or 14 bits of tonal data per pixel while JPEG is limited to 8 bits, so there's significantly more data to work with in a RAW file. I know this first-hand and have recovered from clipped highlights in JPEGs countless times when I pull up the RAW file in RawTherapee. See also: photo.stackexchange.com/a/13448 – bwDraco Nov 16 '15 at 21:39
  • (continued) Heck, the advantages of RAW, including the ability to perform more effective noise reduction and other post-processing on a PC after the event, is significant enough that I shoot sports in RAW+JPEG, even though it dramatically reduces the buffer depth! (My employer often wants an immediately usable JPEG image for their website right after a game, and I turn in the rest of the images a few business days later.) – bwDraco Nov 16 '15 at 21:47
13

In general, I would also recommend always shooting RAW, both to better capture the full dynamic range of your camera, and also to avoid the ugly digital clipping of overexposed areas. For the latter, it helps to underexpose your shots a little [...] and then pull the exposure up on your computer.

OK, yeah, I was being a bit terse when I wrote that. Let me try to unpack it a bit.

Obviously, just switching from JPEG to RAW won't do anything to fix clipping on its own. What I was trying to suggest, when I wrote the paragraph above, is:

  1. Deliberately underexposing your photos enough that the highlights won't clip.

  2. Shooting in RAW, which has a higher dynamic range than JPEG, in order to preserve shadow detail for the next step.

  3. Correct the underexposure in post-processing, using an algorithm that simulates soft "film-like" highlights instead of hard digital clipping. (I believe any decent RAW processor should have this feature built in; I know UFRaw does, and that's free software.)

Why go to all that trouble, instead of just shooting JPEG directly at default exposure? Well, basically (besides all the other reasons to shoot RAW), so that you can get this:

Example photo A with soft highlights Example photo B with soft highlights

instead of this:

Example photo A with hard highlights Example photo B with soft highlights
(Click images to enlarge.)

Of course, I cheated a bit by making both of these example image pairs from the same RAW files — the only difference is that I used "soft film-like highlights" mode for the first pair, and "hard digital clipping" mode for the second pair, simulating what I would've got if I'd shot them directly in JPEG with a longer exposure.

Note particularly the characteristic cyan sky on the top right in the clipped version of the first image, the unnatural flatness of the clipped highlights, and the general color distortions around them. (Pictures with bright white background elements, such as snow or clouds, tend to show this effect particularly prominently, but I didn't happen to find any good examples on this laptop. I may try to look for some better illustrations later.)

The reason for this flatness and color distortion is that, unlike the smoothly saturating light response curve of film, digital image sensors have an (approximately) linear response up to their saturation point, and then a sharp cutoff:

Digital sensor vs. film response curves
(Actually, the film response curve drawn above is somewhat misleading, in that turning the film negative into an actual positive image introduces another layer of nonlinearity at the low end of the response curve, typically resulting in a somewhat sigmoid combined response curve. But at least at the highlight end of the dynamic range, the curves above do resemble the actual light responses of film and digital cameras in a general way.)

In particular, in color photography, each color channel (red, green and blue) has its own response curve. With a digital sensor, this means that, as the brightness of the incoming light increases, one of the R/G/B channels will typically clip before the others, distorting the color of such partially clipped pixels.

Also, the flatness of the digital response curve above the saturation point means that, whereas overexposing film just compresses the highlights, any clipped highlights in a digital photo (whether RAW or JPEG) are just gone, and no detail can be recovered from them. Thus, the rule of thumb for digital photography is that, if you're not sure what the optimal exposure will be (or if you know that the scene you're shooting includes highlights that you don't want clipped), it's always safer to err on the low side. Sure, pushing up the brightness of an underexposed photo in post-processing will also amplify the noise in the image — but underexposing a little, and losing some shadow detail to noise, is still usually better than overexposing and losing highlights completely.

Of course, none of the above requires you to shoot RAW — you can push up the brightness of JPEG images e.g. in Photoshop just as easily. But compared to RAW, the JPEG format has two issues here:

  • JPEG only uses 8-bit color; that is, the smallest difference between two brightness levels it can store is about 1/256 of the difference between pure black and pure white. JPEG actually uses a non-linear color encoding, which helps somewhat, but the effective dynamic range of a JPEG image is still only about 11 stops (as opposed to the 8 stops one would get with a linear encoding). This is enough for displaying images on screen, but it's still less than the effective dynamic range of even low-end camera sensors, and it doesn't leave much room for adjusting the exposure to recover detail from the shadows.

  • Also, JPEG uses a lossy compression scheme designed to reduce image file size by discarding detail that the human eye cannot easily see. Alas, this compression tends to also throw away shadow details pretty aggressively — increase the brightness of a JPEG image too far, and you'll likely end up with an image full of color distortions and blocky compression artifacts.

A RAW file, in comparison, preserves the full dynamic range of your camera's sensor with no lossy compression, allowing you to post-process the image to the full extent possible (in this case, mainly limited by the sensor's noise floor).

  • Wow. Cheers mate. ;-) – Martin Nov 16 '15 at 19:23
3

In short, a RAW file stores each pixel using more bits than the corresponding JPEG.

To understand how this helps, consider a single pixel (we'll ignore colour, the same logic holds but it just complicates everything). If you have 8 bits available to record the amplitude (amount of light that hit that pixel) you have 256 levels, including "no light at all" (0).

You must set a maximum level, which corresponds to the value 255. The range between 0 and this maximum is the dynamic range that can be represented in the image. Any pixel that receives more light than this level is saturated, and the maximum value of 255 is recorded. This causes the clipping effect, where overexposed areas look completely white.

If you have additional bits, you can represent more levels. With the same dynamic range, you'll get finer steps between them, or you can extend the range and allow pixels with higher (or lower) exposure to be represented somewhere in the range.

A RAW file contains more bits per pixel than the corresponding JPEG (e.g. 14 for Canon 5D, compared to 8 for JPEG). This allows it to capture more levels of exposure. Pixels which would be saturated in an 8-bit representation may not saturate a 14-bit representation. This turns the completely white overexposed areas into shades of grey, and allows some detail to still be captured.

Of course, it's still possible to saturate a higher bit-depth representation, but the more bits you have, the more information you've got to work with.

1

Raw is great for a few other reasons, but of course raw CANNOT prevent clipping of overexposed areas. Once the digital data exceeds 255, it is clipped, meaning it remains at 255, no longer representing true color. Digital simply has no way to retain larger numbers, the largest capability is scaled to 255. There is no way to recover the clipped data, other than another try with less exposure.

The example you show is a white color of light. White is special, having three RGB components nearly equal. But imagine the color (overexposed) was like Red 500, Green 250, Blue 250, which is a red color. But when clipped to 255, it comes out 255, 250, 250, an entirely different color, about white now. Backing off in post processing to about half is still 128, 125, 125, still NOT red.

Your linked example possibly was NOT white in the first place, but it came out overexposed and clipped at 255, 255, 255, which is white. There is no recovery for clipping.

  • 1
    This depends on how the camera has mapped the raw picture to the 8 bit picture. Many cameras will have single image HDR options where you can modify this mapping, the standard setting will have less dynamic range than other settings. So, usually an 8 bit image with clipped parts will not have the same clipped areas in the raw image. To always tone map the entire recorded dynamic range comes at a cost; by just letting small areas to be overexposed you have the range till 255 available for the rest of the image, that may lead to a better overall result. – Count Iblis Nov 16 '15 at 17:43
  • 1
    Wait what? Typical RAWs have 14 bits of luminance information per pixel. There are countless of shades of near-white that can be recovered from a RAW even if they by default would all map to 255,255,255 in a JPEG. – JohannesD Nov 16 '15 at 18:45
  • 2
    If your answer were a response to "16-bit TIFF vs. JPEG" it would be correct, since with a TIFF the black and white points are already baked in and the raw data translated to 16 bits based on the black and white points selected in the conversion. But a true raw file includes the data from masked pixels and doesn't have the black and white points baked in. That's the biggest problem I have with converting Canon .cr2 files to .dng: The masked pixels are discarded and the black/white points are baked in. A DNG is more like a TIFF than a true raw file. – Michael C Nov 17 '15 at 0:27
  • 1
    You can recover very bright details, but you cant recover clipped values. That's why dynamic range is so important. Furhtermore you are mixing dynamic range with bit depth of the ADC. Those are not the same at all, see : peachpit.com/articles/article.aspx?p=1709190&seqNum=2 – Grebu Nov 17 '15 at 13:55
  • 1
    Here's what an image looks like when rendered the way you describe in your answer: The first is linearly rendered, the second has gamma correction applied and 0-2047 in the 14-bit file are mapped as 0 in the 8-bit file and 14383-16383 in the 14-bit file are mapped as 255 in the 8-bit file. The last image has the black point (0 in the 8-bit file) set to the approximate value of the darkest parts of the scene which are well above 2047, and the white point (255 in the 8-bit file) set to the brightest parts of the scene which are well below 14383. photo.stackexchange.com/a/39478/15871 – Michael C Nov 18 '15 at 1:14

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.