Why is everybody still using JPEG files if they can only distinguish between 255 different levels? Does it mean it can only capture a dynamic range of 1:255? It turns out there are clever tricks that people use.
As we mentioned before, the camera sensors capture values that are linear, that is, 4 means that it has 4 times more light than 1, and 80 has 8 times more light than 10. But does the JPEG file format have to use a linear scale? It turns out that it doesn't. So, if we are willing to sacrifice the difference between two values, for example, 100 and 101, we can fit another value there.
To understand this better, let's look at the histogram of gray pixel values of a RAW image. Here is the code to generate that—just ...