Curve fitting and read noise, FWC, gain

Depending on the camera there may or may not be Optical Black (OB) data.
Depending on the camera the data in the image area and/or OB may or may not be clipped.
(Sadly, even data with a non-zero Blacklevel can be clipped).
For clipped data I do fit the histogram to a normal distribution.
Bill, do you see systematic differences between the two G and the R and B channels when you're looking at optical black data in cameras that don't do WB prescaling like the Nikons do? If you do, it can't be wavelength dependent RN.

Jim
 
First, which curve are you fitting to the data? The one I have seen depends on 3 parameters? Or more? Where is the formula?
Hi JACS. The formula is very simple: SNR = S/N, with S the signal in DN/ADU and N total noise also in DN/ADU. S is the mean value measured by Jim in a uniform patch of, say, 400x400 pixels, N is the relative standard deviation.

The model is SNR = xf/sqrt(r^2+xf)

with f=FWC in e-, r=RN in e- and x the signal as a factor of full scale (1 being full, as shown in the x-axis of the earlier plots)
To my eyes, it looks like the second fit is also better in terms of least squares as well?

The reason least squares (L^2 norm) is commonly used is mostly because it is simple. Minimizing a quadratic functional leads to a linear system that can be solved in a fast and accurate way. Another reason, sometimes, is that the quadratic functional may have some physical meaning, like energy, for example.

You are minimizing the so called L^1 norm of the error, on a log scale. That leads to a non-linear system. Is it better - depends on what you want to do. In some applications, I think tomography is one of them, it is considered better. But that really depends on what that error signifies, and what we know about the statistical nature of the error.

Another option is to put some weight there. That weight should not depend on what we think is more important but on where we think the error of the measurements might be different. Say - we have a reason to believe that highlight measurements are more accurate - put more weight there then.
SNR varies from, say, 250 to 1. The upper portion of the SNR curve, where xf >> r^2, turns into the square root of the signal: an easy to fit straight line of known slope in log-log. The shadow portion is the critical bit, because it is not linear. But it is two orders of magnitude lower than the easy to fit straight line.

What would you suggest then?
 
However a bigger question is whether it makes sense to average the four channels at ISO 64 for the D810, especially given the fact that the red and blue data in the deep shadows appear to suffer from quantization somewhere along the chain to DN, putting some unwanted play into the fit, hence into RN and FWC estimates.
I wonder whether at base ISO the green channel should be it, period.
For your purposes (you and Jim) that probably makes sense, and it's your decision.

For my purposes I'm satisfied with combining the channels.

I'm less interested in an exact value as in how the read noise affects a normal image.
That's why I don't subtract pairs.
And that's why, for my purposes, combining channels makes sense.
I understand. But (honest question) does it though? Shouldn't random read noise be the same for all four channels at base ISO? Is it at higher ISOs? I did a quick check of the D810 at ISO400 and it appears to be (sort of). And shouldn't FWC be the same for all four channels?
For the D810 I get read noise in DN at ISO 400 of 5.396, 4.625, 4.672, 5.210 for R, Gr, Gb, and B respectively.
Getting interesting. This is what I get from Jim's subtracted/added pair data at ISO 400:

R = 3.18e-, G = 3.18e-, B = 3.12e-, sensorgen.info = 3.7e-

The fits are not bad using the log (not squared) estimator

D810 green channel at ISO 400
D810 green channel at ISO 400

D810 red channel at ISO 400
D810 red channel at ISO 400

D810 blue chanel at ISO 400
D810 blue chanel at ISO 400

My guess is that the x-axis is incorrect in the red and blue case (i.e. zero is not correct), therefore resulting in an incorrect clipping/FWC (blue and red about 10% lower than green). If the fit is accurate read noise should be correct independently of FWC, though. You almost want to shift the red and blue curves a little to the left...
 
Last edited:
First, which curve are you fitting to the data? The one I have seen depends on 3 parameters? Or more? Where is the formula?
Hi JACS. The formula is very simple: SNR = S/N, with S the signal in DN/ADU and N total noise also in DN/ADU. S is the mean value measured by Jim in a uniform patch of, say, 400x400 pixels, N is the relative standard deviation.

