CMOS/ADTG/Digic register investigation on ISO

Started by a1ex, January 10, 2014, 12:11:01 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

a1ex

Updated research tools to the latest codebase (unified) and added them to a branch on the main repository.

https://bitbucket.org/hudson/magic-lantern/pull-request/412/iso-research-tools

Audionut

Looks like the column gain registers need to be adjusted for each ISO when tweaking ADTG2 and ADTG4[0x8, 9, A, B].

Here is with the column gain registers at 0x32?




Very close to 1 full stop improvement over Canon gain at ISOs 200, 400, 800  :D


And here with the column gain registers adjusted to bring the WL back to sweet spot.




Still have lots of observing to conduct, but so far I cannot raise ISO 100 any further.

Thanks for the menu tweaks.

ItsMeLenny

Quote from: a1ex on February 22, 2014, 01:03:52 PM
We are doing the analysis only for RAW.

If you are interested in JPEG, you may be lucky, since the JPEG is created from RAW. But you'll have to do your own analysis ;)

If you can find a digital gain that affects JPEG but does not get burned in the CR2 file, it may be interesting.

Ah.

I didn't mean a separate thing, I mean the same thing that gets applied to Raw then renders the jpeg and video in camera, to get rid of the tstop at f/1.8.

naturalsound

Hi again,

I am sorry if I am again posting something stupid, but Lenny reminded me of some fact I did read about the 5D III sensor.
There was a company that used an electron microscope to examine the sensor of Canons 5D MK III.
They revealed transistors that could be used for electronic pixel binning of three adjacent image pixels. The furthermore assumed this could be used in video mode to reduce aliasing. Unfortunately I could not find a proof of this speculation. Even worse is the fact that this paper was only accessible for some hours or days. I can not find it any more.

Why do I post it here?
Wouldn't binning of three pixels improve the resulting full well capacity by a factor of three? That COULD significantly improve DR in video mode.
On the other hand it would also increase the shot noise compared to one single channel. So if three binned pixels are read with the same settings (Gain & ADC) as one single this would result in WORSE DR compared to photo mode. (Which is what you seemed to see in the beginning?) If one could now somehow adjust the settings to respect the greater full well capacity it could finally increase the video DR, wouldn't it?

Again: I assume that somebody has already investigated / tested this and did not publish his results because it did not work or the information about those transistors is wrong. But since there is a tiny chance that this has not yet been tested I thought I should give it a try.


a1ex

We didn't get this far (we focused mostly on photo mode), but the question does make sense.

stevefal

Is the FPN filter mentioned earlier something that would run in-camera, or post? If in-camera, is it possible that it could be used in video mode, even if the ISO tweaks couldn't?

Making that deep shadow noise prettier would be big plus for video, especially given that the bands crawl, in my experience.
Steve Falcon

a1ex

It's Canon's auto-calibration algorithm (you are already using it).

stevefal

Maybe I've described it wrong. I'm talking about these mentions:

Quote from: a1ex on January 17, 2014, 03:13:51 AM
On my test shot with Greg's car, it didn't remove the pattern noise and actually interpreted it as detail.

I have found a math model for this pattern noise though, and I hope to have a clean fix for it in the near future.

Quote from: a1ex on January 17, 2014, 04:41:23 AM
The banding pattern accounts for only a small part of these histogram distortions.

Proof:

ISO 100 dark frame (5D3), original and corrected


Histograms of horizontal and vertical banding correction (per-line and per-column)


Image histogram before and after correction:


How I've estimated the correction:

# estimate horizontal and vertical banding
fh = mean(im'); fh = fh - mean(fh);
fv = mean(im);  fv = fv - mean(fv);

# banding histograms
hist(fh, -3:0.1:3)
print -dpng -r60 hband.png
hist(fv, -3:0.1:3)
print -dpng -r60 vband.png

# compute the flat field
[m,n] = size(im);
ffh = fh(1:m)' * ones(1,n);
ffv = ones(m,1) * fv(1:n);
ff = ffh + ffv;

# image histogram before and after correction
hist(im(:), 2048 + (-50:50))
print -dpng -r60 hist0.png
hist(im(:) - ff(:), 2048 + (-50:50))
print -dpng -r60 hist1.png


I took that as an idea for new software to de-pattern shadow noise.
Steve Falcon

a1ex

Ah, you should have linked it from the beginning. I thought it's about today's findings.

It can run in camera, but expect around 10 seconds (maybe more) for one picture.

Audionut

An old personal goal of mine was 11.5  :)




http://lifeinmegapixels.com/blog/2012/01/pixel-binning-does-it-work/

QuoteSo while you can do pixel binning in post if you want, it doesn't particularly gain much. So is it still worth doing? Yes, when done during capture.

