What is the dynamic range of a JPEG image?

Started Jan 9, 2016 | Discussions
xpatUSA
xpatUSA Forum Pro • Posts: 15,195
What is the dynamic range of a JPEG image?

By which I mean the dynamic range in EV (DR) of the image itself, not that of the scene that it represents and not that of the raw data from which it was derived.

I do hope to avoid devolution into a discussion of noise levels as regards the proper choice of the lower value part of the equation. Therefore, for a discussion image, I would like to posit a JPEG image which, for simplicity of calculation, has been saved as a ProPhoto image.

Say the max level in the posited image (color-picker-wise) is 240 and the minimum is 4. Make it gray-scale to avoid obfuscation by color.

Is the dynamic range of the image calculated from the values of the levels in the image (where min level > 0) or is it calculated from the reverse transformation of those values into linear values?

Specifically, is the DR:

a) log(2)(240/4)?

or

b) log(2)(240^1.8/4^1.8)?

I ask because I see so often that the max DR of a JPEG is 8 EV but I also see it said as being more than that, e.g. 11 EV.

N.B. I chose ProPhoto to avoid obfuscation due to the true sRGB gamma calculation.

-- hide signature --

Ted

 xpatUSA's gear list:xpatUSA's gear list
Sigma DP2 Sigma DP2 Merrill Panasonic Lumix DMC-G1 Sigma SD15 Panasonic Lumix DMC-GH1 +16 more
Detail Man
Detail Man Forum Pro • Posts: 17,069
Re: What is the Maximum (linear) NOBs Encode-able into an 8-bit JPEG ?

Assume linearly encoded image-data.

JPEG encoding applies gamma-correction (or operates upon already gamma-corrected image-data) prior to RGB > YCbCr color-space conversion. (Even when no Chroma Sub-sampling or Quantization Data Compression are utilized), quantization to 8-bits takes place [within the Quantization Data Compression stage, limiting the processed data to 8-bits prior to loss-less "entropy coding" compression taking place].

To determine how many "extra bits" can be "squeezed-in" (due to the existing gamma-correction), I calculated the derivative of the non-linear transfer-function at the (non-discontinous) lowest value of non-linear compression (0.00313066844250063), which is 12.7033888061, and divided that value by the derivative of the non-linear transfer-function at the highest value of non-linear compression (which is 0.43958333333). Taking the logarithm to the base 2 of that ratio, the result is equal to an increase of 4.85293290926 [bits].

Add that to 8 bits, and I get a total of 12.85293290926 bits - which (may) exceed the (effective, meaningful) bit-depth of a de-mosaiced RAW (or TIFF) file to be JPEG-encoded.

RMS Quantization Error of plus/minus 1/2 LSB equals 1 / ( (2)^(1/2) ) = 0.22675134595 LSB. Taking the logarithm to the base 2, I get a value of -1.79248125036 (relative to unity value of 1.0).

So it appears that the (potential) maximum (linearly encoded) input data-range that JPEG encoding can represent equals 12.85293290926 + 1.79248125036 = 14.6454141597 [bits].

.

Those calculations do not adequately describe what the image-data "information...capacity" would be.

.

DM

xpatUSA
OP xpatUSA Forum Pro • Posts: 15,195
Re: What is the Maximum (linear) NOBs Encode-able into an 8-bit JPEG ?

Detail Man wrote:

Assume linearly encoded image-data.

Is "NOBs" in the title "number of bits"?

JPEG encoding applies gamma-correction (or operates upon already gamma-corrected image-data) prior to RGB > YCbCr color-space conversion.

Should that be Y'CbCr or are you remaining linear for the conversion?

(Even when no Chroma Sub-sampling or Quantization Data Compression are utilized), quantization to 8-bits takes place [within the Quantization Data Compression stage, limiting the processed data to 8-bits prior to loss-less "entropy coding" compression taking place].

I have no idea what "entropy coding" is. Don't really know what "Quantization Data Compression" is either.

