Averaging multiple scans

  • Thread starter Thread starter Don
  • Start date Start date
D

Don

I have a scanner without multiscanning, so I have to do it manually.
The problem is how do I eliminate extreme values when averaging?

Let's say 4 scans result in following values for a point: 123, 125,
127 and 250. Obviously, 250 is a fluke and this spike should be
eliminated before averaging out the first three values.

Question: How do I do this in Photoshop 6? Layering the 4 images with
opacity of 50%, 33% & 25% would include the extreme value.

Thanks!

Don.
 
Don said:
I have a scanner without multiscanning, so I have to do it manually.
The problem is how do I eliminate extreme values when averaging?

Let's say 4 scans result in following values for a point: 123, 125,
127 and 250. Obviously, 250 is a fluke and this spike should be
eliminated before averaging out the first three values.

Question: How do I do this in Photoshop 6? Layering the 4 images with
opacity of 50%, 33% & 25% would include the extreme value.

Thanks!

Don.

But when do you decide that an outlier should be excluded? This is by no
means straightforward, even if you are going to make a personal
judgement on every set of observations. And if you scan an A4 sheet at
600 pixels per inch you are going to have to make 35 million decisions.
I suspect the best way of doing this is to do a simple average. At least
then any pixels which might have resulted in extreme values would then
be moderated, in the above example to a value of 156.

You might get a better answer to this problem by asking a statistician.

Mark Atherton
 
Don said:
I have a scanner without multiscanning, so I have to do it manually.
The problem is how do I eliminate extreme values when averaging?

Let's say 4 scans result in following values for a point: 123, 125,
127 and 250. Obviously, 250 is a fluke and this spike should be
eliminated before averaging out the first three values.

Question: How do I do this in Photoshop 6? Layering the 4 images with
opacity of 50%, 33% & 25% would include the extreme value.
Don,
I am sure you won't be surprised by this but, "been there, done that,
doesn't work" - at least not well enough with the scanner you are using.
;-)

