Analog gain formula

D

Don

Does anybody happen to know the formula used to calculate the value of
a pixel once a certain amount of Analog Gain (AG) is applied?

Example: Scan at Master AG=0. The value of a pixel is R=100, G=100,
B=100. What would be value of that pixel when at, say, Master AG=1?

I assume the same formula would apply to individual RGB channels,
right?

Don.
 
E

East75th

There isn't one. Probably because emulsions, dyes and silver, respond
differently to changes in exposure. For small changes it appears that
NikonScan can estimate and redraw without performing a full preview scan.
And this is as long as it's the same image. Otherwise it has to perform a
full exposure/preview scan.

Dane
 
E

East75th

There isn't one. Probably because emulsions, dyes and silver, respond
differently to changes in exposure. For small changes it appears that
NikonScan can estimate and redraw the preview without performing a full
preview scan. And this is as long as it's the same image. Otherwise it
has to perform a full exposure/preview scan.
 
K

Kennedy McEwen

Don said:
Does anybody happen to know the formula used to calculate the value of
a pixel once a certain amount of Analog Gain (AG) is applied?

Example: Scan at Master AG=0. The value of a pixel is R=100, G=100,
B=100. What would be value of that pixel when at, say, Master AG=1?

I assume the same formula would apply to individual RGB channels,
right?
I have a sensation of deja-vu on this question, but my ISP's news server
has been playing up recently (failing completely for the past few days)
and some messages seem to have been lost, so if I have answered it
before, the response might not have got through.

EV = Exposure Value. This is based on the photographic system where the
exposure to the film could be adjusted by changing the time the shutter
was open for or by changing the lens aperture. Increasing the lens f/#
by one stop and decreasing the shutter speed by one stop resulted in the
same amount of light reaching the film and hence the same exposure
value. This was standardised based on an EV rating of 0 for 1 second
exposure on film with a lens aperture of f/1, with each integer
increment of EV resulting in half the exposure of the previous value.

Lens f/# is approximately proportional to the aperture diameter (an
approximation which becomes increasingly inaccurate as f/# decreases
below 1) and so the area of the aperture is proportional to the square
of f/#, to the same level of approximation. Hence a lens of f/1.4 has
an aperture with half the area of an f/1 lens and consequently it
transmits half as much light. Thus 1sec exposure at f/1.4 corresponds
to EV=1, as does an f/1 lens with an exposure of 0.5sec. An f/2 lens
with 1sec exposure has EV=2, as does an f/1.4 lens with 0.5sec, and an
f/1 lens with 0.25sec and so on.

A typical fast photo lens might be f/1.4, giving an EV of 1 at the
longest typical timed exposure of 1 second. F/22 and 1/4000sec,
probably the shortest exposure available on typical good 35mm cameras,
corresponds to EV=21 (log-base2(4000)+log-base-sqrt2(22) = 12 + 9 = 21).
So the total exposure adjustment range of most 35mm cameras is around
20EV, corresponding to about a scale of 1 million to one!

There are lots of charts available to compute EV from f/# and shutter
speed on the Internet - Google on Exposure Value.

In NikonScan, the Analog Gain sliders are measured in EV and, apart from
the fact that the numbers are reversed from the standard EV definition,
operates on the same principle. Thus EV=1 in AG gives twice the
exposure to the CCD that it achieves in EV=0. EV=2, gives 4x the
exposure, EV=-1 gives 0.5x and EV=-2 gives 0.25x the exposure at the
CCD. Hence a pixel which has a value of 50 at EV=0 will have 100@EV=1 &
200@EV=2 or 25@EV-1 & 12 or 13@EV=-2. With the master analogue gain and
the three individual colours all set to EV=2, the total exposure on the
CCD, and hence the pixel value, is increased by a factor of 16x the
normal default levels.

The resulting pixel amplitude at any EV will be:
P(EV) = P(0).2^EV
where P(0) is the pixel value at EV=0
P(EV) is the value at the EV required
EV is the Exposure Value.