The key issue is overcoming the noise floor, and once the noise is present, no amount of post work with remove it. Read noise is one of the problems, which is the noise generated when the pixels are read from the sensor. If pixel binning is done on sensor, i.e the sets of pixels are combined before being read, then the read noise will be greatly reduced (one portion of noise per final pixel instead of 4/9/etc). This means that additive binning really can provide some benefit in this case by reducing that source of noise. This is performed in some point and shoot cameras where high ISO images come out with reduced resolution, but also on high end cameras such as the Phase One medium format backs with the Sensor+ setting.

stevefal

Quote from: a1ex on February 22, 2014, 05:15:33 PM
Ah, you should have linked it from the beginning. I thought it's about today's findings.

It can run in camera, but expect around 10 seconds (maybe more) for one picture.

Yeah sorry, I just read the whole thread for the first time today. I thought 'FPN' captured it.

So I assume your idea was for an post tool addition. I'm pitching the case for video. Banding is bad, but it's really bad when the bands crawl - the motion catches your eye, and you really see them.
Steve Falcon

Audionut

Quote from: stevefal on February 22, 2014, 05:27:21 PM
Banding is bad, but it's really bad when the bands crawl - the motion catches your eye, and you really see them.

Well FPN, is fixed by nature.

"Crawling" pattern noise, will be an entirely different beast to fix, afaik.

SpcCb

Quote from: naturalsound on February 22, 2014, 03:14:44 PM
(...)
Wouldn't binning of three pixels improve the resulting full well capacity by a factor of three? That COULD significantly improve DR in video mode.
(...)
This is possible if the binning is done on-ship (accumulated charge from each pixel involved in the binning is brought together and summed before the process of ADC occurs) and if the output register pixels can hold the extend charge.
If not, binning reduces the detectable amount of light per pixel, hence the FWC.

Beside, the ADC quantification have to be calibrate for this special configuration.

But in the worse case binning significantly improves the SNR, witch is very interesting by the way.

Audionut

Quote from: SpcCb on February 22, 2014, 05:34:33 PM
If not, binning reduces the detectable amount of light per pixel, hence the FWC.

White level.  It would have to be a special post processor that reduces the capacity of the pixel wells  :)

a1ex

Got some graphs.



On X, there is the raw data from ISO 100 1/200, manual lens, with no tweaks applied. Black subtracted and data converted to EV.

On Y, we have:
1) raw data from ISO 100 1/50, no tweaks applied. It's 2EV brighter (obvious).
2) ADTG gain at -2 EV, along with some other tweaks (black forced to 64, white forced to 15000, CMOS[4] patched to 0x318).
3) the tweaks from 2, plus the latest tweak discovered today (all those registers set to 0).

Source: https://bitbucket.org/hudson/magic-lantern/commits/32ef83a5ee41
Updated raw_diag binary on first post.

SpcCb

for #3 > sigma looks higher, isn't? But transition before clipping looks smoother.

a1ex

Take it with a grain of salt; the white level detection algorithm doesn't quite agree with the graphs. Time to figure out why...

edit: graph autoscaling was broken, white level was OK, re-uploaded the graphs.

Here's another one, with what I believe to be the sweet spot for both gains. First I've tuned the ADTG gain to sweet spot (which can be done with 2 test pictures, since the response curve is linear), then I've reduced the new gain until the white level started to decrease (but this one is trickier because of the nonlinearity).


a1ex

Disregard this one (poor repeatability, probably because of flicker from the light source).


Repeated the experiment with sweet spots only, no black/white level changes (so the graphs should be easier to compare) and no camera movement (the entire test sequence was ran from a script).



On X, there is the raw data from ISO 100 1/200, manual lens, with no tweaks applied (vanilla Canon settings).

On Y, we have:
1) raw data from ISO 100 1/50, no tweaks applied. It's 2EV brighter (obvious).
2) ADTG gain at sweet spot (-0.37 EV).
3) ADTG gain at sweet spot (-0.37 EV) and CMOS[4] patched to 0x318.
4) ADTG gain at sweet spot (-0.37 EV), new gain register set at 36 (default was 59, units are not yet known).
5) ADTG gain at sweet spot (-0.37 EV), new gain register set at 36, CMOS[4] patched to 0x318.

Ran the test again to check the repeatability of the results:


ISO differences, computed as median(real(log2(b)-log2(a))) from the second data set:
2.07, 1.71, 1.57, 1.51, 1.54 EV.

=> the modified ISOs (estimated from median brightness, not from clipping point) were, assumming Canon ISO 100 is really ISO 100:
ISO 100, 77.9, 70.7, 67.8 and 69.2.

The ISO 77.9 matches the theory (I've lowered ADTG gain by 0.36 stops, I've measured 0.36 stops of difference between the two pictures).