The model is SNR = xf/sqrt(r^2+xf)

with f=FWC in e-, r=RN in e- and x the signal as a factor of full scale (1 being full, as shown in the x-axis of the earlier plots)
So no non-uniformity noise?

formula taken from sensorgen

formula taken from sensorgen
To my eyes, it looks like the second fit is also better in terms of least squares as well?

The reason least squares (L^2 norm) is commonly used is mostly because it is simple. Minimizing a quadratic functional leads to a linear system that can be solved in a fast and accurate way. Another reason, sometimes, is that the quadratic functional may have some physical meaning, like energy, for example.

You are minimizing the so called L^1 norm of the error, on a log scale. That leads to a non-linear system. Is it better - depends on what you want to do. In some applications, I think tomography is one of them, it is considered better. But that really depends on what that error signifies, and what we know about the statistical nature of the error.

Another option is to put some weight there. That weight should not depend on what we think is more important but on where we think the error of the measurements might be different. Say - we have a reason to believe that highlight measurements are more accurate - put more weight there then.
SNR varies from, say, 250 to 1. The upper portion of the SNR curve, where xf >> r^2, turns into the square root of the signal: an easy to fit straight line of known slope in log-log. The shadow portion is the critical bit, because it is not linear. But it is two orders of magnitude lower than the easy to fit straight line.

What would you suggest then?
I do not know where the noise and the uncertainty of the measurements is worse. If you are fairly sure that the measurements in the shadows is "accurate enough", choose that optimization which matches it better for the purpose of estimating the read noise. For estimating the FWC, you should be more worried about a better fit away from the shadows. Finding the right functional to minimize is art combined with intelligent guesses.

A more careful analysis would include an estimate of the stability - how the estimates of the parameters depend on small errors, etc.

Still, don't you get a better least square fit as well? That would be weird.
 
Last edited:
I hesitate to bring this up because I don't feel like ripping all the code apart right now, but we could use the high mu values to compute FWC, and the low mu values to compute RN, and do one-dimensional optimization for both in single ISO mode instead of two-dimensional optimization. In all-ISO mode, we could do one dimensional optimization for FWC and two dimensional optimization for preAmp RN and postAmp Rn, instead of three-dimensional optimization.

Please say you hate this idea.
I hate this idea because I would like the world to work perfectly according to our simple theories - which assume that read noise and shot noise (and pattern/PRNU which we are ignoring for now) add in quadrature and there are no other types of noise (pattern or quantization) present.

The simple model seems to work very well with data from image pairs (I am impressed) except at low ISOs where we get ringing in the shadows (especially red and blue which typically get less light) in ultra-clean sensors. The ringing is WAY off the model so no fitting criterion is going to work unless we can model what's causing it. I still haven't fully understood the mechanism of the ringing, let alone figure out how to do model it.

So if one wanted this level of accuracy (does one? Not necessarily) then one option would be to test for heavy deviations from the model in the shadows and in that case rely on the LSE criterion which biases for the highlights. If the shadows look well behaved, stick with the log minimization criterion which fine tunes things all along the curve. With this strategy the more and the deeper the data points in the shadows the better, so no more throwing away points with SNR<2.

Just thinking aloud.
 
The model is SNR = xf/sqrt(r^2+xf)

with f=FWC in e-, r=RN in e- and x the signal as a factor of full scale (1 being full, as shown in the x-axis of the earlier plots)
So no non-uniformity noise?
No, assuming un-truncated data, by subtracting image pairs you should pretty well be left mainly with random noise, minimizing (therefore ignoring here) most sorts of pattern noise including PRNU. Divide the standard deviation resulting from the subtraction by sqrt(2) and you have the denominator. The numerator is simply the mean value before subtraction.
SNR varies from, say, 250 to 1. The upper portion of the SNR curve, where xf >> r^2, turns into the square root of the signal: an easy to fit straight line of known slope in log-log. The shadow portion is the critical bit, because it is not linear. But it is two orders of magnitude lower than the easy to fit straight line.
What would you suggest then?
I do not know where the noise and the uncertainty of the measurements is worse. If you are fairly sure that the measurements in the shadows is "accurate enough", choose that optimization which matches it better for the purpose of estimating the read noise. For estimating the FWC, you should be more worried about a better fit away from the shadows. Finding the right functional to minimize is art combined with intelligent guesses.

