Mike Engles said:
If it is not too boring for you, I am still puzzled by the necessity for
inverse gamma, when viewing 16 bit images on a truly linear display,
apart from correcting for a not quite ideal exposure.
It seems to me that most scanners apply inverse gamma after the A/D, so
any noise is now digitised. How can inverse gamma in this instant
improve noise or the use of bits? I can see that if inverse gamma is
applied in a analogue domain, then passed through a A/D, there would be
a benefit. It would act like a noise reduction system.
Inverse gamma added to a already digitised image would just make the
noise in the darker end more visible, which is exactly what happens.
This is necessary because most images are not ideal and need further
correction, even though they have been linearised to correct for display
on a CRT.
I thought I had already explained this to your satisfaction Mike, but it
seems you aren't quite convinced yet, so lets take a different approach
and see if that helps you get the principle.
There are a lot of things in nature which can be measured in different
ways and each method produces a different transfer function. In fact,
it is so unusual for a parameter to exhibit the same characteristics
when measured by completely independent means that some people have
spent entire lives trying to find the common link between the methods.
One classic example is something as simple as mass. Isaac Newton
predicted that the gravitational force attracting two objects was a
linear function of their mass and inversely proportional to the square
of the distance between them. So to measure the mass of one object you
could just measure the attractive force towards another at a known
distance - which is effectively what you do every time you step onto the
bathroom scales and weigh yourself: you measure the attractive force
between you and the earth at a known distance from its centre.
But there is another way of determining mass - from inertia. You know
that objects with more mass require more force to get them moving,
change their direction and stop them. This is also one of Newton's
equations, in fact it is Newton's 2nd Law of Motion and defines force in
terms of mass and vice versa: force = mass times acceleration. So you
have the same two properties measured relative to each other, force and
mass, that have an exact linear relationship to each other, and again
have a means of determining mass directly by measuring the force under a
known acceleration - such as in a circular orbit or a centrifuge.
But what connects the mass derived from gravitational force measurements
to the mass derived from inertial force measurements? Why is the mass
exactly the same from both techniques? It suggests that gravity and
inertia are some manifestation of the same underlying principle - as my
old physics lecturer used to call it "the unresolved mystery of
classical mechanics".
It is easy to see why the mass works out to have the same value - in the
inertial mass the connection between force and acceleration is simply
unity because that was the definition of force, so it is measured in
Newtons. But when he came to gravitation he had to 'invent' a
relationship between mass and force and used a constant, Newtons
Gravitational Constant, so that the force and mass were in the correct
scale to each other over the distances he was concerned with, such as
between the sun, earth and moon. Yet that is a fixed constant meaning
that inertial mass and gravitational mass are perfectly linear to each
other over enormous (literally astronomic) scales. Experiments have
shown that they are linear to better than 1 part in a billion over a
range of more than 10 to the power 23. What makes gravitational mass
exactly the same as inertial mass over such huge ranges? I doubt that
even Stephen Hawking can explain it and, as I mentioned earlier, people
have spent their entire lives since Newton's time trying to do just
that.
Even in hard physics it is rare to find parameters that are perfectly
linear when measured in different ways. Temperature, for example, can
be measured in many ways, including the expansion of a gas or liquid, as
in a thermometer. Or it can be measured by the resistance of a
semiconductor, as in an electronic thermometer. Or it can be measured
by the amount of radiation emitted from a black body or numerous other
means. All of these measurement techniques only give the same
temperature over a limited range because temperature has a different
transfer function, a different non-linear curve relating it to each of
the parameters that are actually measured. For example, the expansion
of gas or liquid with temperature becomes extremely non-linear near the
phase transitions of the material, the semiconductor resistance becomes
very non-linear at low absolute temperatures and also again at high
temperatures while emitted radiation has to be corrected by a fourth
power "gamma" to give temperature.
All of this might seem to have nothing to do with the question you ask,
but it has a common underlying question. With inorganic measurements it
is unusual, to say the least, for physically unconnected measurement
techniques to give the same response between parameters. Imagine how
much less likely it is to find such a perfect match between inorganic
and biological methods. Which is where the underlying question comes
in: What is linearity? This isn't just an abstract point of little
importance. Since it is so uncommon for measurement techniques to
provide the same transfer function unless they are somehow related by an
underlying principle, it follows that any two parameters can only have a
linear relationship when measured according to certain rules - any other
measurement of the two parameters will inevitably yield a non-linear
relationship. So which is the "correct" method of measuring two
parameters to determine their mutual linearity? Convention - and it is
the need for that convention and linearity that is behind the constant
redefinition of fundamental parameters as science develops. That is why
a year is no longer 300 days, or 365 days, or 365.242 days or that a
second is no longer 1/86400th of a day - not to be more exact or precise
in scale, but to be more precise in relative terms, in linear and power
relationships with other parameters according to agreed rules for the
measurement system used.
So coming back to your original question about bits and light measured
by a scanner. We say that the scanner is a very linear device because
it produces an output that is linear according to the agreed rules of
the measurement of light in the SI, and other, systems. Within a large
range, the output voltage of the CCD is directly proportional to the
number of photons incident on the CCD pixel. That voltage is then
digitised by another fairly linear device, the analogue to digital
convertor. So the output data from the scanner is a linear function of
the light intensity.
But your eyes don't contain CCDs and ADCs, but biological light
receptors and ionic transfer of the electrical signal to your brain to
produce a sensation of brightness. It would be quite incredible if your
eyes had the same transfer function as the CCD - and we know from
precise measurements that the sensation of brightness is approximately a
logarithmic function of intensity, not a linear one at all.
So, in terms of scanners, displays and eyes, what is meant by "linear"?
We know what is meant in measurement terms, but is that what matters? As
mentioned above, those rules for measurement are only defined by
convention. If human beings were consistent in their perception then
would it not be better to define light intensity as a linear function of
the sensation of brightness perceived by them? After all, it is what
you see in the image and in the scene that matters. Of course if you
define light intensity in this way then the scanner becomes *non-linear*
- and the data produced by the ADC would *not* be equally spaced
intensity levels any longer.
And that really is what is at the crux of your question - the difference
between what you see and what your scanner measures. If you put a
perfectly linear display on the output of your scanner, the output will
look roughly the same as the original image. However, because you
perceive the light in a different way from the scanner, the discrete
light levels produced by the linear quantisation do not appear to be
linearly spaced perceptually. A gamma correction is necessary to make
them appear so. So while the gamma correction can be argued to be
making the quantisation noise worse in certain luminance ranges, such as
the shadows, it is actually making it the same throughout the range as
perceived by your eyes.