How does a camera convert 12/14-bit RAW sensor data into 8-bit JPEG?
Asked 6/11/2022
1 views
2 answers
0
I understand that a camera sensor records RAW data at around 12–14 bits, while JPEG is only 8 bits per channel. How does the camera reduce that data when creating a JPEG? Does it simply discard tonal values, or does it apply a non-linear tone curve or gamma mapping first?
I’m mainly interested in the general process used by modern digital cameras, though examples relevant to Olympus OM-D and Canon EOS M series bodies would also help.
Originally by Photography Stack Exchange contributor. Source · Licensed CC BY-SA 4.0
Photography Stack Exchange contributor
4y ago
2 Answers
1
While the RAW-to-JPEG processing is a huge subject and can only be summarized as "camera can do anything", the question seem to stem from the basic assumption that there is a huge excess of data in the 12-bit RAW form, which can only barely be squeezed into 8-bit JPEG.
No, the sensor manufacturers do not unnecessarily waste resources by producing those 12 bits images only to immediately throw away 1/3 of the bits.
The missing detail is the encoding. Raw sensor data is linear while JPEG (and PNG and display screens in general) are gamma corrected. The 12-bit linear range is "accidentally" similar to the 8-bit sRGB range (only slightly bigger, but not 16 times bigger like it would be in the linear case).
Of course it still means the amount of data is reduced, but it naturally follows from the nonlinearity and all the input bits actually take part in the process. The excess provides some headroom for color and exposure correction and allows for increased precision.
Now, the question can be rephrased for the 14- or 16-bit raws... this time there is no excuse, those cameras really produce "too much" data and allow for greater freedom in postprocessing corrections, tonemapping, shadow/hightlight recovery, etc.
Originally by user32811. Source · Licensed CC BY-SA 4.0
user32811
4y ago
0
Generated from our catalog & community — verify before relying on it.
A camera does not usually make JPEG by simply “chopping off” RAW values. RAW sensor data is linear, while JPEG is a processed, display-ready format with a non-linear tone curve/gamma (typically similar to sRGB). That remapping allocates more code values where our eyes notice differences most, so 8-bit JPEG can represent tone surprisingly well.
In general, the camera pipeline is roughly:
- Read linear RAW sensor data
- Demosaic Bayer data into full color
- Apply white balance, color conversion, contrast, sharpening, noise reduction, etc.
- Apply a tone curve/gamma mapping
- Quantize to 8 bits per channel
- Compress as JPEG
So yes, information is reduced, but not by blindly throwing away the “tails” of the histogram. The important step is the non-linear encoding: human vision is closer to logarithmic than linear, and gamma/tone mapping uses that to preserve visible tonal gradation efficiently.
Also, RAW bit depth and JPEG bit depth are not directly comparable one-to-one: RAW is sensor data, while JPEG is a rendered color image. Different camera brands/models may tune the tone curve and JPEG processing differently, but the basic idea is the same.
Recommended products
UniqueBot
AI4y ago
Your Answer
Related Questions
How are RAW and HDR images mapped to 8-bit for display?
How is 12-bit RAW sensor data turned into an 8-bit JPEG or screen image?
How many bits of data does a digital camera sensor actually capture?
How much real-world difference is there between 12-bit and 14-bit RAW?
Why do RAW files capture 12/14-bit data but the camera only shows an 8-bit preview and histogram?