Doug Kerr
Well-known member
It is well recognized that is we seek to manipulate the tonal scale mapping of an image (perhaps to overcome the results of less-than-optimum exposure), we will generally have more success if working with the raw output of the camera than with the JPEG output.
In a recent very insightful discussion of the notions of the "richness" and "robustness" of images, one of our members commented (color emphasis added for ease of later reference):
I did not remember having heard the notion in blue before, and I decided to look into just what that might mean.
The JPEG data compression
I first looked into whether the actual JPEG "data compression" process somehow allocates less bits of the delivered data to representing the color of points with lower luminance. I can't find anyplace where that seems to happen. Of course, it could happen in some very obscure way that I missed - the whole process is very complex.
sRGB gamma precompensation
Next I looked into whether this might be an implication of the "gamma precompensation" that is part of the sRGB color space upon which the JPEG representation we use is (indirectly) based. This refers to the fact that the 8-bit R, G, and B values are not linear representations of the corresponding coordinates of the color space.
We find that near the very bottom of the tonal scale (lets say at about 8 stops down from the saturation luminance), a one unit difference in R,G,B represents a difference in luminance of about 0.0003 (where 1.000 represents saturation luminance).
In contrast, at 1/2 stop down from the saturation luminance, a one unit difference in R,G,B represents a difference in luminance of about 0.007.
Thus, if we think in the representation of absolute luminance, the precision of representation in the "dark" region is about 23 times as precise as in the "light" region.
But of course the human response to luminance is itself logarithmic, so perhaps we should consider the precision of the representation not of absolute differences between luminances but rather of luminance difference ratios.
In our "light" region, we find that one unit of R,G,B corresponds to a luminance change of about 1%.
In our "dark" region, we find that one unit of R,G,B corresponds to a luminance change of about 8%, which we can in a certain sense consider to be "8 times worse precision".
So perhaps this is the sense in which lower luminances are recorded "less precisely".
In fact, the gamma precompensation mitigates this effect (one of its purposes). If we instead imagined a linear 8-bit RGB representation, then:
• In our "light" region, at a base luminance 0.5 stops below saturation, one RGB unit (up) would correspond to a change in luminance of 0.5%.
• In our "dark" region, at a base luminance 8 stops below saturation, one RGB unit (up) would correspond to a change in luminance of 100%, which we can in a certain sense consider to be "200 times worse precision".
Loss of sensor precision
In many digital cameras, the luminance detected by the photodetectors is registered on a 12-bit basis. In the sRGB color space used in our JPEG files, luminance is in effect recorded on an 8-bit basis. We can easily imagine this "reduction in precision" to be a cause of worse results when making changes in tonal mapping using the JPEG output of the camera compared to using the raw output. And this wisdom is broadly true.
But in this article we are focusing on the "darker regions" of the image.
We noted above that at 8 stops down from saturation, a one-unit change in the RGB encoding corresponds to a luminance difference of 0.0003 (where 1.000 represents saturation luminance).
If we were working with 12-bit raw values, a one-unit change would correspond to a luminance difference of 0.00024.
Thus, in this region, the precision of luminance representation via the sRGB color space is only 1.2 times less precise than that via the raw data.
Of course, if we consider a camera with 14-bit encoding, the precision in luminance afforded by the raw data is, even in this region, substantially greater than with the JPEG representation.
Observation
Thus I am so far unable to find an actual situation that seems to fit the concept of the JPEG representation devoting less data to the dark areas.
So what does happen?
So then how is it that, when trying to do a postprocessing "exposure adjustment", we have less success working with a JPEF representation than a raw representation (and I concentrate here on the "darker areas" of the image)?
Well, I don't really know. I would be eager to hear the views of my colleagues here on this conundrum.
One author has suggested that in the typical digital camera, when processing the sensor data into JPEG form, a transfer curve is applied to give the "nicest looking" images in typical cases. These curves may well "compress" both the very dark and very light regions.
That's what we know here for now.
Best regards,
Doug
In a recent very insightful discussion of the notions of the "richness" and "robustness" of images, one of our members commented (color emphasis added for ease of later reference):
A good example of "less rich" pictures [based on his earlier discussion, I suspect the writer may have meant here "less robust"] are compressed jpeg pictures. Jpeg is dependent on the limitations of human vision to achieve good compression. For example, it [JPEG] spends less data on dark parts, because human vision is less sensitive to details in the darker parts. When one raises the shadows, this becomes obvious and the image breaks (which is to be expected).
I did not remember having heard the notion in blue before, and I decided to look into just what that might mean.
The JPEG data compression
I first looked into whether the actual JPEG "data compression" process somehow allocates less bits of the delivered data to representing the color of points with lower luminance. I can't find anyplace where that seems to happen. Of course, it could happen in some very obscure way that I missed - the whole process is very complex.
sRGB gamma precompensation
Next I looked into whether this might be an implication of the "gamma precompensation" that is part of the sRGB color space upon which the JPEG representation we use is (indirectly) based. This refers to the fact that the 8-bit R, G, and B values are not linear representations of the corresponding coordinates of the color space.
We find that near the very bottom of the tonal scale (lets say at about 8 stops down from the saturation luminance), a one unit difference in R,G,B represents a difference in luminance of about 0.0003 (where 1.000 represents saturation luminance).
In contrast, at 1/2 stop down from the saturation luminance, a one unit difference in R,G,B represents a difference in luminance of about 0.007.
Thus, if we think in the representation of absolute luminance, the precision of representation in the "dark" region is about 23 times as precise as in the "light" region.
But of course the human response to luminance is itself logarithmic, so perhaps we should consider the precision of the representation not of absolute differences between luminances but rather of luminance difference ratios.
In our "light" region, we find that one unit of R,G,B corresponds to a luminance change of about 1%.
In our "dark" region, we find that one unit of R,G,B corresponds to a luminance change of about 8%, which we can in a certain sense consider to be "8 times worse precision".
So perhaps this is the sense in which lower luminances are recorded "less precisely".
In fact, the gamma precompensation mitigates this effect (one of its purposes). If we instead imagined a linear 8-bit RGB representation, then:
• In our "light" region, at a base luminance 0.5 stops below saturation, one RGB unit (up) would correspond to a change in luminance of 0.5%.
• In our "dark" region, at a base luminance 8 stops below saturation, one RGB unit (up) would correspond to a change in luminance of 100%, which we can in a certain sense consider to be "200 times worse precision".
Loss of sensor precision
In many digital cameras, the luminance detected by the photodetectors is registered on a 12-bit basis. In the sRGB color space used in our JPEG files, luminance is in effect recorded on an 8-bit basis. We can easily imagine this "reduction in precision" to be a cause of worse results when making changes in tonal mapping using the JPEG output of the camera compared to using the raw output. And this wisdom is broadly true.
But in this article we are focusing on the "darker regions" of the image.
We noted above that at 8 stops down from saturation, a one-unit change in the RGB encoding corresponds to a luminance difference of 0.0003 (where 1.000 represents saturation luminance).
If we were working with 12-bit raw values, a one-unit change would correspond to a luminance difference of 0.00024.
Thus, in this region, the precision of luminance representation via the sRGB color space is only 1.2 times less precise than that via the raw data.
Of course, if we consider a camera with 14-bit encoding, the precision in luminance afforded by the raw data is, even in this region, substantially greater than with the JPEG representation.
Observation
Thus I am so far unable to find an actual situation that seems to fit the concept of the JPEG representation devoting less data to the dark areas.
So what does happen?
So then how is it that, when trying to do a postprocessing "exposure adjustment", we have less success working with a JPEF representation than a raw representation (and I concentrate here on the "darker areas" of the image)?
Well, I don't really know. I would be eager to hear the views of my colleagues here on this conundrum.
One author has suggested that in the typical digital camera, when processing the sensor data into JPEG form, a transfer curve is applied to give the "nicest looking" images in typical cases. These curves may well "compress" both the very dark and very light regions.
That's what we know here for now.
Best regards,
Doug