A more careful analysis would include an estimate of the stability - how the estimates of the parameters depend on small errors, etc.
Right. And I think as long as there is no 'quantization' ringing it works pretty well. It's when there is some ringing that it bends the curve in the shadows and shifts the straight line in the highlights the wrong way.
Still, don't you get a better least square fit as well? That would be weird.
More often than not LSE seems to me to be less appropriate than the proposed alternative. I am going to look into Jim's suggestion of difference of logs squared.
 
Last edited:
FWIW, for the same reasons state above I don't think FWC is FWC; I think it's a function of wavelength.
Oh, my (again).
I will soon have two a7II's, one modified for IR and one not. That should allow a test of your thought.
I wouldn't expect any difference.
The IR conversion is mechanical, right?
So it won't change the per channel conversion gain values.

(Still an interesting test)

Regards,
 
Depending on the camera there may or may not be Optical Black (OB) data.
Depending on the camera the data in the image area and/or OB may or may not be clipped.
(Sadly, even data with a non-zero Blacklevel can be clipped).
For clipped data I do fit the histogram to a normal distribution.
Bill, do you see systematic differences between the two G and the R and B channels when you're looking at optical black data in cameras that don't do WB prescaling like the Nikons do? If you do, it can't be wavelength dependent RN.
As I said earlier, I'm not sure it's WB prescaling, it could be QE normalization.
Perhaps it's peculiar to Nikon. I haven't done a study across brands.

Since I don't separate my Optical Black (OB) data by channel I can't tell you for sure.
(I do separate it in an outdated way that would be a pain to change at this point.)

Regards,

