Why can RAW files recover some blown highlights that JPEGs cannot?
Asked 5/18/2013
1 views
2 answers
0
When I shoot RAW on my Sony A99, I sometimes overexpose by about a stop and can pull the exposure back in post to recover detail that looked blown in-camera. With JPEG, those highlights seem permanently clipped.
Why does this happen? Is the camera histogram only showing the JPEG preview rather than the full RAW data? Does RAW effectively contain extra headroom that the histogram doesn’t show? And why does highlight recovery often seem easier than recovering detail from very dark shadows?
Originally by Photography Stack Exchange contributor. Source · Licensed CC BY-SA 4.0
Photography Stack Exchange contributor
13y ago
2 Answers
32
This is one of the benefits you get from shooting raw.
You can't recover highlight or shadow detail from a JPEG because it has 8 bits of color depth per color component,1 and it's mapped so that the lowest pixel value is interpreted as "black," and the highest is "white." There simply is nothing below black or above white. The creators of JPEG did this because 8 bpc is adequate for humans to perceive a properly-exposed full-color image.2 The human eye has greater dynamic range than JPEG allows, but it can't see that full range all the time.3
Most raw-capable cameras are capable of capturing at least 10 bpc. 12 bpc+ is very common, and 14 bpc+ is possible with the best sensors. The trick is, how to make use of this additional dynamic range? There are several design spaces in which to find a solution:
Full range capture and display
The camera's exposure meter could try to capture as much dynamic range as is physically possible, and it could attempt to display it all on the little screen on the back of the camera. Your raw processing software could likewise attempt to show you all of the dynamic range in the image file on screen. When saving a JPEG, the camera could just map this full dymamic range in the obvious way, effectively discarding the least significant bits from the sensor.
No one does this.4
If you take a picture of a backlit bush at sunset, the camera could attempt to capture the black ants in the dark gray shadow under the dense dark green foliage while at the same time capturing sun spot detail in the sun's disc.
Cameras don't do this because the resulting image would look like striped mud. Human eyes don't have the dynamic range to see the ants and the sun spots at the same time, so human brains don't expect to see such things.5 We don't have display technology good enough to reproduce a physically correct image, either.6
Slice from the middle
Instead, the camera could simply put its notion of "correct" exposure right in the middle of the range, and extract the 8-bit JPEG and the screen preview from the middle of the range. If your camera has a 12-bit sensor, it could effectively give you a ±2 stop exposure adjustment range, since every 1 bpc translates into 1 stop, in photographic terms.
I don't think that this is an entirely bad way to go, but it wouldn't give the most pleasing imagery. Camera companies that did this wouldn't be selling many cameras.
Black point and gamma curve
A much better plan is to pick a brightness level in the image to call black7 and then choose a gamma curve to remap the raw sensor data into that 8 bpc range.
With this method, the camera and raw processing software can choose to leave some of the raw data outside the mapped range, so that the raw image file encodes blacker-than-black and brighter-than-white. This is the region you're pulling from when your raw processing software recovers highlight or shadow detail.
There is no universal authority mandating which method to use, and even if there were, there is plenty of variation in existing technology and still plenty more room for further variation. For example, Lossy DNGs use an 8 bpc color space, but the nonlinear way the input image data is mapped to output values, you still have a bit of dynamic range to work with outside the normally visible display range.
Footnotes:
8 bpc is also called "24-bit" by those who prefer to consider all three channels needed for color imaging together.
At any single moment, the human eye has less dynamic range than you get from 8 bpc. The only reason we use even that many bits per channel is that computers like dealing with data in 8-bit chunks, as do digital displays. Any value a 7 bpc or 9 bpc variant of JPEG might have is wiped out by decades of historical inertia pushing us to stick with 8.
If your eyes could use their full dynamic range all the time, you wouldn't have to squint for a while when walking outside from a dimly lit house at noon, or when turning on the bedside light when waking up in the dark.
I have no doubt this has been tried several times in research labs. I'd even be unsurprised to learn that software has been made publicly available that does this. If I wanted to be precisely correct, I'd have to rewrite that sentence to something less punchy like, "No one has been commercially successful producing software or hardware that presents images using this method."
This is part of the reason it's hard to make a good HDR.
And if we did have such technology, you wouldn't be able to look at the sun in the reproduced image, any more than you could while taking the picture.
Or white, if you prefer. It really doesn't matter. You can work the math either way.
Originally by user4141. Source · Licensed CC BY-SA 4.0
user4141
13y ago
0
Generated from our catalog & community — verify before relying on it.
Yes—what you’re seeing is mainly because the camera’s histogram and preview are based on an in-camera JPEG, even when you shoot RAW. That JPEG is only 8 bits per channel, so once highlights hit pure white in the preview, they look clipped.
The RAW file usually contains more tonal information—typically 12 to 14 bits per channel—and records more of the sensor’s full dynamic range. In post, lowering exposure changes which portion of that larger range gets mapped into the limited display/output range, so detail that looked blown in the JPEG preview can reappear.
It’s not that the camera is secretly “reserving” space just for mistakes; it’s that the JPEG preview shows a more limited rendering than the RAW data actually contains.
Shadow recovery is less forgiving because very dark areas contain less usable signal and are more affected by noise. If the data is truly clipped to white or crushed to black at the sensor level, it cannot be recovered from RAW either. RAW just gives you more latitude before that point than JPEG does.
Recommended products
UniqueBot
AI13y ago
Your Answer
Related Questions
Are in-camera histograms based on the JPEG preview, and can they miss RAW highlight or shadow detail?
Do modern digital cameras recover blown highlights better than older models?
Why do bright highlights lose detail on a Nikon D700, even when shooting RAW?
What real-world advantages does RAW have over JPEG, and are there example scenarios?
How can I visualize the full dynamic range in a RAW file while editing in Lightroom?