Multiscanning was the main reason I upgraded from the LS-20 (very
similar to your scanner) to the LS-2000. When I bought the LS-20 I
mistakenly believed that this would be a doddle to implement myself and
that it was just a marketing ploy by Nikon to encourage folk with less
programming skills to buy the more expensive scanners - a bit like your
current train of thought - I was wrong then, just as you are now. :-(

Really, the only way that you can remove outliers is to write a
programme yourself - after all, only you know what your criteria for an
outlier is. Yes, you could analyse the scanner data but, lets face it,
life is just too short to consider multiscanning by more than 16x, and
that is just too small a sample to get an accurate measure of the
standard deviation of each element in the CCD of your particular
scanner. Added to which, this will change as a function of temperature
in any case, so the criteria you set now will have little relevance come
August.

The weightings that you suggest are completely the wrong way to go about
it, since the noise present in the highest weighting will dominate your
results - recall that noise adds in quadrature, so the 33% image will
only contribute 43% of the first term in the noise integral, with
subsequent layers adding even less. The noise reduction of an IIR
filter (which is effectively what you are setting up in the time domain,
is given by 1/sqrt(2K-1), where K is the scaling factor of subsequent
terms in the IIR filter. Your suggested parameters of 50%, 30% and 25%
approximate (very coarsely) to a K factor of sqrt(2) and, even if
continued to infinity (well, 16x integration which would give 8bpc
limits) would only result in an SNR reduction of some 26% - and that is
the theory, so it includes a mechanism for removing outliers! Do you
really think this is worth the effort doing it this way?

Added to which, Photoshop will only layer with 8bpc data - so you are
introducing more quantisation noise than you will ever recover through
multiscanning!

You really need to write a specific program to implement this, weighting
each scan equally an d removing any outliers against a very coarse
criteria - or use an application which has already done it properly,
such as Vuescan.

After all of that, you will find that multipass multiscanning simply
does not work as well as single pass multiscanning in any case. When I
tried to implement it with a scanner such as yours, I found that the
main obstacle was scanner precision - it was not possible to align the
entire frame perfectly on each pass such that multiscanning could be
achieved without significant resolution loss. The tradeoff, is to
weight the terms of the integral, as you have, thus retaining the
resolution of the first scan - but that limits the SNR improvement much
more dramatically than the loss in spatial resolution with equal
weighting! An adaptive approach is optimal, rejecting local scan
information which differs from the primary scan above a set level,
whether that is due to noise or image content - but the end result
cannot be greater than the theory predicts, and once rejections are
included, the performance gains of the theory plummet.

The only solution I could think of - and I discussed this with Ed
Hamrick at the time, though he had other priorities - was to implement
some form of feature extraction such that each frame could be resampled
to correlate well with subsequent frames, permitting the full noise
reduction benefit of equal weighting to be obtained. However resampling
means a loss of resolution as well, so that has to be taken into account
too. Having gone into the mathematics of all this, it isn't too
surprising that the limits of what can be achieved, in a general type of
SNR-Resolution product assessment, are not much more than the overall
25% advantage that comes from the weighting approach. Of course the
value you get heavily depends on the stability of the scanner between
subsequent passes over the same image - in the case of the LS-20 it was
barely within 2 pixels across the entire field, although I would hope
the mechanism change on the LS-30 improved that a little. With perfect
alignment then you could get close to the single pass multiscanning
performance, but I don't know of any scanners that even approach that -
even a second pass for the IR capture causes problems with ICE on some
otherwise high performance film scanners that require it!

If you want to see what multiscanning can actually offer you, download a
copy of Vuescan and try the demo version. Unlike most shareware, it is
not limited in capability - it just puts a watermark on the resulting
image so yo cannot use it for real, which means you can evaluate all of
its capabilities before buying it. Despite the fact that I don't use
this package myself, it is not without significance that this is not the
first time I have recommended it to you!
 
....
But when do you decide that an outlier should be excluded? This is by no
means straightforward, even if you are going to make a personal
judgement on every set of observations. And if you scan an A4 sheet at
600 pixels per inch you are going to have to make 35 million decisions.
I suspect the best way of doing this is to do a simple average. At least
then any pixels which might have resulted in extreme values would then
be moderated, in the above example to a value of 156.

You might get a better answer to this problem by asking a statistician.

They came up with what is known as a "trimmed mean" which is what I
described above.

It's a blunt tool, but the idea was to limit the number of scans and
save time by doing more intelligent averaging.

But the question hanging in the air always was whether this was worth
the effort considering how labor intensive all this is in return for
only a marginal improvement.

Don.
 
Don,
I am sure you won't be surprised by this but, "been there, done that,
doesn't work" - at least not well enough with the scanner you are using.
;-)

I had a sneaky suspicion... ;-)
The weightings that you suggest are completely the wrong way to go about
it, since the noise present in the highest weighting will dominate your
results - recall that noise adds in quadrature, so the 33% image will
only contribute 43% of the first term in the noise integral, with
subsequent layers adding even less. The noise reduction of an IIR
filter (which is effectively what you are setting up in the time domain,
is given by 1/sqrt(2K-1), where K is the scaling factor of subsequent
terms in the IIR filter. Your suggested parameters of 50%, 30% and 25%
approximate (very coarsely) to a K factor of sqrt(2) and, even if
continued to infinity (well, 16x integration which would give 8bpc
limits) would only result in an SNR reduction of some 26% - and that is
the theory, so it includes a mechanism for removing outliers! Do you
really think this is worth the effort doing it this way?

50%, 33%, 25% , etc. is simply a way of calculating mean values using
PS. The first problem, of course, is that PS uses integer arithmetic.
However, what I did fail to take into account is that noise adds in
quadrature. Still, given enough samples that should level off but then
it defies the purpose of doing it in the first place. After all, the
main reason I asked about smart averaging is exactly to limit the
number of scans without loss of quality.
After all of that, you will find that multipass multiscanning simply
does not work as well as single pass multiscanning in any case. When I
tried to implement it with a scanner such as yours, I found that the
main obstacle was scanner precision - it was not possible to align the
entire frame perfectly on each pass such that multiscanning could be
achieved without significant resolution loss.

I found that scanner precision was pretty good as long as the slide is
not removed between scans. Certainly considerably better than my
flatbed scanner.

One "advantage" of slight inaccuracies is that it acts as a mild
Gaussian blur "automatically" removing grain. Granted, this is
haphazard and a much better method is to apply Gaussian blur directly
and have control over it.
An adaptive approach is optimal, rejecting local scan
information which differs from the primary scan above a set level,
whether that is due to noise or image content - but the end result
cannot be greater than the theory predicts, and once rejections are
included, the performance gains of the theory plummet.

That's what I suspected all along, not to mention that the amount of
effort is not reciprocal to, at best, only marginal improvement.
If you want to see what multiscanning can actually offer you, download a
copy of Vuescan and try the demo version. Unlike most shareware, it is
not limited in capability - it just puts a watermark on the resulting
image so yo cannot use it for real, which means you can evaluate all of
its capabilities before buying it. Despite the fact that I don't use
this package myself, it is not without significance that this is not the
first time I have recommended it to you!

Yes, I did try Vuescan's multiscanning a long time ago but was not
impressed with the result (nothing to do with Vuescan). I expected a
true multiscan but, if I recall correctly, it was still multipass.

Also, as I mentioned earlier I'm not a big fan of Vuescan's user
interface. Even forgetting the lag in reacting to parameter changes
and the subsequent distracting multiple screen redraw, I can't escape
the feeling that it does all sorts of things "under the hood" without
telling me. And, for me, the absolutely most important aspect of any
software is to (not only tell all it does but) let me turn things off!

Again, this is no slur on Vuescan, just one person's
opinion/preference/taste. So, all you many Vuescan fans out there,
stand down your flame throwers... ;o)

