Don ha scritto:
Ah, that's different, then. I don't know what SANE does but as far as
I recall it's GNU so you should be able to inspect the sources.
Not all of them, since part of the Epson Avasys driver is given in
binary format only.
What I can inspect, however, I'm inspecting right now.
But what's funniest is that there is *no* mention of exposure (or gain)
in the whole source.
I think the exposure logic is actually in the firmware, and it reacts
automatically to the gamma lookup tables that are passed to it (see
below for why I still think this is the case).
It would appear SANE either mislabeled this option or does something
unconventional. The sole point of a negative setting in scanner
software is to invert the image and remove the orange mask.
What option are you talking about, "--film-type Negative" or the
"--color-gamma-table" set of options?
"--film-type Negative" does just about what it's supposed to do: it
adjusts the exposure in order to remove the orange mask, and... well,
nothing else that I can see, since it doesn't even invert.
About "--***-gamma-table", as I said, I don't think it's the option
itself that does something unconventional, but rather it is the scanner
firmware that thinks it's smart enough to change the exposure based on
the gamma table it's passed.
You can easily check this by doing two scans and then comparing the
histograms afterwards in your image editing software. I guess you're
using GIMP, right?
Mostly Photoshop (the computer with Linux is my "server", the one I use
normally has Windows).
The problem is that, to meaningfully compare the histograms, I need to
be sure the the scan taken with "--film-type Negative" and the one
taken with "--film-type Positive" are made with exactly the same RGB
exposures -- and as you now know, this isn't an easy thing do with my
scanner
But really, contrast doesn't seem to be an issue. As I said, "I can't
be sure", but for all I can tell, "--film-type Negative" just changes
the green and blue exposures.
I'll explain. I used the term "gamma" simply because that's the name of
the option, i.e. "--red-gamma-table", "--green-gamma-table" and
"--blue-gamma-table".
However, what these options let me specify is a complete map of color
values, so that, for example,
0,2,4,6,8,10,12,14,...,254,255,255,...,255
gives me an image with twice the brightness (if brightness is the
correct term), without really changing *gamma*.
OK, that's a bit clearer, now. The values you're referring to are
indeed gamma values. They're so-called "look up tables" (LUT) and when
they're applied the following happens (I'll use your examples).
Any color with value 0 is replaced with value 0.
Any color with value 1 is replaced with value 2.
Any color with value 2 is replaced with value 4.
...
Any color with value 253 is replaced with value 255.
Any color with value 254 is replaced with value 255.
Any color with value 255 is replaced with value 255.
Now, if you look at these tables you'll notice that regardless of the
gamma setting *all* of them start with a 0 and end with a 255. The
only thing that changes are the values in between. That's why it's
impossible to map values from 0 - 255 to 0 - 128 using gamma.
Why do you say it's impossible? I can set up that table to anything I
like, for example
scanimage [...] --red-gamma-table
0,32,64,96,128,160,192,224,255,255,[...],255
Sure, it still ends with 255, but I don't see any problem with that.
It's *not* a gamma table, it's a linear table. It's just like moving
the whitepoint, for all I can see.
I suspect you may be mistaking the application of gamma for exposure.
It's probably because, superficially, both may appear to "brighten"
the image but the differences are major. Again, looking at the
histogram should throw more light.
Believe me, I'm not mistaking gamma for exposure. The scanner takes
longer to scan using the table above (though only when scanning above
600 dpi, as I now realized; when scanning at 600 dpi or less, it
apparently keeps the exposure fixed and just lets the software processe
the image according to the table given).
Of course, if I gave it a table like
0,255,0,255,0,255,[...]
it would have to let the software apply this table; same for a "real"
gamma table which actually changes the gamma; but the point is that,
when it is given a table that puts the whitepoint below 255, it uses
exposure to achieve that instead of color-mapping.
Also, when you change exposure the scan takes longer (assuming all
other options are kept the same). That's another test you may try.
Changing gamma does not change the time it takes to scan.
No, changing the gamma doesn't, but changing the gamma table so that
the last n values are filled with 255 apparently does.
I think this is really an important information for Epson owners,
although more careful scrutiny of what the scanner is actually doing is
needed, in order to understand what side-effects there are, if any.
(Actually, the fact that changing the gamma tables in a specific way
changes the exposures is itself one of the biggest side-effects I have
ever seen..)
I've started measuring the times taken to scan with various different
gamma-tables (all linear, but with the whitepoint set at different
values). For now, all I can say is that the time *does* change, but
I'll post numeric results when I've got enough of them.
This is a wild guess but maybe SANE has auto-exposure and doesn't even
let you change exposure manually? Not very likely, but possible.
Nope. SANE itself leaves it to the individual driver to decide which
options to offer (there aren't even fixed option names, for example
"--film-type Negative" could be called "--mary-had-a-little Lamb" with
another scanner driver -- though there are standards, fear not).
The specific driver of my scanner certainly doesn't allow to change the
exposure explicitely.
Again, a histogram is the way to get to the bottom of it. Scan raw a
few images (some underexposed, some overexposed) without making any
editing changes, and then check the right edge of the histogram. If
they all "touch" the right edge it suggests SANE does auto-exposure.
And it doesn't.
It doesn't even have a way to, since it has no concept of a "preview"
(a preview is simply a scan at a low resolution, which SANE doesn't
perform unless I tell it to).
The Windows software (Epson Scan), on the other hand, does something
similar to what you say: it forces the user to take a preview scan, and
then automatically computes levels and all that based on the preview.
*And* it computes exposure, although, as I said, I have a feeling that
even Epson Scan doesn't *directly* decide exposure, but just sets a
white point by sending appropriate lookup tables to the scanner
firmware.
Later: A lateral thought... Try searching SANE docs for things like
"gain". Maybe SANE just uses a different term for exposure?
Tried. Nope. :-\
That's indeed the way to do it!
Have you tried re-installing?
As posted in another article, I have solved this one: exposure gets
changed depending on the lookup tables passed *only* when scanning at
1200 dpi or higher.
However, I'm still very uncertain on the details: for example, if I
scan as positive using the whitepoint that should lead to orange-mask
removal, I do *not* get the same exposure times I get when scanning
directly as negative -- I just get the normal exposure time (let's call
it 1x).
However, if I set the whitepoint even lower, then the exposure does
change, up to about 3x (based on manual timing).
In other words, it's all a big mess.
[snip]
Also, Curves are non-linear while exposure is linear. Therefore, one
can *not* emulate curve settings using exposure! It's just impossible.
Well, a "linear curve" *can* be emulated using exposure