To determine how many "extra bits" can be "squeezed-in" (due to the existing gamma-correction), I calculated the derivative of the non-linear transfer-function at the (non-discontinous) lowest value of non-linear compression (0.00313066844250063),

Bad link, error 404

which is 12.7033888061, and divided that value by the derivative of the non-linear transfer-function at the highest value of non-linear compression (which is 0.43958333333). Taking the logarithm to the base 2 of that ratio, the result is equal to an increase of 4.85293290926 [bits].

I'll have to take your word for it, the response is well beyond my ken, sorry

Add that to 8 bits, and I get a total of 12.85293290926 bits - which (may) exceed the (effective, meaningful) bit-depth of a de-mosaiced RAW (or TIFF) file to be JPEG-encoded.

OK

RMS Quantization Error of plus/minus 1/2 LSB equals 1 / ( (2)^(1/2) ) = 0.22675134595 LSB. Taking the logarithm to the base 2, I get a value of -1.79248125036 (relative to unity value of 1.0).

I'll take your word for it. the response is beyond my ken.

So it appears that the (potential) maximum (linearly encoded) input data-range that JPEG encoding can represent equals 12.85293290926 + 1.79248125036 = 14.6454141597 [bits].

An interesting result, thank you. So, now we have calculated  a maximum bit range, can we consider a work-flow?

Suppose I work on a raw file with unspecified editing and export a 16-bit TIFF. Do I say that the TIFF data "bit maximum" for conversion to JPEG is 14bits or 15bits? Would that TIFF have to be linear, as I suspect.

.

Those calculations do not adequately describe what the image-data "information...capacity" would be.

One of those links includes the camera lens abberations etc. and is again beyond my ken. The other is a discourse on the well-known discontinuity in sRGB gamma correction.

From the title change, it appears that the question is incorrect?

-- hide signature --

Ted

 xpatUSA's gear list:xpatUSA's gear list
Sigma DP2 Sigma DP2 Merrill Panasonic Lumix DMC-G1 Sigma SD15 Panasonic Lumix DMC-GH1 +16 more
xpatUSA
OP xpatUSA Forum Pro • Posts: 15,195
Re: What is the dynamic range of a JPEG image?

xpatUSA wrote:

By which I mean the dynamic range in EV (DR) of the image itself, not that of the scene that it represents and not that of the raw data from which it was derived.

Say the max level in the posited image (color-picker-wise) is 240 and the minimum is 4. Make it gray-scale to avoid obfuscation by color.

Is the dynamic range of the image calculated from the values of the levels in the image (where min level > 0) or is it calculated from the reverse transformation of those values into linear values?

Specifically, is the DR:

a) log(2)(240/4)?

or

b) log(2)(240^1.8/4^1.8)?

I ask because I see so often that the max DR of a JPEG is 8 EV but I also see it said as being more than that, e.g. 11 EV.

N.B. I chose ProPhoto to avoid obfuscation due to the true sRGB gamma calculation.

Prompted by DM's response or at least the part that I understood, it seems that the question above is all wrong and that I should at least be talking about linear Y.

So I've changed tack and used Bruce's calculator to avoid tedious arithmetic. First, I entered sRGB numbers 1,1,1 and then 255,255,255 to get the Y part of xyY (linear luminance) and calculated the DR as log(2)(Y1/Y255) EV. Gamma "sRGB" and Bradford D65.

Then I repeated the exercise for ProPhoto, gamma 1.8, Bradford D50.

I got 11.64 EV for sRGB and 14.377 EV for ProPhoto.

It is probably too simple an approach but I'm after ball-park figures (sorry, DM) in order to refute the claim that "the DR" for JPEG is 8 EV.

-- hide signature --

Ted

 xpatUSA's gear list:xpatUSA's gear list