Don.
 
Don said:
On Fri, 27 Feb 2004 23:58:23 +0000, Mark Atherton


They came up with what is known as a "trimmed mean" which
is what I described above.

You could also look into this
http://homepages.inf.ed.ac.uk/rbf/HIPR2/csmooth.htm#2 approach, should you
wish to explore it further and it could also be expanded to layer
differences.
Perhaps a simple 8-bpc Filter Factory (one of the Goodies on the Photoshop
CDROM) effort could be employed to take out most of the tedious work without
having to leave Photoshop.

Bart
 
Don said:
50%, 33%, 25% , etc. is simply a way of calculating mean values using
PS.

But it doesn't calculate the mean - it calculates a weighted average.
The layer at 50% contributes 50% more to the image than the layer at 33%
and 100% more than the layer at 25%. Even so, the sum of all the layers
should add to 100% or else you produce an overall gain in contrast.
The first problem, of course, is that PS uses integer arithmetic.

Provided that you perform your level adjustments first, then that isn't
a significant problem - after all, you only need an integer result. More
significant is the limitation that this layer arithmetic can only be
implemented with 8bpc layers, which rapidly runs out of precision when
you add any layers at small weightings to get the 100% total.
However, what I did fail to take into account is that noise adds in
quadrature. Still, given enough samples that should level off but then
it defies the purpose of doing it in the first place.

It does indeed, but the noise reduction of a weighted average levels off
much faster - to almost zero in only a few terms. With an infinite
number of terms it converges on the formula I gave in the last posting
which, with your weightings, results in a total noise reduction of only
25%. With equal weightings to all scans, the noise reduces as a
function of the square root of the total number of scans - benefit of
additional scans still flattens off, but it never falls to zero. Thus,
with equal weighting two scans results noise being reduced by a factor
of 1.414x (already better than your weightings extended to an infinite
number of scans), 4 scans give a factor of 2 improvement, 8 a factor of
2.818, 16 a factor of 4, 32 a factor of 5.636 etc. - you might recognise
approximations to these numbers from a related field, it is no
coincidence. ;-)

With an infinite amount of time you can add an infinite number of scans
with equal weighting and achieve complete elimination of noise - in
theory. In practice, it reaches a fixed limit in a very finite amount
of time because that theory assumes that the noise is completely random,
ie. it has a white temporal spectrum. However, the real noise spectrum
of the CCD (and the LED, the analogue electronics, the ADC etc.)
contains a 1/f^n component, where f is the inverse of the total time
taken by all scans, and n is a number ranging from 0 to 2, hopefully
closer to 0 than 2! Once you hit this 1/f knee (where the 1/f noise is
equal to the white noise) then the advantage of adding further scans
falls much more rapidly than white noise theory predicts, quickly
reaching zero. Regular recalibration, as performed to correct CCD
non-uniformity which is simply a spatial manifestation of the
uncorrelated 1/f noise on each CCD element, can contain the 1/f noise in
your noise averaging process, however that only buys a small advantage
since the next limit is the precision that the calibration is performed
to - determined by the number of samples used in that computation and
the precision. There are ways around this, but they require access to
the scanner internals, which are not available to you.
After all, the
main reason I asked about smart averaging is exactly to limit the
number of scans without loss of quality.
Meanwhile throwing the baby out with the bathwater. ;-)

Stick with equal weightings, *then* look at removing outliers, and
hopefully you will get close to the theoretical white noise integral
with the small number of terms you are likely to use.
 
Don said:
I had a sneaky suspicion... ;-)