A more general formula is that the pixel value at a new EV will be given
by P(New) = P(Old).2^(New-Old)
where New is the new EV and Old is the original EV at which you know the
pixel value (within the limits of the quantisation accuracy of the
scanner's ADC).

However, the CCD is a very linear device and the above only corresponds
to the data output by it and subsequently digitised - ie. raw data.
Normally the data that you are looking at has undergone some overall
gamma correction to match the display characteristics, or even more
detailed colour management. So this must be taken account of when
considering the effect of analogue gain on any pixel value. The
consequence is that for highlights the EV adjustement is significantly
reduced from that expected whilst for shadows it is greater than
expected. For general gamma adjustment, the exact effect is fairly easy
to calculate using the natural logs and exponentials of the gamma used
to estimate, first, from the pixel data what the original CCD output
value was and then, from the output of the above formulae, what the
resulting pixel data of the new CCD output value will be. For a colour
managed system you need to access the detailed colour lookup tables used
in the management systems - which can become complex, especially if
colour space conversions are performed.

The easiest way of seeing the effect of the analogue gain on the actual
data itself is to conduct scans with NCM off and gamma set to unity.
This will result in very dark images, of course, but you will see the
exact effect of the analogue gain. Scan first at AG=0 and examine the
histogram of a relatively uniform crop. Note the median value of the
histogram (viewed in Photoshop without any colour management). Compare
this to the medians of scans at other EV's and you should see them
conform to the above rules, within the accuracy of the ADC in your
scanner.
 
D

Don

I have a sensation of deja-vu on this question, but my ISP's news server
has been playing up recently (failing completely for the past few days)
and some messages seem to have been lost, so if I have answered it
before, the response might not have got through.

Oh, that's why you were gone for a few days... I haven't seen any
messages from you here since... let's see... Feb 20 (there was no
response in the Histogram puzzle thread).

I assume you have the replies in your news reader so maybe you should
just repost everything from Feb 20 to catch up?
In NikonScan, the Analog Gain sliders are measured in EV and, apart from
the fact that the numbers are reversed from the standard EV definition,
operates on the same principle. Thus EV=1 in AG gives twice the
exposure to the CCD that it achieves in EV=0. EV=2, gives 4x the
exposure, EV=-1 gives 0.5x and EV=-2 gives 0.25x the exposure at the
CCD. Hence a pixel which has a value of 50 at EV=0 will have 100@EV=1 &
200@EV=2 or 25@EV-1 & 12 or 13@EV=-2. With the master analogue gain and
the three individual colours all set to EV=2, the total exposure on the
CCD, and hence the pixel value, is increased by a factor of 16x the
normal default levels.

The resulting pixel amplitude at any EV will be:
P(EV) = P(0).2^EV
where P(0) is the pixel value at EV=0
P(EV) is the value at the EV required
EV is the Exposure Value.