ISO differences, computed from clipping point: 2.07, 1.68, 1.44, 1.34, 1.49.

=> the modified ISOs (estimated from clipping point) were, assumming Canon ISO 100 is really ISO 100:
ISO 100, 76.3, 64.6, 60.2 and 66.8.

ISO estimation code: https://bitbucket.org/hudson/magic-lantern/commits/0c18a31891b6

Audionut

Quote from: a1ex on February 23, 2014, 09:11:55 AM
new gain register set at 36 (default was 59, units are not yet known).

My defaults.



They don't appear to vary, at least not with the lower ISOs.

a1ex

Yes, they don't vary with ISO. I've set all of them to 36 = 0x24 from iso_regs, and the first one (the one printed in iso_regs) was 59 = 0x3b.

Looks like the repeatability is much better at 1/50 vs 1/25 (probably because of artificial light flicker and maybe also mechanical flicker) => will repeat the experiment with these values.

a1ex

Did the the experiment again with 1/25 (tested image) vs 1/50 (reference image) because this improves the repeatability. ISO 100 in Canon menu.

Repeatability series 1: Canon 1/25 vs 1/50, ISO tweaking modules not loaded, camera not moved during the entire experiment.

Expo difference (EV)
median  clip
1.01    1.03
1.01    1.01
1.01    1.00
1.01    1.00
1.01    1.01




Checking register settings:

Expo difference (EV)
median  clip
1.00    0.99          # Canon 1/25 vs 1/50
0.63    0.59          # 1/25 with ADTG gain at -0.37 EV vs Canon 1/50
0.64    0.60          # 1/25 with ADTG gain at -0.37 EV and CMOS patched vs Canon 1/50
0.49    0.40          # 1/25 with ADTG gain at -0.37 EV and new gain at 36 vs Canon 1/50
0.50    0.42          # 1/25 with ADTG gain at -0.37 EV, new gain at 36 and CMOS patched vs Canon 1/50




Repeatability series 2: settings from the third tweaked set (1/25, ADTG gain -0.37 EV, new gain 36, no CMOS patch).
Camera moved intentionally between each bracket, but not moved during a bracket.

Expo difference (EV)
median  clip
0.51    0.43
0.49    0.38
0.50    0.40
0.47    0.38
0.49    0.40




Clarifications:
- CMOS patched: changed CMOS[4] from 0x718 to 0x318.
- ADTG at -0.37 EV: all ADTG gains were scaled by this value from factory gains, and this value was found to be the sweet spot (lower this gain more => white level starts to decrease).
- new gain at 36: ADTG2/4[8,9,A,B] all set to 36 from iso_regs (one of them was 59 by default). Below this level, highlights are no longer clean (they start to get vertical banding).
- ISO estimation code: https://bitbucket.org/hudson/magic-lantern/commits/0c18a31891b6
- the script for running the experiment https://bitbucket.org/hudson/magic-lantern/commits/5df6093487a6 (note: you need mini_iso, which is not yet published, but I can send you a copy on request via PM).

Conclusions:
- on 5D3 we now have a really nice ISO 66 (-0.6 stops below ISO 100).
- we also have two methods of estimating the relative ISO in raw_diag + octave.

a1ex

ISO 200 in Canon menu:

Expo difference (EV)
median  clip
1.00    1.03          # Canon 1/25 vs 1/50, ISO 200
0.58    0.59          # 1/25 with ADTG gain at -0.41 EV vs Canon 1/50
0.60    0.59          # 1/25 with ADTG gain at -0.41 EV and CMOS patched vs Canon 1/50
0.25    0.21          # 1/25 with ADTG gain at -0.41 EV and new gain at 0 vs Canon 1/50
0.24    0.20          # 1/25 with ADTG gain at -0.41 EV, new gain at 0 and CMOS patched vs Canon 1/50


=> the new ISO pulled from 200 was actually 115.

From ISO 400:

Expo difference (EV)
median  clip
1.00    1.04          # Canon 1/25 vs 1/50, ISO 400
0.57    0.58          # 1/25 with ADTG gain at -0.43 EV vs Canon 1/50
0.56    0.57          # 1/25 with ADTG gain at -0.43 EV and CMOS patched vs Canon 1/50
0.22    0.20          # 1/25 with ADTG gain at -0.43 EV and new gain at 0 vs Canon 1/50
0.22    0.21          # 1/25 with ADTG gain at -0.43 EV, new gain at 0 and CMOS patched vs Canon 1/50


=> the new ISO pulled from 400 was actually 230.

From ISO 800:

Expo difference (EV)
median  clip
0.97    1.02          # Canon 1/25 vs 1/50, ISO 800
0.55    0.56          # 1/25 with ADTG gain at -0.43 EV vs Canon 1/50
0.57    0.60          # 1/25 with ADTG gain at -0.43 EV and CMOS patched vs Canon 1/50
0.21    0.20          # 1/25 with ADTG gain at -0.43 EV and new gain at 0 vs Canon 1/50
0.20    0.21          # 1/25 with ADTG gain at -0.43 EV, new gain at 0 and CMOS patched vs Canon 1/50


=> the new ISO pulled from 800 was actually 460.

From ISO 1600:

Expo difference (EV)
median  clip
0.93    1.00          # Canon 1/25 vs 1/50, ISO 1600
0.53    0.58          # 1/25 with ADTG gain at -0.44 EV vs Canon 1/50
0.52    0.56          # 1/25 with ADTG gain at -0.44 EV and CMOS patched vs Canon 1/50
0.18    0.19          # 1/25 with ADTG gain at -0.44 EV and new gain at 0 vs Canon 1/50
0.18    0.19          # 1/25 with ADTG gain at -0.44 EV, new gain at 0 and CMOS patched vs Canon 1/50


=> the new ISO pulled from 1600 was actually 912.

From ISO 3200:

Expo difference (EV)
median  clip
0.97    0.99          # Canon 1/25 vs 1/50, ISO 3200
0.49    0.50          # 1/25 with ADTG gain at -0.49 EV vs Canon 1/50
0.50    0.51          # 1/25 with ADTG gain at -0.49 EV and CMOS patched vs Canon 1/50
0.14    0.14          # 1/25 with ADTG gain at -0.49 EV and new gain at 0 vs Canon 1/50
0.13    0.13          # 1/25 with ADTG gain at -0.49 EV, new gain at 0 and CMOS patched vs Canon 1/50

=> the new ISO pulled from 3200 was actually 1750.

From ISO 6400:

Expo difference (EV)
median  clip
0.95    1.00          # Canon 1/25 vs 1/50, ISO 6400
0.41    0.43          # 1/25 with ADTG gain at -0.55 EV vs Canon 1/50
0.43    0.49          # 1/25 with ADTG gain at -0.55 EV and CMOS patched* vs Canon 1/50
0.06    0.06          # 1/25 with ADTG gain at -0.55 EV and new gain at 0 vs Canon 1/50
0.10    0.11          # 1/25 with ADTG gain at -0.55 EV, new gain at 0 and CMOS patched* vs Canon 1/50

* CMOS[4] patched from 0x718 to 0x318 and CMOS[3] patched from 0x144 to 0x944.

=> the new ISO pulled from 6400 was actually 3333.

From 12800:

Expo difference (EV)
median  clip
0.91    1.05          # Canon 1/25 vs 1/50, ISO 12800
0.35    0.39          # 1/25 with ADTG gain at -0.58 EV vs Canon 1/50
0.36    0.40          # 1/25 with ADTG gain at -0.58 EV and CMOS patched* vs Canon 1/50
0.01    0.03          # 1/25 with ADTG gain at -0.58 EV and new gain at 0 vs Canon 1/50
0.00    0.00          # 1/25 with ADTG gain at -0.58 EV, new gain at 0 and CMOS patched* vs Canon 1/50

* CMOS[4] patched from 0x718 to 0x318 and CMOS[3] patched from 0x144 to 0x944.

=> the new ISO pulled from 12800 was actually 6400.

Graphs for these sets uploaded here: https://www.dropbox.com/sh/onppbwy44fqomxa/VlGTJBoSr4/5d3-iso-experiments

(note: the metadata from the graph itself may be incomplete; also look at the file name to know which is which)

Audionut

I'd like to understand them first  :o
Haven't had a chance to play with updated raw_diag.

What do the blue/green/red lines represent?  I find it hard to tell what is what.  I think I know what I am looking at, but could you please explain it a little more.

a1ex

Blue is blue channel, red is red channel, green is green channel. They are compared to the values from a reference shot taken with Canon settings (unmodified ISOs) and underexposed by 1 stop via shutter.

So, in the first graph (Canon 1/25 vs Canon 1/50), you see the graph exactly 1 stop above the diagonal. That's because the exposure difference between these two is exactly 1 stop.

In the subsequent graphs, you see the graph getting closer to the diagonal (that's because ISO is getting lower).

If you define ISO as "overall brightness", I estimate it from the median vertical distance between the graph and the diagonal.

If you define ISO as "clipping point" (DxO definition), I estimate the clipping point and then take the horizontal distance between the two clipping points. If that distance is 0.6 stops, it means our ISO is 1-0.6 = 0.4 stops lower. Note the overall brightness might difer a little because of nonlinearity.

When you want to know how much you can expose to the right with the new ISOs, you need to know the clipping point.

engardeknave

I enjoy just sort of watching this thread utterly without comprehension. Like a cat watching TV.