[sane-devel] fujitsu deskew background artifacts

G. Paul Ziemba pz-sane-devel at ziemba.us
Thu Feb 9 21:39:30 UTC 2017


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
 
I'm implementing an automated pipeline to scan and OCR my receipts on
unix, to replace my previous approach using the fujitsu-provided tools
running in MS-windows in VirtualBox. The receipts don't always go in
exactly straight, so deskewing is a requirement.
 
When I specify --swdeskew=yes to scanimage, it does indeed deskew
the scanned image. However, it leaves a giant artifact in the
background (corresponding to the edge of the original canvas) that
appears to prevent subsequent correct automatic cropping.
 
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.
 
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.
 
Here are URLs to sample images from three scans of the same receipt fed
in at a slight angle. I converted the images from pnm to png so that
they would be accepted at the image hosting site. Dimensions are
2550x3300 (i.e., 8.5in x 11in at 300dpi) for the first two, and
1793x3299 for the cropped image.
 
Plain scan:
 
    /usr/local/bin/scanimage -d "fujitsu:ScanSnap S1500:182858" \
        --format pnm --batch=plain-%02d.pnm --source "ADF Duplex" \
        --mode Gray --sleeptimer 1 --resolution 300
 
    Image: https://image.ibb.co/nysR1F/plain_01.png
 
Deskewed scan:
 
    /usr/local/bin/scanimage -d "fujitsu:ScanSnap S1500:182858" \
        --format pnm --batch=deskew-%02d.pnm --source "ADF Duplex" \
        --mode Gray --swdeskew=yes --sleeptimer 1 --resolution 300

    Image: https://image.ibb.co/gAZTFa/deskew_01.png

Deskewed and cropped scan:

    /usr/local/bin/scanimage -d "fujitsu:ScanSnap S1500:182858" \
        --format pnm --batch=deskewcrop-%02d.pnm --source "ADF Duplex" \
        --mode Gray --swdeskew=yes --swcrop=yes --sleeptimer 1 --resolution 300

    Image: https://image.ibb.co/cYxb1F/deskewcrop_01.png
-- 
G. Paul Ziemba
FreeBSD unix:
 1:41PM  up 26 days,  5:24, 20 users, load averages: 0.75, 0.69, 0.64



More information about the sane-devel mailing list