A more general formula is that the pixel value at a new EV will be given
by P(New) = P(Old).2^(New-Old)
where New is the new EV and Old is the original EV at which you know the
pixel value (within the limits of the quantisation accuracy of the
scanner's ADC).

That's what I expected. I know that 1 AG = 1 EV, and that +1 EV =
doubling of exposure.

So, I ran a few tests with various films and images scanning from -2
AG to +2 AG in 1 AG increments, i.e. 5 samples per test. I plotted
those values and did *not* get a confirmation of what I expected.
Instead of doubling the increase seems to settle at around 70% on
average.

One caveat: Instead of plotting each individual pixel I "reduced" each
image to a single set of RGB values (let's call it a "meta-pixel", for
a lack of a better term) by writing a program to average them out
(e.g. add up all R values and then divide by number of pixels to get
the "average" R, etc.). I'm sure you have the proper name for this...
However, the CCD is a very linear device and the above only corresponds
to the data output by it and subsequently digitised - ie. raw data.
Normally the data that you are looking at has undergone some overall
gamma correction to match the display characteristics, or even more
detailed colour management. So this must be taken account of when
considering the effect of analogue gain on any pixel value.

OK, that may account for my results.
The
consequence is that for highlights the EV adjustement is significantly
reduced from that expected whilst for shadows it is greater than
expected.

That's what I was planning to do next: Test the effect on different
areas of the available range by, for example, dividing the range into
4 sections (pixels 0-63, 64-127, etc).

Of course, that should not change the overall (average) result but I
just wanted to find out if starting value of a pixel had an effect on
its increase (or decrease) when AG is applied.
For general gamma adjustment, the exact effect is fairly easy
to calculate using the natural logs and exponentials of the gamma used
to estimate, first, from the pixel data what the original CCD output
value was and then, from the output of the above formulae, what the
resulting pixel data of the new CCD output value will be. For a colour
managed system you need to access the detailed colour lookup tables used
in the management systems - which can become complex, especially if
colour space conversions are performed.

As you probably know by now I turn everything off - except gamma which
is at 2.2 so that's probably the main reason for my results. However,
by using my "meta-pixel" method I expected the effects of gamma to be
neutralized, but I guess I was mistaken.
The easiest way of seeing the effect of the analogue gain on the actual
data itself is to conduct scans with NCM off and gamma set to unity.
This will result in very dark images, of course, but you will see the
exact effect of the analogue gain. Scan first at AG=0 and examine the
histogram of a relatively uniform crop. Note the median value of the
histogram (viewed in Photoshop without any colour management). Compare
this to the medians of scans at other EV's and you should see them
conform to the above rules, within the accuracy of the ADC in your
scanner.

OK, I'll try that later today. The added bonus is that this can be
used to test the accuracy of the ADC!!

Thanks as always, Kennedy!

Don.
 
K

Kennedy McEwen

Don said:
One caveat: Instead of plotting each individual pixel I "reduced" each
image to a single set of RGB values (let's call it a "meta-pixel", for
a lack of a better term) by writing a program to average them out
(e.g. add up all R values and then divide by number of pixels to get
the "average" R, etc.). I'm sure you have the proper name for this...
I sure do... it's called a "mistake"! :)

The problem with doing that is that it takes no account of pixels in the
image which are saturated in any of the channels and these will
inevitably skew the "meta-pixel" value. Certainly over the range of -2
to +2EV you can expect some pixels in even a fairly low contrast image
to saturate at one or more settings, so data skewing is almost
inevitable. Since you cannot guarantee that the saturation levels
(black and white) of the CCD correspond to the same saturation limits of
the ADC, you can't just simply ignore data which is 0 or 255 either.
Also, the linearity of the CCD will be degraded close to saturation
limits and it is possible for very saturated pixels to "bloom" adjacent
pixels and also to "bounce" due to the power rails in the local area
being current limited. All of which means that saturated pixels in the
image will cause problems to the calculated "meta-pixel" and cannot
simply be compensated for by eliminating them from the arithmetic.
As you probably know by now I turn everything off - except gamma which
is at 2.2 so that's probably the main reason for my results. However,
by using my "meta-pixel" method I expected the effects of gamma to be
neutralized, but I guess I was mistaken.
Even if you use linear gamma your "meta-pixel" data is unreliable since
this is effectively just the mean of the image, and will always be
skewed by the saturated pixels it is derived from. Why bother to write
a program to calculate the wrong data when you can just scan a small
relatively uniform area and get the median directly in Photoshop from
the histogram? The median is an average measure which is independent of
the saturated pixels - assuming that the median itself is not saturated
of course. Using different areas of the image you can analyse the
effect with different densities till the cows come home - and each scan
only takes a couple of seconds since it is small. ;-)
OK, I'll try that later today. The added bonus is that this can be
used to test the accuracy of the ADC!!
I can't see this performing much of a test on the ADC really - it is
pretty crude and more likely to test the accuracy of the exposure
scaling than anything else.

Anyhow, after posting the previous message last night I checked the
process step by step using my LS-40000. NCM off, gamma=1, no colour
management in Photoshop worked exactly as expected and I got the
following median data for four different sections of an image using
Master Gain control.

AG -2 -1 0 1 2
Lum 20 40 80 162 255 (saturated median)
R 17 35 70 141 255 (saturated median)
G 21 42 85 172 255 (saturated median)
B 19 38 78 157 255 (saturated median)

Lum 13 26 52 104 207
R 13 25 50 99 198
G 14 27 54 108 215
B 13 24 49 99 198

Lum 4 8 16 32 65
R 3 7 14 28 56
G 4 8 17 34 68
B 4 8 15 31 61

Lum 0(sat) 1 2 5 9
R 0(sat) 1 2 4 9
G 1 1 3 5 10
B 0(sat) 1 2 5 9