Sigma DP2 Sigma DP2 Merrill Panasonic Lumix DMC-G1 Sigma SD15 Panasonic Lumix DMC-GH1 +16 more
D Cox Forum Pro • Posts: 23,749
Re: What is the dynamic range of a JPEG image?
1

Are you looking for a graph of "Number-of-Photons-Hitting-a-Pixel" against numbers in the file from zero to 255 ?  I think this will vary according to the particular sensor and the ISO setting.

It is not fixed that zero photons is represented by zero in a file, nor that a full well is represented by 255. Nor is it fixed that in a 16-bits-per-channel zero photons is coded by zero and a full well by 65536.

The range of photon numbers covered by the coding is basically the same for both, but the 16-bit file has finer steps. Either 8 or 16 (or any number) bit files can represent any range of numbers of photons.

Does "the dynamic range" of a file mean anything other than "the range of integers that are used for coding"?

D Cox Forum Pro • Posts: 23,749
Re: What is the Maximum (linear) NOBs Encode-able into an 8-bit JPEG ?

xpatUSA wrote:

Suppose I work on a raw file with unspecified editing and export a 16-bit TIFF. Do I say that the TIFF data "bit maximum" for conversion to JPEG is 14bits or 15bits? Would that TIFF have to be linear, as I suspect.

This is a downscaling problem. You want to map the integers from zero to 65536 onto the integers from zero to 255.

I see no reason why the 16-bit file has to be using linear or any other coding for this.  Nor why you want to drop one or two bits first.

xpatUSA
OP xpatUSA Forum Pro • Posts: 15,195
Re: What is the Maximum (linear) NOBs Encode-able into an 8-bit JPEG ?

D Cox wrote:

xpatUSA wrote:

Suppose I work on a raw file with unspecified editing and export a 16-bit TIFF. Do I say that the TIFF data "bit maximum" for conversion to JPEG is 14bits or 15bits? Would that TIFF have to be linear, as I suspect.

This is a downscaling problem. You want to map the integers from zero to 65536 onto the integers from zero to 255.

I see no reason why the 16-bit file has to be using linear or any other coding for this. Nor why you want to drop one or two bits first.

Not sure what we are discussing here. DM said:

So it appears that the (potential) maximum (linearly encoded) input data-range that JPEG encoding can represent equals 12.85293290926 + 1.79248125036 = 14.6454141597 [bits].

I was responding to that number "14.6454141597 [bits]" and trying to related that to a 16-bit file. No more than that. I am of course becoming confused, as usual.

-- hide signature --

Ted

 xpatUSA's gear list:xpatUSA's gear list
Sigma DP2 Sigma DP2 Merrill Panasonic Lumix DMC-G1 Sigma SD15 Panasonic Lumix DMC-GH1 +16 more
Mark Scott Abeln
Mark Scott Abeln Forum Pro • Posts: 13,685
Re: What is the dynamic range of a JPEG image?
1

D Cox wrote:

Does "the dynamic range" of a file mean anything other than "the range of integers that are used for coding"?

You make a good point, since some pretty arbitrary processing can be done during raw conversion.

From the sRGB standard, the white point is 80 cd/m^2 while the black point is 0.2 cd/m^2, which gives us a ratio of 400:1 or 8.6 stops, which seems rather paltry. And this assumes viewing on a calibrated monitor, and tells us nothing of the scene encoded in the image.

 Mark Scott Abeln's gear list:Mark Scott Abeln's gear list
Nikon D200 Nikon D7000 Nikon D750 Nikon AF-S DX Nikkor 35mm F1.8G Nikon AF Nikkor 50mm f/1.8D +2 more
xpatUSA
OP xpatUSA Forum Pro • Posts: 15,195
Re: What is the dynamic range of a JPEG image?

D Cox wrote:

Are you looking for a graph of "Number-of-Photons-Hitting-a-Pixel" against numbers in the file from zero to 255 ? I think this will vary according to the particular sensor and the ISO setting.