--
Bill (visit me at http://home.comcast.net/~NikonD70/ )
 
Last edited:
Thinking aloud here Jim, the log error difference is mostly a very small number, less than one. Squaring it will will make it even smaller. Will the squaring then penalize potentially bigger outlier errors, in the overall sum? What about a square root?
Jack, I don't think the world turns upside down when the numbers get below 1. Let's compare log errors of say, 0.1 and 0.01. Their squares are 0.01 and 0.0001. The larger error contributes 100 times as much to the sum as the smaller one. Now consider errors of 100 and 10. Their squares are 10000 and 100. The larger error contributes 100 times as much to the sum as the smaller one.

Jim
 
I wouldn't expect any difference.
The IR conversion is mechanical, right?
Yes. Out with the IR-blocking hot mirror, in with the visible blocking part.
So it won't change the per channel conversion gain values.
But it does change the average wavelength of the light at each photosite. I thought you said that FWC probably varied with wavelength.

Jim
 
I hesitate to bring this up because I don't feel like ripping all the code apart right now, but we could use the high mu values to compute FWC, and the low mu values to compute RN, and do one-dimensional optimization for both in single ISO mode instead of two-dimensional optimization. In all-ISO mode, we could do one dimensional optimization for FWC and two dimensional optimization for preAmp RN and postAmp Rn, instead of three-dimensional optimization.

Please say you hate this idea.
I hate this idea because I would like the world to work perfectly according to our simple theories - which assume that read noise and shot noise (and pattern/PRNU which we are ignoring for now) add in quadrature and there are no other types of noise (pattern or quantization) present.

The simple model seems to work very well with data from image pairs (I am impressed) except at low ISOs where we get ringing in the shadows (especially red and blue which typically get less light) in ultra-clean sensors. The ringing is WAY off the model so no fitting criterion is going to work unless we can model what's causing it. I still haven't fully understood the mechanism of the ringing, let alone figure out how to do model it.

So if one wanted this level of accuracy (does one? Not necessarily) then one option would be to test for heavy deviations from the model in the shadows and in that case rely on the LSE criterion which biases for the highlights. If the shadows look well behaved, stick with the log minimization criterion which fine tunes things all along the curve. With this strategy the more and the deeper the data points in the shadows the better, so no more throwing away points with SNR<2.

Just thinking aloud.
This all begs for testing with the camera simulator that is built into the Matlab program. I had actually forgotten about it, it's been so long since we used it. I'm trying to fire it up but I seem to have broken it. Give me a little time. It'll be interesting to see if there are ripples when we use the camera simulator. Mebbe not; there is no dc offset in the simulator as it's currently written, and I don't want to add that until I'm confident it's working OK.

Jim
 
See here


and here under "Weighted least squares"


If the estimated function is actually fully appropriate for the data, heteroscedasticity just implies that ordinary least squares (OLS) is inefficient. But if such is not the case, it may have a systematic impact on the parameter estimates as well.
 
I wouldn't expect any difference.
The IR conversion is mechanical, right?
Yes. Out with the IR-blocking hot mirror, in with the visible blocking part.
So it won't change the per channel conversion gain values.
But it does change the average wavelength of the light at each photosite. I thought you said that FWC probably varied with wavelength.
I think FWC varies between the channels, R, B, Gr & Gb due to QE compensation built in to the conversion gains used and programmed into the firmware.
So I don't expect IR conversion would change anything there.

I think I'll contact someone I know with hacked firmware to see if they will do a test for me.

Regards,
 
bclaff wrote: I think FWC varies between the channels, R, B, Gr & Gb due to QE compensation built in to the conversion gains used and programmed into the firmware.
As you saw in my isolated test at ISO400 from Jim's data, read noise estimated from SNR does appear to converge when ringing is not present, as expected. The reason is that SNR does not require knowing gain (hence WB pre-conditioning), and it does not care about QE because photoelectron generation follows poisson statistics: a lower effective QE is equivalent to a lower signal, which will simply result in a proportionately lower point on the SNR plot. In theory the fitted curve should not be affected.

I have often wondered why Nikon does WB pre-conditioning: the image needs to be white balanced anyways. I would venture that the differences you see in read noise raw levels (DN/ADU) are due to what is called WB pre-conditioning as you hinted earlier (whatever its cause, QE or other): for instance, assuming no ringing,
For the D810 I get read noise in DN at ISO 400 of 5.396, 4.625, 4.672, 5.210 for R, Gr, Gb, and B respectively.
would indicate to me that red has an additional 'gain' of 1.16 and blue of 1.12, which happen to be the order of error that I see in the relative saturation count ('FWC'). For instance for the D810 graphs above at ISO400 FWC R=10824e-, G=12560e- and B=10630e-**, subtending an additional 'gain' of 1.16 for red and 1.18 for blue. Why would there be such an additional 'gain'? FWCs should all be the same, as Jim exclaimed right after we first saw these results. Photon transfer is photon transfer, and a physical pixel is a pixel, no matter what color filter it is sitting under.

I am thinking that the reason is that I am holding crossed fingers behind my back when suggesting that we do not need 'gain' to model SNR this way:

SNR = S / N = xf / sqrt(r^2+xf)

with f = FWC in e- and r = RN in e-. x is the signal, normalized to full scale, with 1 a full scale signal and zero no signal. True, when measuring the mean (S) and standard deviation (N) in DN during testing, 'gain' is present both in the numerator and the denominator so it cancels out, taking it out of the equation, allowing us to read off of it values for f and r directly in units of e-.

But where does x=1 come from when collecting statistics in DN? It comes from the raw level at which the green channel clips at the given ISO, for the D810 at base ISO 16383-600=15783 DN. That works well as long as that is indeed the raw value at which the channel saturates, true enough for the green channel which typically saturates first.

What if instead we arbitrarily decreed that the saturation point, hence the normalizing factor, were 16% lower in DN? The normalized signal (x-axis in the earlier graphs) would shift to the left with respect to the fitted curve, reducing the value of the y-axis intercept (FWC). This is what I believe is happening to the red and blue FWCs as a result of WB pre-conditioning - as I assume Jim normalizes the signals from all channels by dividing them by the very same saturation/clipping value in DN. While that works for green, it's not true for red and blue in the presence of some relative pre-conditioning 'gain'. Meaning that if they were not scaled they would saturate at, say, a 16% or so higher signal at ISO 400.

Therefore, to get the 'proper' FWC (which I think, as Jim suggested, should be about equal for all channels) one should use different signal normalization factors in DN, corrected for the WB pre-conditioning 'gain'. Or one could simply say that if one did that in the end FWCs and RNs should all come out the same anyways, hence hold the green channel values as representative for the others as well - especially given the fact that the green channels get more signal for a given exposure (higher effective QE), hence less ringing, hence they provide more accurate estimates.

I am still wrapping my head around this and look forward to everybody's thoughts.

Jack

** You can see in the earlier graphs that the log (not squared) fit appears to be slightly underestimating FWC, but the differences are no more than 3% when using LSE, which tends to nail the highlights at the expense of bigger errors in the shadows.

*** Read noise should be unaffected by this error in channel signal normalization because it only requires relative signal to do its magic, absolute signal values are not necessary.
 
Last edited:
See here

http://en.wikipedia.org/wiki/Heteroscedasticity

and here under "Weighted least squares"

http://en.wikipedia.org/wiki/Least_squares

If the estimated function is actually fully appropriate for the data, heteroscedasticity just implies that ordinary least squares (OLS) is inefficient. But if such is not the case, it may have a systematic impact on the parameter estimates as well.
Thank you Anders. What method would you suggest for this kind of estimation?
 
See here

http://en.wikipedia.org/wiki/Heteroscedasticity

and here under "Weighted least squares"

http://en.wikipedia.org/wiki/Least_squares

If the estimated function is actually fully appropriate for the data, heteroscedasticity just implies that ordinary least squares (OLS) is inefficient. But if such is not the case, it may have a systematic impact on the parameter estimates as well.
Thank you Anders. What method would you suggest for this kind of estimation?
I haven't thought enough about your particular problem to know what I'd try first in that specific case. But the standard solutions to heteroscedasticity are those listed under "Fixes" in the first of the two links I gave you. Essentially, the choice is between transforming the models/variables so as to make the disturbances reasonably homoscedastic (the first two points under "fixes") or apply some form of WLS (weighted least squares). As indicated, the fourth point listed under "fixes" isn't a full solution since the fitted function would be the same as with OLS. It only gives you a better idea of standard errors of the parameter estimates.
 
Jack,

Probably not important; just my thoughts.

1) It's generally referred to as White Balance (WB) preconditioning, probably because R and B are adjusted relative to Gr & Gb; but I don't recall any proof that this is the reason for the scaling (perhaps someone has a reference?).
So my Quantum Efficiency (QE) normalization idea seems just as valid (more so to me).