This all looks exactly as expected. I haven't looked at the exact
numbers for adjusting the individual channels, but visually they look
right too, and I have no reason to doubt that they would be any
different from expectations.
 
D

Don

I sure do... it's called a "mistake"! :)

LOL! Very good! :blush:)
The problem with doing that is that it takes no account of pixels in the
image which are saturated in any of the channels and these will
inevitably skew the "meta-pixel" value. Certainly over the range of -2
to +2EV you can expect some pixels in even a fairly low contrast image
to saturate at one or more settings, so data skewing is almost
inevitable. Since you cannot guarantee that the saturation levels
(black and white) of the CCD correspond to the same saturation limits of
the ADC, you can't just simply ignore data which is 0 or 255 either.
Also, the linearity of the CCD will be degraded close to saturation
limits and it is possible for very saturated pixels to "bloom" adjacent
pixels and also to "bounce" due to the power rails in the local area
being current limited. All of which means that saturated pixels in the
image will cause problems to the calculated "meta-pixel" and cannot
simply be compensated for by eliminating them from the arithmetic.

You're absolutely right about extreme pixels. I did notice that as
some graphs started leveling off as they got saturated. So I ignored
the extreme ends and focused on the middle part of the graph. But
that's where gamma kicked in.
Even if you use linear gamma your "meta-pixel" data is unreliable since
this is effectively just the mean of the image, and will always be
skewed by the saturated pixels it is derived from. Why bother to write
a program to calculate the wrong data when you can just scan a small
relatively uniform area and get the median directly in Photoshop from
the histogram? The median is an average measure which is independent of
the saturated pixels - assuming that the median itself is not saturated
of course. Using different areas of the image you can analyse the
effect with different densities till the cows come home - and each scan
only takes a couple of seconds since it is small. ;-)

Yes, I have the formulas for statistical calculations, but I was
trying to simplify and streamline, and a mean is easier to calculate
than the median. But, to paraphrase a common phrase, a program should
be as simple as possible but not simpler...
Anyhow, after posting the previous message last night I checked the
process step by step using my LS-40000. NCM off, gamma=1, no colour
management in Photoshop worked exactly as expected and I got the
following median data for four different sections of an image using
Master Gain control.

AG -2 -1 0 1 2
Lum 20 40 80 162 255 (saturated median)
R 17 35 70 141 255 (saturated median)
G 21 42 85 172 255 (saturated median)
B 19 38 78 157 255 (saturated median)

Lum 13 26 52 104 207
R 13 25 50 99 198
G 14 27 54 108 215
B 13 24 49 99 198

Lum 4 8 16 32 65
R 3 7 14 28 56
G 4 8 17 34 68
B 4 8 15 31 61

Lum 0(sat) 1 2 5 9
R 0(sat) 1 2 4 9
G 1 1 3 5 10
B 0(sat) 1 2 5 9

This all looks exactly as expected. I haven't looked at the exact
numbers for adjusting the individual channels, but visually they look
right too, and I have no reason to doubt that they would be any
different from expectations.

For what is worth here are my results of the same test (3 sections):

AG -2 -1 0 1 2
Lum 11 23 48 97 187
R 9 19 39 79 162
G 11 22 45 92 188
B 20 41 78 169 254 (almost saturated median)

Lum 1 2 5 11 22
R 2 4 8 17 35
G 1 1 3 7 14
B 1 3 6 13 26

Lum 0(sat) 0(sat) 0(sat) 0(sat) 1
R 0(sat) 0(sat) 0(sat) 0(sat) 0(sat)
G 0(sat) 0(sat) 0(sat) 0(sat) 1
B 0(sat) 0(sat) 0(sat) 1 2

It follows the progression as you expected, but it also shows how much
my scanner is struggling with KC. It had a very hard time saturating
the highlights but was all too eager to saturate the lowlights. The
lack of red and abundance of blue is also apparent (the mid range was
a scan of a face which accounts for it going against the trend).

However, by boosting the individual RGB channels (red most of all) and
then digital contrast masking I can get acceptable dynamic range. But
it all takes a lot of work, of course. On the minus side, I have no
choice but to push ahead; on the plus side, I learned a lot.

Don.

P.S. Still giggling about the meta-pixel "mistake"... :blush:)
 
K

