[sane-devel] Probs... test

Michael Talbot-Wilson mtw at view.net.au
Wed Sep 14 14:36:13 UTC 2011

Dear all, I'm a newcomer to the list.  My first message.  Hope you can
help.  Several points.

(My scanner is an Epson Perfection 4990 Photo detected as Epson

I've written a Tcl/Tk frontend/interface to scanimage (quite
restricted, 260 lines) in part because I want XPosition and YPosition
tags, which xsane doesn't save, in part also because I want the TIFF
tags, equivalents, in PGM files (as comments).  The scanimage output,
PGM, is piped to a program that reads and writes up to the first
whitespace, writes its comments, and then copies the rest.

Noticed this along the way.  Using the test device I can't duplicate
scanimage's calculation of the br coords, and I can't see anything
wrong with my code.  I do a mouse drag of a rectangle to obtain the
args for scanimage, run it (using -l -t -x -y not --tl-x etc.), and
see messages such as

scanimage: rounded value of tl-x from 18.288 to 18
scanimage: rounded value of tl-y from 16.256 to 16
scanimage: rounded value of br-x from 49.496 to 49
scanimage: rounded value of br-y from 51.052 to 51

but my own corresponding calculations are

min x in pixels = 36
min y in pixels = 32
tl-x in mm = 18.288
tl-y in mm = 16.256
max x in pixels = 98
max y in pixels = 101
br-x in mm = 49.784
br-y in mm = 51.308

I can't understand the "convert x/y to br_x/br_y" section of

I'm doing the calculations like this, where $prevres, the resolution of
the preview file, is 50 (per inch).

bind .w <ButtonPress-2> {
    set x1 %x
    set y1 %y
bind .w <B2-Motion> {
    set x2 %x
    set y2 %y

set xmin [min $x1 $x2]
set ymin [min $y1 $y2]
set xmax [max $x1 $x2]
set ymax [max $y1 $y2]

set tlx [expr ${xmin}.0 / ${prevres}.0 * 25.4]
set tly [expr ${ymin}.0 / ${prevres}.0 * 25.4]
set brx [expr ${xmax}.0 / ${prevres}.0 * 25.4]
set bry [expr ${ymax}.0 / ${prevres}.0 * 25.4]

puts "min x in pixels = $xmin"
puts "min y in pixels = $ymin"
puts "tl-x in mm = $tlx"
puts "tl-y in mm = $tly"
puts "max x in pixels = $xmax"
puts "max y in pixels = $ymax"
puts "br-x in mm = $brx"
puts "br-y in mm = $bry"

Also, I notice:

$ sane-backends-1.0.22/frontend/.libs/scanimage -d test --tl-x 3.1
--tl-y 4.7 --br-x 10 --br-y 11 >/dev/null
scanimage: rounded value of tl-x from 3.10001 to 3
scanimage: rounded value of tl-y from 4.7 to 5
./scanimage: unrecognized option '--br-x'

Finally, does anyone do multiple passes and averaging for noise reduction?
Scanning a black sheet I seem to see some noise, a little (doing
histograms/counts), but I don't know whether modern scanners ever need
noise reduction.

Oops, sorry, not final.  I just noticed this, using device test with
--format tiff:

Script started on Wed 14 Sep 2011 10:13:30 CST
$ file scan1315957558
scan1315957558: TIFF image data, big-endian
$ tiffinfo  scan1315957558
TIFFReadDirectory: Warning, scan1315957558: wrong data type 8992 for
"XResolution"; tag ignored.
TIFFReadDirectory: Warning, scan1315957558: invalid TIFF directory;
tags are not sorted in ascending order.
TIFFReadDirectory: Warning, scan1315957558: unknown field with tag
26991 (0x696f) encountered.
TIFFReadDirectory: Warning, scan1315957558: unknown field with tag
25971 (0x6573) encountered.
TIFF Directory at offset 0x8 (8)
   Subfile Type: (0 = 0x0)
   Image Width: 623 Image Length: 680
   Bits/Sample: 8
   Compression Scheme: None
   Photometric Interpretation: min-is-black
   Orientation: row 0 top, col 0 lhs
   Samples/Pixel: 1
   Rows/Strip: 680
   Min Sample Value: 0
   Max Sample Value: 255
   Planar Configuration: single image plane
TIFFFetchDirectory: scan1315957558: Can not read TIFF directory count.
TIFFReadDirectory: scan1315957558: Failed to read directory at offset 0.
$ exit

Script done on Wed 14 Sep 2011 10:14:05 CST

As a newbie I threw that in just in case the people who have been
working on SANE for years had never noticed.  Doesn't stop it from
working perfectly well as a test device.  Sorry.

Still, I hope someone can say something about multiple scanner takes
for noise reduction.  Is it useful, or it is overdoing things
insanely?  NonSANEly?  Unsaintly?

More information about the sane-devel mailing list