No, Don. I am looking for the reason why some people say a JPEG's dynamic range is 8 stops (by virtue of JPEG being 8-bit) and others say it is more, e.g. 11 stops.

It is not fixed that zero photons is represented by zero in a file, nor that a full well is represented by 255. Nor is it fixed that in a 16-bits-per-channel zero photons is coded by zero and a full well by 65536.

That does seem rather obvious.

The range of photon numbers covered by the coding is basically the same for both, but the 16-bit file has finer steps. Either 8 or 16 (or any number) bit files can represent any range of numbers of photons.

Also seems obvious, but I don't see what you're trying to tell me. Perhaps between this rather basic talk of photons hitting pixels and DM's scientific complexity there is a medium answer.

Does "the dynamic range" of a file mean anything other than "the range of integers that are used for coding"?

Please read DM's post above where, apparently, it does.

Perhaps I should have asked:

"What is the definition of dynamic range for a JPEG image?"

 xpatUSA's gear list:xpatUSA's gear list
Sigma DP2 Sigma DP2 Merrill Panasonic Lumix DMC-G1 Sigma SD15 Panasonic Lumix DMC-GH1 +16 more
Jack Hogan Veteran Member • Posts: 6,990
Re: What is the dynamic range of a JPEG image?
2

xpatUSA wrote: Prompted by DM's response or at least the part that I understood, it seems that the question above is all wrong and that I should at least be talking about linear Y.

So I've changed tack and used Bruce's calculator to avoid tedious arithmetic. First, I entered sRGB numbers 1,1,1 and then 255,255,255 to get the Y part of xyY (linear luminance) and calculated the DR as log(2)(Y1/Y255) EV. Gamma "sRGB" and Bradford D65.

Then I repeated the exercise for ProPhoto, gamma 1.8, Bradford D50.

I got 11.64 EV for sRGB and 14.377 EV for ProPhoto.

Hi Ted, imho those numbers are too big. Recall that

DR = Maximum recordable signal / minimum acceptable signal.

The numerator is easy to determine, the denominator harder because subjective. If we assume 8-bit sRGB, Jpeg Numbers (JN) near zero are linearly related to the input (in e- or approximately also to 14-bit raw data). Ignoring perceptual effects, if we assume a clean capture at base ISO the minimum acceptable signal is probably going to be limited by quantization error as the familiar SNR=x criterion for acceptability (x=1 for engineers) goes out the window at these tiny gains* in JN/e-. So the minimum acceptable signal is even more subjective and probably going to be determined by how much quantization error you are willing to stomach: 1%, 10%, 30%...

How low will you go?

I think by looking at the graph above most people would feel that the signal stops being acceptable somewhere below 2DN possibly as low as 0.5 or even 0.25 (JN in this post, the graph comes from this article ). So that's the denominator from which this Jpeg's DR can be very subjectively estimated at somewhere around 7-10 stops.  What would you choose?

This is with a very clean capture. As more electronic noise is added it starts becoming the dominant factor in the denominator. But then you are measuring the DR of the image data, not the Jpeg container.

Jack

* The gain in the graph is 0.125DN/e-. As a reference, assume a camera with FWC of about 26400e-. Then for 8-bit sRGB signals near zero in the linear region gain = 12.92*255/26400 = 0.125JN/e-.

xpatUSA
OP xpatUSA Forum Pro • Posts: 15,195
Re: What is the dynamic range of a JPEG image?

Jack Hogan wrote:

xpatUSA wrote: Prompted by DM's response or at least the part that I understood, it seems that the question above is all wrong and that I should at least be talking about linear Y.

So I've changed tack and used Bruce's calculator to avoid tedious arithmetic. First, I entered sRGB numbers 1,1,1 and then 255,255,255 to get the Y part of xyY (linear luminance) and calculated the DR as log(2)(Y1/Y255) EV. Gamma "sRGB" and Bradford D65.

Then I repeated the exercise for ProPhoto, gamma 1.8, Bradford D50.

