[sane-devel] fujitsu deskew background artifacts

m. allan noah kitno455 at gmail.com
Tue Feb 14 13:23:13 UTC 2017

Paul- I'm sorry I missed your earlier email, gmail put it in spam. It
was only when Olaf replied that I saw anything about it (thanks
Olaf!). Further comments inline...

On Thu, Feb 9, 2017 at 4:39 PM, G. Paul Ziemba <pz-sane-devel at ziemba.us> wrote:
> There seems to be something wrong with the software deskew operation
> in SANE. I'm hoping someone can either confirm it is a bug or suggest
> alternate arguments to scanimage to fix the problem. I am also happy
> to modify C code and try patches.
> Many thanks for your anticipated suggestions.
> Goal: crop the deskewed image correctly.
> Version: scanimage reports:
>     scanimage (sane-backends) 1.0.25; backend version 1.0.25
> Scanner: Fujitsu ScanSnap S1500

First- thanks for including that info, we have to tease that info out
of most bug reporters :)


> To me, it looks like the color of the background filled in by the
> deskew operation does not match the "empty" background generated by
> the scanner.

Yes- that is exactly the problem. I bet if you scan in black and white
(lineart) mode, the problem would go away just because both background
colors would become white. We'll need to get better at background
color detection for gray and color modes to work.

> As an aside, if the deskewing code can already detect the edges before
> it rotates the image, maybe it can cache those parameters for subsequent
> use by the crop code.

It does do that- you notice that the deskew code moves the image to
the upper left corner rather than rotate it in place. Unfortunately,
the deskew code only finds the top and left edges because it is so
slow. I suppose we could detect if both deskew and crop are turned on
at the same time, and look for the other edges too, but fixing the
background color would be faster to code and faster to run.

[snipped very useful image links]

A quick workaround would be to modify backend/fujitsu.c in the
function buffer_deskew. Change:

  int bg_color = 0xd6;


  int bg_color = 0xbe;

Then rebuild and re-install.

Longer term, we need to either make the background color configurable
on a per-model basis (as done in canon_dr backend), or do a better job
of autodetecting it (made difficult by shadow edges on full-size

"well, I stand up next to a mountain- and I chop it down with the edge
of my hand"

More information about the sane-devel mailing list