[sane-devel] Re: Unpaper 1.0.1 problem

Jens Gulden mail@jensgulden.de
Sat, 18 Jun 2005 13:11:05 +0200


Hello,

Janusz S. Bien wrote:
> I placed an example at
>         http://www.mimuw.edu.pl/~jsbien/PTJ1927/

> the result of unpaper on a sample file=20
 >
> ./unpaper -vv --layout double 04b.pgm unpaper04.pgm
 >
> is slightly surprising: the pages has been shifted slighty to the left

Ah, I agree it is badly documented that "--layout double" implies both=20
"--pre-rotate 90" and "--post-rotate -90":

"unpaper --help" says:
[...]
'double' - two pages per sheet, rotated
            anti-clockwise (i.e. the top-
            sides of the pages are heading
            leftwards, and the pages are
            placed right-page above left-
            page on the unrotated sheet)
Using this option automatically adjusts the
--mask-point and --pre/post-rotation options.
[...]

Try

./unpaper -vv --layout double --pre-rotate 0 --post-rotate 0 04b.pgm=20
unpaper04.pgm

instead.

(Note that --pre-rotate and --post-rotate must appear after the --layout=20
option, because they need to overwrite the default-settings changed by=20
--layout.)
The current version of unpaper will issue a message telling you that it=20
is not possible to set pre/post-rotation values other than -90 or 90,=20
but as a consequence to this it will set the value to 0 anyway, so the=20
message can be ignored.

The original idea behind the default rotation performed with "--layout=20
double" was that when scanning sheets via scanimage or scanadf, one=20
would by default get images that are rotated the described way (or 180=B0=
=20
flipped, if the paper gets fed in the other way, of course).
Maybe iff one day I would find time for an update of unpaper, this=20
should be changed to a "--layout double-rotated" option, while "--layout=20
double" would use no pre- or post-rotations. But that's just an idea for=20
today.

I have also tried to find some other settings which make your original=20
image better. Try e.g.

unpaper -vv --layout double --pre-rotate 0 --post-rotate 0=20
--mask-scan-threshold 0.4 --grayfilter-size 5 --grayfilter-step 5=20
--blurfilter-size 25 --blurfilter-step 15 --blurfilter-intensity 0.05=20
--border-scan-threshold 8 04test.pgm unpaper04test_jens.pgm

The one example image looks quite nice after doing this. Besides some=20
more filtering, now also the mask-scanning works, which correctly=20
centers both pages on their half of the sheet.
This might also be a good preparation for cutting the sheets into halfs.

(Note that in the example above, the mask-scan-threshold value of 0.4 is=20
unusually high, so this maybe would cause problems on pages that include=20
e.g. line-drawings instead of text. I don't know what kind of other=20
pages you have. If pages include text and line-drawings, but no=20
grayscale-photos or color, converting them to 1-bit black-and-white PBM=20
files before running them through unpaper probably makes the=20
configuration of unpaper a little easier.)

Hope that helps,
Jens