I got 11.64 EV for sRGB and 14.377 EV for ProPhoto.

Hi Ted, imho those numbers are too big. Recall that

DR = Maximum recordable signal / minimum acceptable signal.

The numerator is easy to determine, the denominator harder because subjective. If we assume 8-bit sRGB, Jpeg Numbers (JN) near zero are linearly related to the input (in e- or approximately also to 14-bit raw data). Ignoring perceptual effects, if we assume a clean capture at base ISO the minimum acceptable signal is probably going to be limited by quantization error as the familiar SNR=x criterion for acceptability (x=1 for engineers) goes out the window at these tiny gains* in JN/e-. So the minimum acceptable signal is even more subjective and probably going to be determined by how much quantization error you are willing to stomach: 1%, 10%, 30%...

How low will you go?

I think by looking at the graph above most people would feel that the signal stops being acceptable somewhere below 2DN possibly as low as 0.5 or even 0.25 (JN in this post, the graph comes from this article ). So that's the denominator from which this Jpeg's DR can be very subjectively estimated at somewhere around 7-10 stops. What would you choose?

This is with a very clean capture. As more electronic noise is added it starts becoming the dominant factor in the denominator. But then you are measuring the DR of the image data, not the Jpeg container.

Jack

* The gain in the graph is 0.125DN/e-. As a reference, assume a camera with FWC of about 26400e-. Then for 8-bit sRGB signals near zero in the linear region gain = 12.92*255/26400 = 0.125JN/e-.

Thanks, Jack:

I should have asked "What is the definition for the dynamic range of a JPEG image?"

In the OP, I did say "I do hope to avoid devolution into a discussion of noise levels as regards the proper choice of the lower value part of the equation. Therefore, for a discussion image, I would like to posit a JPEG image which, for simplicity of calculation [gamma-wise], has been saved as a ProPhoto image. Say the max level in the posited image (color-picker-wise) is 240 and the minimum is 4."

What would be your calculation for a ProPhoto JPEG image where the max RGB is 240,240,240 and the min RGB is 4,4,4?

-- hide signature --

Ted

 xpatUSA's gear list:xpatUSA's gear list
Sigma DP2 Sigma DP2 Merrill Panasonic Lumix DMC-G1 Sigma SD15 Panasonic Lumix DMC-GH1 +16 more
Jack Hogan Veteran Member • Posts: 6,990
Re: What is the dynamic range of a JPEG image?

xpatUSA wrote: What would be your calculation for a ProPhoto JPEG image where the max RGB is 240,240,240 and the min RGB is 4,4,4?

I am going to pull a quick attribute substitution while you are not looking and say that what that's going to give you is the contrast ratio of the image, as opposed to the DR of any item in the chain. Following DM's approach, where color data is reverted to linear relative luminance according to ProPhoto's gamma curve, for an 8-bit file resulting from encoding 14-bit raw data:

Contrast Ratio = 228.58 / 0.25682 = 890.

The same exercise with sRGb results in a CR of 713. The question is whether these contrast ratios can be related back to some form of a DR.

D Cox Forum Pro • Posts: 23,749
Re: What is the dynamic range of a JPEG image?

xpatUSA wrote:

D Cox wrote:

Are you looking for a graph of "Number-of-Photons-Hitting-a-Pixel" against numbers in the file from zero to 255 ? I think this will vary according to the particular sensor and the ISO setting.

No, Don. I am looking for the reason why some people say a JPEG's dynamic range is 8 stops (by virtue of JPEG being 8-bit) and others say it is more, e.g. 11 stops.

I think because they are confused between two completely different uses of binary numbers.

The difference between a JPG file and a 16-bit TIF file is not the range but the number of steps (integers) within that range. A 16-bit file can potentially give you better gradation, but not better dynamic range.

It is not fixed that zero photons is represented by zero in a file, nor that a full well is represented by 255. Nor is it fixed that in a 16-bits-per-channel zero photons is coded by zero and a full well by 65536.