But yes, I realize that anything that is not linear can't be emulated
with (just) exposure.
That's basically how I got into all this 3 years ago only I tried to
correct the notorious Kodachrome cast! ;o) And I'm still at it!
Encouraging ;-)
The trouble with optics is that it's a maze of ambushes and "hidden"
pitfalls.
Yeah, I've been realizing this. At just about every time I take a scan.
For example, see below for the "progression" of color values
as you change exposure.
In theory, you can remove a cast using exposure as long as the cast is
linear. That opens up a whole new can of worms such as film response
curves, etc but with that caveat:
But is the cast given by the orange mask linear? That's the issue that
concerns me most at the moment.
Obviously I'll also have to deal with film characteristic curves and
all that, but I think that's better left for when I have resolved the
more fundamental issues I have posted about, do you agree?
(But I wouldn't mind if you could point me to a site that gives good
curves for the "average" film given an ISO rating, or even various
brands, in *numerical* format, not just drawings...)
Here's a formula you may find useful. This may be simplified a lot but
I'm including everything to see how it's arrived at.
OP = ((OldPix / 255) ^ Gamma) * 255
NP = ((NewPix / 255) ^ Gamma) * 255
ev = Log(1 / (OP / NP)) / Log(2)
where:
OldPix = old pixel value before exposure is applied
NewPix = new pixel value after exposure is applied
ev = standard exposure value
Thanks. So at gamma=1.0, ev = Log(1 / (OldPix / NewPix)) / Log(2) ?
I admit to not knowing what a "standard exposure value" actually is.
Just tell me, is it linear to the exposure time?
Now, you know that I can't give my scanner the ev value directly: I
must directly map every possible OldPix value to every possible NewPix
value. Am I right in assuming that, using your formula, I could set an
ev value by solving
NewPix = 2^ev * OldPix (with gamma=1.0)
or
NewPix = 2^(ev/Gamma) * (OldPix^Gamma)^(1/Gamma) (with
gamma<>1.0)
?
(Just ignore the second formula if you prefer, it's the result my
calculator gives, I can't solve that kind of things =)
For example, assuming gamma=1.0 and doubling of exposure:
A color with value 10 will become 20 and a color with value of 100
will become 200. So far so good. But if you locate these values on the
histogram you'll *perceive* 10 as barely "moving" to reach 20, while
100 will make a huge jump to get to 200. That's because 10/255 is not
the same as 100/255!
That's why it's so easy to blow the highlights but the shadows barely
lighten.
Yes, I understand this.
by LjL
(e-mail address removed)