50%, 33%, 25% , etc. is simply a way of calculating mean values using
PS. The first problem, of course, is that PS uses integer arithmetic.
However, what I did fail to take into account is that noise adds in
quadrature. Still, given enough samples that should level off but then
it defies the purpose of doing it in the first place. After all, the
main reason I asked about smart averaging is exactly to limit the
number of scans without loss of quality.


I found that scanner precision was pretty good as long as the slide is
not removed between scans. Certainly considerably better than my
flatbed scanner.

One "advantage" of slight inaccuracies is that it acts as a mild
Gaussian blur "automatically" removing grain. Granted, this is
haphazard and a much better method is to apply Gaussian blur directly
and have control over it.


That's what I suspected all along, not to mention that the amount of
effort is not reciprocal to, at best, only marginal improvement.


Yes, I did try Vuescan's multiscanning a long time ago but was not
impressed with the result (nothing to do with Vuescan). I expected a
true multiscan but, if I recall correctly, it was still multipass.

Also, as I mentioned earlier I'm not a big fan of Vuescan's user
interface. Even forgetting the lag in reacting to parameter changes
and the subsequent distracting multiple screen redraw, I can't escape
the feeling that it does all sorts of things "under the hood" without
telling me. And, for me, the absolutely most important aspect of any
software is to (not only tell all it does but) let me turn things off!

Again, this is no slur on Vuescan, just one person's
opinion/preference/taste. So, all you many Vuescan fans out there,
stand down your flame throwers... ;o)

Don.


Hello

If you are interested and have Photoshop 6 or greater I have a Multiscan
PSD. It is zipped and 8mb and had 8 layers. I scanned it with a LS 30 a
few years back. I also have a huge 16 layer file which is nearly 300Mb.
I can psot a portion of that.

http://www.btinternet.com/~mike.engles/mike/samurai.zip

Mike Engles
 
You could also look into this
http://homepages.inf.ed.ac.uk/rbf/HIPR2/csmooth.htm#2 approach, should you
wish to explore it further and it could also be expanded to layer
differences.

Will do!
Perhaps a simple 8-bpc Filter Factory (one of the Goodies on the Photoshop
CDROM) effort could be employed to take out most of the tedious work without
having to leave Photoshop.

I installed everything so it's probably already there. Will check when
I get offline.

Thanks Bart!

Don.
 
But it doesn't calculate the mean - it calculates a weighted average.
The layer at 50% contributes 50% more to the image than the layer at 33%
and 100% more than the layer at 25%. Even so, the sum of all the layers
should add to 100% or else you produce an overall gain in contrast.

I don't think that's right. When I figured out these numbers I created
a 4-layer image and filled them with red, green, blue and white. My
instinct was to use 25% opacity on all layers, following exactly your
way of thinking, and expecting that each layer would then contribute
25% to the image resulting in medium gray (128, 128, 128) - i.e.
arithmetic mean. But apparently that's not how PS works. Instead, the
resulting color turns out to be: R=132, G=146, B=163 presumably
because PS works its way up one layer at a time, or whatever.

However, when I set opacities to 100%, 50%, 33% and 25% the resulting
color is indeed arithmetic mean: R=128, G=128, B=127 which is roughly
what I would expect considering PS uses integer arithmetic.

In other words (best viewed with a proportional font):
Layer R G B % Result Layers
4 (W) 255 255 255 35 = 128 128 127 all 4
3 (B) 0 0 255 33 = 85 86 84 1, 2 + 3
2 (G) 0 255 0 50 = 127 128 0 1 + 2
1 (R) 255 0 0 100

Anyway, it's late, brain hurts, must go to sleep... :o)

Don.
 
Hello

If you are interested and have Photoshop 6 or greater I have a Multiscan
PSD. It is zipped and 8mb and had 8 layers. I scanned it with a LS 30 a
few years back. I also have a huge 16 layer file which is nearly 300Mb.
I can psot a portion of that.

http://www.btinternet.com/~mike.engles/mike/samurai.zip

Mike Engles

Hi Mike,

Yes, I'd be interested, if it's not too much trouble.

Could you trim the files to a sample of about 1 MB zipped each?
Thanks!

Don.
 
Don said:
Hi Mike,

Yes, I'd be interested, if it's not too much trouble.

Could you trim the files to a sample of about 1 MB zipped each?
Thanks!

Don.


Hello

I have cropped the whole file. It is a very small PSD. It will still
show the principle.

Alt click on base to turn off all layers. Ctrl click to turn off base.
Dbl click on a layer to show the layer options and opacity.

http://www.btinternet.com/~mike.engles/mike/samurai1.zip