That does seem rather obvious.

That means we are on a good track.

The range of photon numbers covered by the coding is basically the same for both, but the 16-bit file has finer steps. Either 8 or 16 (or any number) bit files can represent any range of numbers of photons.

Also seems obvious, but I don't see what you're trying to tell me. Perhaps between this rather basic talk of photons hitting pixels and DM's scientific complexity there is a medium answer.

I'm not really trying to tell you anything, but to get down to basics in my own mind. Let's keep it simple (which means leave out colour, and probably noise too).

Does "the dynamic range" of a file mean anything other than "the range of integers that are used for coding"?

Please read DM's post above where, apparently, it does.

I think he is mistaken.

Perhaps I should have asked:

"What is the definition of dynamic range for a JPEG image?"

JDinOregon Junior Member • Posts: 46
Re: What is the dynamic range of a JPEG image?

Mark Scott Abeln wrote:

D Cox wrote:

Does "the dynamic range" of a file mean anything other than "the range of integers that are used for coding"?

You make a good point, since some pretty arbitrary processing can be done during raw conversion.

From the sRGB standard, the white point is 80 cd/m^2 while the black point is 0.2 cd/m^2, which gives us a ratio of 400:1 or 8.6 stops, which seems rather paltry. And this assumes viewing on a calibrated monitor, and tells us nothing of the scene encoded in the image.

The 0.2 to 80 cd/m^s range is what I would consider as the intended dynamic range of sRGB. Perhaps the 0.2cd/m^2 number is more of an upper bound of the blackest black. This would be limited by flare, reflections, and the lack of little "black holes" in the display. The ability to adequately represent the levels between white and black is nicely presented by "http://www.normankoren.com/digital_tonality.html" which I'm sure most of us have read.

xpatUSA
OP xpatUSA Forum Pro • Posts: 15,195
Re: What is the dynamic range of a JPEG image?

Jack Hogan wrote:

xpatUSA wrote: What would be your calculation for a ProPhoto JPEG image where the max RGB is 240,240,240 and the min RGB is 4,4,4?

I am going to pull a quick attribute substitution while you are not looking and say that what that's going to give you is the contrast ratio of the image, as opposed to the DR of any item in the chain. Following DM's approach, where color data is reverted to linear relative luminance according to ProPhoto's gamma curve

Trying to keep up, is the linear relative luminance in units of Y as given by aR+bG+cB where a,b,c are the coefficients found in Rec. 709 etc? In which case, can I instead use Bruce's CIE calculator, converting RGB numbers (for a color space, it's illuminant and exponent) to XYZ or xyY and use those values of Y to derive what has now become 'Contrast Ratio'?

for an 8-bit file resulting from encoding 14-bit raw data:

Contrast Ratio = 228.58 / 0.25682 = 890.