2) You may be right about Full Well Count (FWC) being identical across channels (R, B, Gr & Gb) but I'm simply challenging this as an assumption. I would love it if someone more knowledgeable would jump in.
2a) We know it's a potential well not a physical well. But does it hold electrons of different energies with the same efficiency?
2b) Is charge converted to voltage with the same efficiency for different energies of electrons.

Regards,
 
Jack,

Probably not important; just my thoughts.

1) It's generally referred to as White Balance (WB) preconditioning, probably because R and B are adjusted relative to Gr & Gb; but I don't recall any proof that this is the reason for the scaling (perhaps someone has a reference?).
So my Quantum Efficiency (QE) normalization idea seems just as valid (more so to me).
Right.
2) You may be right about Full Well Count (FWC) being identical across channels (R, B, Gr & Gb) but I'm simply challenging this as an assumption. I would love it if someone more knowledgeable would jump in.
Me too. Mine is not an assumption: I am challenging a current assumption (that FWCs from different channels should be averaged) with a different hypothesis :-)
2a) We know it's a potential well not a physical well. But does it hold electrons of different energies with the same efficiency?

2b) Is charge converted to voltage with the same efficiency for different energies of electrons.
I am no expert, but as far as I understand from Janesick (p. 38) and from a thread here a while back, for photons in the visual range allowed through by the filters to silicon, 1 converted photon = 1 valence electron of charge q, independently of the original photon energy. Happy to learn otherwise if that should not be the case.

Jack
 

Keyboard shortcuts

Back
Top