It is 1.15mb

Mike Engles
 
Kennedy McEwen said:
But it doesn't calculate the mean - it calculates a weighted average.
The layer at 50% contributes 50% more to the image than the layer at
33% and 100% more than the layer at 25%. Even so, the sum of all the
layers should add to 100% or else you produce an overall gain in contrast.
Don, forget the above comments - I was thinking of a different situation
when I wrote it, not the one you were referring to.

In layers, the percentage opacity defines the amount of the current
layer that is mixed with the previous ones. Consequently, the opacities
that you suggested do indeed result in an equal contribution to the
final image from all of the layers.

The other comments about the precision and the limit of the number of
terms that you can add this way remain valid though.
 
Hello

By the way the scan is from quite a dark Kodachrome.

Which pretty much describes my complete slide collection... ;o)

Well, at least as far as LS30 is concerned. For an LS30 every
Kodachrome is dark.

Don.
 
Don said:
Which pretty much describes my complete slide collection... ;o)

Well, at least as far as LS30 is concerned. For an LS30 every
Kodachrome is dark.

Don.


Hello

Dark slides should be in almost everyones collection.
In the days before scanning, we had to underexpose for the printing to
be good. Why Kodachromes seem to be more opaque than Ekatchromes is
really a puzzle. The degree of underexpose was in my case always
consistent. I always rated the film as 1/3 stop faster than it was.


Mike Engles
 
Mike Engles said:
Dark slides should be in almost everyones collection.
In the days before scanning, we had to underexpose for the printing to
be good. Why Kodachromes seem to be more opaque than Ekatchromes is
really a puzzle.

Why is it a puzzle? They are completely different dye types, with
different spectral transmissions. Why would you expect these different
dyes to have exactly the same ratio of narrow band transmission to broad
band transmission? It is no coincidence that Kodachromes only appear
more opaque than Ektachromes to Nikon scanners.
 
Kennedy said:
Why is it a puzzle? They are completely different dye types, with
different spectral transmissions. Why would you expect these different
dyes to have exactly the same ratio of narrow band transmission to broad
band transmission? It is no coincidence that Kodachromes only appear
more opaque than Ektachromes to Nikon scanners.
--
Kennedy
Yes, Socrates himself is particularly missed;
A lovely little thinker, but a bugger when he's pissed.
Python Philosophers (replace 'nospam' with 'kennedym' when replying)


Hello

It did not seem so to me at the Focus exhibition in Birmingham UK.
I tried the same slides on a Minolta 5400. They were as opaque as my
Nikon Ls40 and 50. Perhaps it was the display monitor, but I was not
impressed with the result. I was impressed when I scanned the same slide
on Epson 4870. I don't believe the resolution claims, but the exposure
and noise looked very good, even though they slide again looked very
dark. I was not able to try the Nikon scanners, they decided not to demo
them, but I bought the LS50 anyway. I was going to get the LS5000, but
decided that an extra 500UKP for 2 bits was not very good value. I have
also bought a Epson. It will be very interseting, comparing them.


Mike Engles
 
Mike Engles said:
Hello

It did not seem so to me at the Focus exhibition in Birmingham UK.
I tried the same slides on a Minolta 5400. They were as opaque as my
Nikon Ls40 and 50. Perhaps it was the display monitor, but I was not
impressed with the result.

You will consistently find Nikon scanners reproduce KC darker than an
equivalent EC slide than other manufacturers, however that difference
has reduced significantly in the last two release iterations. Before
you can make such a judgement you do need to be sure of the performance
of the setup, otherwise work on the actual data as displayed in a
histogram. Nevertheless, I am sure that you will find the LS-40 and
LS-50 do not produce anything like the density (or batch variability)
that you encountered scanning the same KC slides on the LS-30, and for
good reason. Similarly, the LS5000 & LS-4000 produced a better match
than the LS-2000 could ever achieve. However none of these are quite as
tolerant of film source as, say, the Minolta or Canon ranges which do
not even require separate settings for KC film to yield similar results
to EC or other related emulsions.
I was not able to try the Nikon scanners, they decided not to demo
them, but I bought the LS50 anyway. I was going to get the LS5000, but
decided that an extra 500UKP for 2 bits was not very good value.

2-bits
half the scan time
improved CCD
multiscan capability
uncut film option
bulk slide feeder option
to list just a few. Whether these other features are significant to you
certainly influences your decision, that is why they offer the lower
cost alternative, but it is quite wrong to say its "just" an extra two
bits.
 
Back
Top