Trying to match that first number (to see if I'm following) using said BT.709 coefficients for the higher JPEG level R=G=B=240:

Y = 0.2126 R + 0.7152 G + 0.0722 B where RGB are linear and normalized to 1

Y = (0.2126x(240/255)^1.8+0.7152x(240/255)^1.8+0.0722x(240/255)^1.8)x255 = 229.74 so I'm wrong as usual. Wrong coefficients? Looks like you might have use D50 adapted . . .

. . . in which case could I use Bruce's calculator but select D50 going from RGB to XYZ.

The same exercise with sRGb results in a CR of 713. The question is whether these contrast ratios can be related back to some form of a DR.

-- hide signature --

Ted

 xpatUSA's gear list:xpatUSA's gear list
Sigma DP2 Sigma DP2 Merrill Panasonic Lumix DMC-G1 Sigma SD15 Panasonic Lumix DMC-GH1 +16 more
Roland Karlsson Forum Pro • Posts: 28,248
Re: What is the dynamic range of a JPEG image?

D Cox wrote:

xpatUSA wrote:

No, Don. I am looking for the reason why some people say a JPEG's dynamic range is 8 stops (by virtue of JPEG being 8-bit) and others say it is more, e.g. 11 stops.

I can disclose - I am the source of all this

I think because they are confused between two completely different uses of binary numbers.

Eh? Now you got me really confused? Two completely different uses of binary numbers?

The difference between a JPG file and a 16-bit TIF file is not the range but the number of steps (integers) within that range.

OK? Even more confused?

The JPEG has that 8+ (sometimes called 11) in dynamic range and a linear 16 bit TIFF has 16 stops.

A 16-bit file can potentially give you better gradation, but not better dynamic range.

Just to try to sort things out.

Yes, often when converting between digital formats, then the max value of one representation matches the max value of the other one. So - when converting from 16 bit TIFF to JPEG then 64k-1 is probably converted to 255. So, the max represented value do not change, i.e. you cannot fit brighter tones in the image. I do not know if that is what you mean when you say the range do not change?

The TIF has a potential of storing a dynamic range of 16 stops (or maybe 15, depending on how you define it). The JPEG, using sRGB, can never store that dynamic range. It is impossible. So, you might lose dynamic range.

Caveat: of course, if the original data only has e.g. 6 stops dynamic range, then all this is just theoretical pastime.

-- hide signature --

/Roland
Kalpanika X3F tools:
https://github.com/kalpanika/x3f

 Roland Karlsson's gear list:Roland Karlsson's gear list
Sigma DP3 Merrill Sigma dp2 Quattro Sony RX100 III Pentax K-3 Pentax K-1 +14 more
Andy C Knight Contributing Member • Posts: 758
My Head Hurts!

D Cox wrote:

xpatUSA wrote:

D Cox wrote:

Are you looking for a graph of "Number-of-Photons-Hitting-a-Pixel" against numbers in the file from zero to 255 ? I think this will vary according to the particular sensor and the ISO setting.

No, Don. I am looking for the reason why some people say a JPEG's dynamic range is 8 stops (by virtue of JPEG being 8-bit) and others say it is more, e.g. 11 stops.

I think because they are confused between two completely different uses of binary numbers.

The difference between a JPG file and a 16-bit TIF file is not the range but the number of steps (integers) within that range. A 16-bit file can potentially give you better gradation, but not better dynamic range.

Not trying to hijack the thread, but may I ask some more direct questions which may (or may not :-D) give some clarity to this thread...

1. What is "Dynamic range"

2. Does an 8 bit RAW file (which contains one pixel with a single integer between 0 and 255) have infinite DR, if the noise is zero? (since 255/0 is infinity??) Am I even on the right track??

I previously thought that a lossless 8 bit JPG had a max DR of 8 bits per pixel... Or am I confused with SNR or something else??

Regards

Andy.

Roland Karlsson Forum Pro • Posts: 28,248
Re: My Head Hurts!

Andy C Knight wrote:

  1. What is "Dynamic range"

Dynamic range is (often log of) the max usable valu divided with the min usable value.

  1. Does an 8 bit RAW file (which contains one pixel with a single integer between 0 and 255) have infinite DR, if the noise is zero? (since 255/0 is infinity??) Am I even on the right track??

To solve that problem, you can add 0.5 to each value. Another way of solving it is to use the definition of useful minimum signal. To have such a thing, you need to use the values 0, 1 and 2. In practice you have noise though

I previously thought that a lossless 8 bit JPG had a max DR of 8 bits per pixel... Or am I confused with SNR or something else??

Ah ... this is the kernel of the poodle!

My claim is that if you use compressed coding (as sRGB JPEG does) then the dynamic range is not the actual digital values, but what they represent decoded.

I have heard that you then get 11 bits. Ted and DM here have excelled in mathematics and done some computations that give similar or not numbers

-- hide signature --

/Roland
Kalpanika X3F tools:
https://github.com/kalpanika/x3f

 Roland Karlsson's gear list:Roland Karlsson's gear list
Sigma DP3 Merrill Sigma dp2 Quattro Sony RX100 III Pentax K-3 Pentax K-1 +14 more
Jack Hogan Veteran Member • Posts: 6,990
Re: What is the dynamic range of a JPEG image?

xpatUSA wrote:

Jack Hogan wrote:

xpatUSA wrote: What would be your calculation for a ProPhoto JPEG image where the max RGB is 240,240,240 and the min RGB is 4,4,4?

I am going to pull a quick attribute substitution while you are not looking and say that what that's going to give you is the contrast ratio of the image, as opposed to the DR of any item in the chain. Following DM's approach, where color data is reverted to linear relative luminance according to ProPhoto's gamma curve

Trying to keep up, is the linear relative luminance in units of Y as given by aR+bG+cB where a,b,c are the coefficients found in Rec. 709 etc? In which case, can I instead use Bruce's CIE calculator, converting RGB numbers (for a color space, it's illuminant and exponent) to XYZ or xyY and use those values of Y to derive what has now become 'Contrast Ratio'?