Kennedy McEwen

Don said:
For what is worth here are my results of the same test (3 sections):

AG -2 -1 0 1 2
Lum 11 23 48 97 187
R 9 19 39 79 162
G 11 22 45 92 188
B 20 41 78 169 254 (almost saturated median)

Lum 1 2 5 11 22
R 2 4 8 17 35
G 1 1 3 7 14
B 1 3 6 13 26

Lum 0(sat) 0(sat) 0(sat) 0(sat) 1
R 0(sat) 0(sat) 0(sat) 0(sat) 0(sat)
G 0(sat) 0(sat) 0(sat) 0(sat) 1
B 0(sat) 0(sat) 0(sat) 1 2

It follows the progression as you expected, but it also shows how much
my scanner is struggling with KC. It had a very hard time saturating
the highlights but was all too eager to saturate the lowlights. The
lack of red and abundance of blue is also apparent (the mid range was
a scan of a face which accounts for it going against the trend).

Don,
just a thought about your whole KC issue, admittedly prompted by the
data above but not due to an apparent flaw in it.

Have you had the scanner professionally cleaned recently?

The reason for asking is that dirt and grime are known to accumulate on
the imaging optics side of the scanner and cause soft scans. I had to
dismantle my LS-20 and LS-2000 several times to clear this.

Although I never experienced a problem with it, I am sure that the same
level of grime will accumulate on the LED side too. This would not have
any effect on the image sharpness, hence you might not be aware of it,
but it certainly would limit the amount of light reaching the slide and
the CCD.

This would force the scanners autogain towards the long exposure side
just to get normally exposed images. However, if there is a hard
exposure limit (and I am sure there is, because even unexposed slide
film can be scanned in a finite time and results in a relatively dark
image) then that will reduce the scanner's ability to cope with very
dense media. Once again, I am sure that this is something that Ed
Hamrick's Vuescan will cope with using its long exposure option, but it
may indicate the need for a clean of the illumination side of the
optical path.
 
D

Don

Don,
just a thought about your whole KC issue, admittedly prompted by the
data above but not due to an apparent flaw in it.

Have you had the scanner professionally cleaned recently?

No, but I don't think that's the problem because I only unpacked the
scanner less than a year ago. All told, I probably only scanned about
500 images (mostly testing). When I don't use it for a few days I
actually put it back in the original box even going as far as putting
it in the plastic it came in! Otherwise, I keep the scanner covered
and clean each slide with a blow brush before scanning. Still, I'm
sure there is some dust inside but probably not enough to affect
performance - but I don't know this for a fact, and you may be right.


BTW, after I did the above tests and set gamma back to 2.2, the
"weird" histograms are back again (gamma artifacts) and I can't turn
them off no matter what I try (my rebooting "trick" doesn't seem to
work anymore). It's one step forward, two steps back... Aaarrghh!

Actually, I'm now past the frustration stage and starting to see the
funny side of all this... ;o)

Don.
 
K

Kennedy McEwen

Don said:
No, but I don't think that's the problem because I only unpacked the
scanner less than a year ago. All told, I probably only scanned about
500 images (mostly testing). When I don't use it for a few days I
actually put it back in the original box even going as far as putting
it in the plastic it came in!

Maybe not as good an idea as it sounds - many soft plastics give off
plasticiser vapours which have a nasty habit of condensing where you
want them least. How regularly do you have to clean the inside of your
car windscreen? That "dirt" is condensed plasticiser from the plastic
components inside the car. It is a major problem with flatbed scanners,
where the plasticiser condenses on the glass platten. Google will find
loads of complaints from people who have bought scanners that have a
dirty film on the inside of the glass - at least they can see it, on a
film scanner you can't. Then there is the lubricant from the motors and
gears etc., though with only 500 scans that shouldn't be too bad -
depending on the storage temperatures. The dirt that clogs up scanner
optics doesn't just come in from outside of the scanner, though it is
still a good idea to use a (non-plastic) dust cover when not using the
device.
 
D

Don

Maybe not as good an idea as it sounds - many soft plastics give off
plasticiser vapours which have a nasty habit of condensing where you
want them least.

If Nikon used such plastic to package their scanners then that's
another thing I can blame Nikon for... ;o)

Don.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top