Discussion:
fujitsu deskew background artifacts
(too old to reply)
Olaf Meeuwissen
2017-02-14 12:06:26 UTC
Permalink
Raw Message
Hi Paul,
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.
I'm no expert here but looking at your images and the fujitsu backend
code,

- what does a swcrop'd only image look like?
- what if you add a call to buffer_crop before buffer_deskew in the
backend/fujitsu.c code?

The code currently has

/* finished buffering, adjust image as required */
if(s->swdeskew && (!s->hwdeskewcrop || s->req_driv_crop)){
buffer_deskew(s,s->side);
}
if(s->swcrop && (!s->hwdeskewcrop || s->req_driv_crop)){
buffer_crop(s,s->side);
}

The idea is to run crop, deskew, crop, so change that to

/* finished buffering, adjust image as required */
if((s->swdeskew && s->swcrop) && (!s->hwdeskewcrop || s->req_driv_crop)){
buffer_crop(s,s->side);
}
if(s->swdeskew && (!s->hwdeskewcrop || s->req_driv_crop)){
buffer_deskew(s,s->side);
}
if(s->swcrop && (!s->hwdeskewcrop || s->req_driv_crop)){
buffer_crop(s,s->side);
}
Many thanks for your anticipated suggestions.
Hope this helps,
--
Olaf Meeuwissen, LPIC-2 FSF Associate Member since 2004-01-27
GnuPG key: F84A2DD9/B3C0 2F47 EA19 64F4 9F13 F43E B8A4 A88A F84A 2DD9
Support Free Software https://my.fsf.org/donate
Join the Free Software Foundation https://my.fsf.org/join
--
sane-devel mailing list: sane-***@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
to sane-devel-***@lists.alioth.debian.org
m. allan noah
2017-02-14 13:23:13 UTC
Permalink
Raw Message
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...
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.
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 :)

[snip]
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;

to

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
scans).

allan
--
"well, I stand up next to a mountain- and I chop it down with the edge
of my hand"
--
sane-devel mailing list: sane-***@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
to sane-devel-***@lists.alioth.debian.org
Loading...