Hi Ted,

I am simplifying, but the end results are not going to be much different. If the three RGB values are the same, the coefficients used to determine the luminosity component are immaterial because they add up to 1:

0.2*100 +0.7*100 + 0.1*100 = 100.

for an 8-bit file resulting from encoding 14-bit raw data:

Contrast Ratio = 228.58 / 0.25682 = 890.

Trying to match that first number (to see if I'm following) using said BT.709 coefficients for the higher JPEG level R=G=B=240:

Y = 0.2126 R + 0.7152 G + 0.0722 B where RGB are linear and normalized to 1

Y = (0.2126x(240/255)^1.8+0.7152x(240/255)^1.8+0.0722x(240/255)^1.8)x255 = 229.74 so I'm wrong as usual. Wrong coefficients? Looks like you might have use D50 adapted . . .

Looks to me like rounding error in the numerator: (240/255)^1.8*255 = 228.6.  And the denominator is in the linear region of ProPhoto (second line below)

from https://en.wikipedia.org/wiki/ProPhoto_RGB_color_space#Encoding_Function

. . . in which case could I use Bruce's calculator but select D50 going from RGB to XYZ.

The same exercise with sRGb results in a CR of 713. The question is whether these contrast ratios can be related back to some form of a DR.

Jack

Andy C Knight Contributing Member • Posts: 758
Re: My Head Hurts!

Hi Roland, Thanks for the reply...

Roland Karlsson wrote:

Dynamic range is (often log of) the max usable valu divided with the min usable value.

Understood

  1. Does an 8 bit RAW file (which contains one pixel with a single integer between 0 and 255) have infinite DR, if the noise is zero? (since 255/0 is infinity??) Am I even on the right track??

To solve that problem, you can add 0.5 to each value. Another way of solving it is to use the definition of useful minimum signal. To have such a thing, you need to use the values 0, 1 and 2. In practice you have noise though

Again understood

I previously thought that a lossless 8 bit JPG had a max DR of 8 bits per pixel... Or am I confused with SNR or something else??

Ah ... this is the kernel of the poodle!

My claim is that if you use compressed coding (as sRGB JPEG does) then the dynamic range is not the actual digital values, but what they represent decoded.

Ah indeed! ... now (I think!) I understand.

So if took some (say) 12 bit RAW data (with insignificant noise) and applied a logarithmic curve to the intensity values prior to quantising to 8 bits... the DR of the 8 bit RAW file is increased because the minimum useful value (of 1) would now represent a lower intensity. (i.e. as opposed to just throwing away the lower 4 bits)

I have heard that you then get 11 bits. Ted and DM here have excelled in mathematics and done some computations that give similar or not numbers

Ted and DM (plus a few others of course) are pretty good at the detail - so I have no issues with leaving the math to them!

Regards

Andy.

Keyboard shortcuts:
FForum MMy threads