You are not logged in.

#1 2019-02-06 20:52:56

JonnyRobbie
Member
Registered: 2015-04-28
Posts: 147

[solved] Scanner V600 doesn't scan in 16bpc mode

I have a scanner Epson V600. Installed `iscan`, `iscan-data` from repos and `iscan-plugin-gt-x820` from AUR.

$ scanimage -h -d 'epkowa:interpreter:003:020'
Usage: scanimage [OPTION]...

Start image acquisition on a scanner device and write image data to
standard output.

Parameters are separated by a blank from single-character options (e.g.
-d epson) and by a "=" from multi-character options (e.g. --device-name=epson).
-d, --device-name=DEVICE   use a given scanner device (e.g. hp:/dev/scanner)
    --format=pnm|tiff|png|jpeg  file format of output file
-i, --icc-profile=PROFILE  include this ICC profile into TIFF file
-L, --list-devices         show available scanner devices
-f, --formatted-device-list=FORMAT similar to -L, but the FORMAT of the output
                           can be specified: %d (device name), %v (vendor),
                           %m (model), %t (type), %i (index number), and
                           %n (newline)
-b, --batch[=FORMAT]       working in batch mode, FORMAT is `out%d.pnm' `out%d.tif'
                           `out%d.png' or `out%d.jpg' by default depending on --format
    --batch-start=#        page number to start naming files with
    --batch-count=#        how many pages to scan in batch mode
    --batch-increment=#    increase page number in filename by #
    --batch-double         increment page number by two, same as
                           --batch-increment=2
    --batch-print          print image filenames to stdout
    --batch-prompt         ask for pressing a key before scanning a page
    --accept-md5-only      only accept authorization requests using md5
-p, --progress             print progress messages
-n, --dont-scan            only set options, don't actually scan
-T, --test                 test backend thoroughly
-A, --all-options          list all available backend options
-h, --help                 display this help message and exit
-v, --verbose              give even more status messages
-B, --buffer-size=#        change input buffer size (in kB, default 32)
-V, --version              print version information

Options specific to device `epkowa:interpreter:003:020':
  Scan Mode:
    --mode Binary|Gray|Color [Color]
        Selects the scan mode (e.g., lineart, monochrome, or color).
    --depth 8|16 [8]
        Number of bits per sample, typical values are 1 for "line-art" and 8
        for multibit scans.
    --halftoning None|Halftone A (Hard Tone)|Halftone B (Soft Tone)|Halftone C (Net Screen) [inactive]
        Selects the halftone.
    --dropout None|Red|Green|Blue [inactive]
        Selects the dropout.
    --brightness-method iscan|gimp [iscan]
        Selects a method to change the brightness of the acquired image.
    --brightness -100..100 (in steps of 1) [0]
        Controls the brightness of the acquired image.
    --contrast -100..100 (in steps of 1) [0]
        Controls the contrast of the acquired image.
    --sharpness -2..2 [inactive]
        
    --gamma-correction User defined (Gamma=1.0)|User defined (Gamma=1.8) [User defined (Gamma=1.8)]
        Selects the gamma correction value from a list of pre-defined devices
        or the user defined table, which can be downloaded to the scanner
    --color-correction User defined [inactive]
        Sets the color correction table for the selected output device.
    --resolution 400|800|1600|3200dpi [400]
        Sets the resolution of the scanned image.
    --x-resolution 200|400|600|800|1200|1600|3200|6400dpi [200]
        Sets the horizontal resolution of the scanned image.
    --y-resolution 200|240|320|400|600|800|1200|1600|3200|4800|6400dpi [320]
        Sets the vertical resolution of the scanned image.
    --threshold 0..255 [inactive]
        Select minimum-brightness to get a white point
  Advanced:
    --mirror[=(yes|no)] [inactive]
        Mirror the image.
    --speed[=(yes|no)] [no]
        Determines the speed at which the scan proceeds.
    --auto-area-segmentation[=(yes|no)] [inactive]
        
    --short-resolution[=(yes|no)] [no]
        Display short resolution list
    --zoom 50..200 [inactive]
        Defines the zoom factor the scanner will use
    --red-gamma-table 0..255,...
        Gamma-correction table for the red band.
    --green-gamma-table 0..255,...
        Gamma-correction table for the green band.
    --blue-gamma-table 0..255,...
        Gamma-correction table for the blue band.
    --wait-for-button[=(yes|no)] [no]
        After sending the scan command, wait until the button on the scanner
        is pressed to actually start the scan process.
  Color correction coefficients:
    --cct-1 -2..2 [1.2578]
        Controls red level
    --cct-2 -2..2 [-0.213989]
        Adds to red based on green level
    --cct-3 -2..2 [-0.0437927]
        Adds to red based on blue level
    --cct-4 -2..2 [-0.193893]
        Adds to green based on red level
    --cct-5 -2..2 [1.2856]
        Controls green level
    --cct-6 -2..2 [-0.0916901]
        Adds to green based on blue level
    --cct-7 -2..2 [-0.0257874]
        Adds to blue based on red level
    --cct-8 -2..2 [-0.264191]
        Adds to blue based on green level
    --cct-9 -2..2 [1.28999]
        Control blue level
  Preview:
    --preview[=(yes|no)] [no]
        Request a preview-quality scan.
    --preview-speed[=(yes|no)] [no]
        
  Geometry:
    --scan-area Maximum|A4|A5 Landscape|A5 Portrait|B5|Letter|Executive|CD [Maximum]
        Select an area to scan based on well-known media sizes.
    -l 0..215.9mm [0]
        Top-left x position of scan area.
    -t 0..297.18mm [0]
        Top-left y position of scan area.
    -x 0..215.9mm [215.9]
        Width of scan-area.
    -y 0..297.18mm [297.18]
        Height of scan-area.
    --quick-format Maximum|A4|A5 Landscape|A5 Portrait|B5|Letter|Executive|CD [Maximum]
        Select an area to scan based on well-known media sizes. (DEPRECATED)
  Optional equipment:
    --source Flatbed|Transparency Unit [Flatbed]
        Selects the scan source (such as a document-feeder).
    --auto-eject[=(yes|no)] [inactive]
        Eject document after scanning
    --film-type Positive Film|Negative Film [inactive]
        
    --focus-position Focus on glass|Focus 2.5mm above glass [inactive]
        Sets the focus position to either the glass or 2.5mm above the glass
    --bay  1 | 2 | 3 | 4 | 5 | 6  [inactive]
        Select bay to scan
    --eject [inactive]
        Eject the sheet in the ADF
    --adf-mode Simplex|Duplex [inactive]
        Selects the ADF mode (simplex/duplex)
    --detect-doc-size[=(yes|no)] [inactive]
        Activates document size auto-detection.  The scan area will be set to
        match the detected document size.
    --adf-auto-scan[=(yes|no)] [inactive]
        Skips per sheet device setup for faster throughput.
    --double-feed-detection-sensitivity None|Low|High [inactive]
        Sets the sensitivity with which multi-sheet page feeds are detected
        and reported as errors.
    --deskew[=(yes|no)] [inactive]
        Rotate image so it appears upright.
    --autocrop[=(yes|no)] [inactive]
        Determines empty margins in the scanned image and removes them.  This
        normally reduces the image to the size of the original document but may
        remove more.
    --calibrate [inactive]
        Performs color matching to make sure that the document's color tones
        are scanned correctly.
    --clean [inactive]
        Cleans the scanners reading section.

Type ``scanimage --help -d DEVICE'' to get list of all options for DEVICE.

List of available devices:
    epkowa:interpreter:003:021
    utsushi:esci:usb:/sys/devices/pci0000:00/0000:00:1a.7/usb9/9-5/9-5:1.0
    utsushi:esci:networkscan://192.168.0.2:1865
    utsushi:sane::epkowa:usb:0x04b8:0x0848

Trying simple `scanimage` with default depth works fine:

$ scanimage --verbose -d 'epkowa:interpreter:003:021' --format=tiff --source 'Transparency Unit' > test.tiff
scanimage: scanning image of size 808x3052 pixels at 24 bits/pixel
scanimage: acquiring RGB frame
scanimage: min/max graylevel value = 0/254
scanimage: read 7398048 bytes in total

But setting the depth to 16bpc results in a crash?:

$ scanimage --verbose -d 'epkowa:interpreter:003:021' --format=tiff --source 'Transparency Unit' --depth 16 > test.tiff
scanimage: scanning image of size 808x3052 pixels at 48 bits/pixel
scanimage: acquiring RGB frame
$ hexdump test.tiff
0000000 4949 002a 0008 0000 0010 00fe 0004 0001
0000010 0000 0000 0000 0100 0003 0001 0000 0328
0000020 0000 0101 0003 0001 0000 0bec 0000 0102
0000030 0003 0003 0000 00ce 0000 0103 0003 0001
0000040 0000 0001 0000 0106 0003 0001 0000 0002
0000050 0000 0111 0004 0001 0000 00f0 0000 0112
0000060 0003 0001 0000 0001 0000 0115 0003 0001
0000070 0000 0003 0000 0116 0004 0001 0000 0bec
0000080 0000 0117 0004 0001 0000 c540 00e1 0118
0000090 0003 0003 0000 00d4 0000 0119 0003 0003
00000a0 0000 00da 0000 011a 0005 0001 0000 00e0
00000b0 0000 011b 0005 0001 0000 00e8 0000 0128
00000c0 0003 0001 0000 0002 0000 0000 0000 0010
00000d0 0010 0010 0000 0000 0000 ffff ffff ffff
00000e0 0190 0000 0001 0000 0190 0000 0001 0000
00000f0

scanimage does not seem to segfault, but the output image is garbage and the scanner seems to be stuck and needs restart. I've tried xsane and skanlite, but since they all (presumably) work with sane, it didn't help.

Has anyone managed to make 16bpc transparency (analog film negative) work?

$ scanimage -V
scanimage (sane-backends) 1.0.27; backend version 1.0.27
$ uname -roms
Linux 4.20.6-arch1-1-ARCH x86_64 GNU/Linux

Last edited by JonnyRobbie (2019-03-08 10:19:10)

Offline

#2 2019-02-07 14:49:12

eda2z
Member
From: Woodstock, IL
Registered: 2015-04-21
Posts: 28

Re: [solved] Scanner V600 doesn't scan in 16bpc mode

Over the past year I have scanned almost 7k prints, slides and negatives on my V600 -- it helps to be retired. When I started I quickly gave up on scan image. I tried out vuescan and after seeing the results I purchased a license and never looked back.

Offline

#3 2019-02-07 16:40:35

JonnyRobbie
Member
Registered: 2015-04-28
Posts: 147

Re: [solved] Scanner V600 doesn't scan in 16bpc mode

I'm using iscan only as a backend for sane. I don't really want to use epson's imagescan as a frontend. I just need 16bpc in sane/xsane. Are your scans in 16bpc?

Offline

#4 2019-02-08 15:06:07

eda2z
Member
From: Woodstock, IL
Registered: 2015-04-21
Posts: 28

Re: [solved] Scanner V600 doesn't scan in 16bpc mode

My scans are not 16-bit but according to the docs for vuescan they do support 16-bit. Note that this is not imagescan but a different piece of software. It is proprietary but is in the AUR. Without purchasing a license you get a watermarked result.

Offline

#5 2019-03-08 10:18:48

JonnyRobbie
Member
Registered: 2015-04-28
Posts: 147

Re: [solved] Scanner V600 doesn't scan in 16bpc mode

So I was looking more into it. I know that the scanner supports 16bpc on win+mac, so the hardware is capable of that. I've tried running the scan with some more debug info. The output being quite substantial is hosted here. The most important being the last line:

$ SANE_DEBUG_EPKOWA=HEX scanimage --verbose --format=pnm --source 'Transparency Unit' --depth 16 > test16bpcV2.pnm
...
dip-obj.c:572: [epkowa][F] failed: require (8 == buf->ctx.depth)

So I looked into the source of iscan and here's what I found:

$ cat backend/dip-obj.c
...
/*! \todo Add support for 16 bit color values (#816).
 */
void
dip_apply_color_profile (const void *self, const buffer *buf,
                         const double profile[9])
{
...
require (8 == buf->ctx.depth);
...
}
...

Shaking my head at this point, it seems like while the hardware might support 16bpc, Epson could not be arsed enough to implement that in Linux. (Worth noting that 3rd party proprietary Vuescan does support 16bpc, I've tried that with the free watermarked version).

It seemed like I just should resign on the futility and move on, but this miraculous find happened: https://github.com/hean01/iscan. Someone had the exact same problem more then five years ago, but knew enough of C to implement a patch. So I've checked out iscan using ABS, formatted a patch from hean01's changes:

--- backend/channel-usb.c
+++ backend/channel-usb.c
@@ -91,6 +91,7 @@ static ssize_t channel_usb_send (channel *, const void *,
 static ssize_t channel_usb_recv (channel *, void *,
                                  size_t, SANE_Status *);
 
+static size_t channel_usb_max_request_size (const channel *);
 
 channel *
 channel_usb_ctor (channel *self, const char *dev_name, SANE_Status *status)
@@ -119,7 +120,7 @@ channel_usb_ctor (channel *self, const char *dev_name, SANE_Status *status)
   self->send = channel_usb_send;
   self->recv = channel_usb_recv;
 
-  self->max_size = 128 * 1024;
+  self->max_request_size = channel_usb_max_request_size;
 
   return self;
 }
@@ -265,9 +266,6 @@ channel_interpreter_ctor (channel *self, const char *dev_name,
           self->dtor = channel_interpreter_dtor;
         }
     }
-
-  self->max_size = 32 * 1024;
-
   return self;
 }
 
@@ -283,3 +281,10 @@ channel_interpreter_dtor (channel *self)
   self->dtor = channel_dtor;
   return self->dtor (self);
 }
+
+static size_t
+channel_usb_max_request_size (const channel *self)
+{
+  return (self->interpreter ? 32 : 128) * 1024;
+}
+
--- backend/dip-obj.c
+++ backend/dip-obj.c
@@ -555,44 +555,70 @@ dip_change_GRB_to_RGB (const void *self, const buffer *buf)
   return;
 }
 
-/*! \todo Add support for 16 bit color values (#816).
- */
 void
 dip_apply_color_profile (const void *self, const buffer *buf,
                          const double profile[9])
 {
   SANE_Int i;
-  SANE_Byte *r_buf, *g_buf, *b_buf;
   double red, grn, blu;
 
-  SANE_Byte *data;
   SANE_Int size;
 
   require (dip == self && buf && profile);
-  require (8 == buf->ctx.depth);
+  require (buf->ctx.depth == 8 || buf->ctx.depth == 16);
 
   if (SANE_FRAME_RGB != buf->ctx.format)
     return;
 
-  data = buf->ptr;
-  size = buf->end - buf->ptr;
+  if (buf->ctx.depth == 8)
+  {
+    SANE_Byte *r_buf, *g_buf, *b_buf;
+    SANE_Byte *data;
+
+    data = buf->ptr;
+    size = buf->end - buf->ptr;
 
-  for (i = 0; i < size / 3; i++)
+    for (i = 0; i < size / 3; i++)
+    {
+      r_buf = data;
+      g_buf = data + 1;
+      b_buf = data + 2;
+
+      red =
+       profile[0] * (*r_buf) + profile[1] * (*g_buf) + profile[2] * (*b_buf);
+      grn =
+       profile[3] * (*r_buf) + profile[4] * (*g_buf) + profile[5] * (*b_buf);
+      blu =
+       profile[6] * (*r_buf) + profile[7] * (*g_buf) + profile[8] * (*b_buf);
+
+      *data++ = clamp (red, 0, 255);
+      *data++ = clamp (grn, 0, 255);
+      *data++ = clamp (blu, 0, 255);
+    }
+  }
+  else if (buf->ctx.depth == 16)
   {
-    r_buf = data;
-    g_buf = data + 1;
-    b_buf = data + 2;
-
-    red =
-      profile[0] * (*r_buf) + profile[1] * (*g_buf) + profile[2] * (*b_buf);
-    grn =
-      profile[3] * (*r_buf) + profile[4] * (*g_buf) + profile[5] * (*b_buf);
-    blu =
-      profile[6] * (*r_buf) + profile[7] * (*g_buf) + profile[8] * (*b_buf);
-
-    *data++ = clamp (red, 0, 255);
-    *data++ = clamp (grn, 0, 255);
-    *data++ = clamp (blu, 0, 255);
+    uint16_t *r_buf, *g_buf, *b_buf;
+    uint16_t *data;
+
+    data = (uint16_t *)buf->ptr;
+    while(data < buf->end)
+    {
+      r_buf = data;
+      g_buf = data + 1;
+      b_buf = data + 2;
+
+      red =
+       profile[0] * (*r_buf) + profile[1] * (*g_buf) + profile[2] * (*b_buf);
+      grn =
+       profile[3] * (*r_buf) + profile[4] * (*g_buf) + profile[5] * (*b_buf);
+      blu =
+       profile[6] * (*r_buf) + profile[7] * (*g_buf) + profile[8] * (*b_buf);
+
+      *data++ = clamp (red, 0, 65535);
+      *data++ = clamp (grn, 0, 65535);
+      *data++ = clamp (blu, 0, 65535);
+    }
   }
 }

, and it seems to work!!! Makepkg went through and scanning with 16bpc actually worked.

So if anyone is having the issue, checkout iscan from arch repos using abs, apply this patch (tested with version 2.30.3) and makepkg. I'll try to file a bugreport to have this patch in the archrepos. Thanks hean01.

Offline

Board footer

Powered by FluxBB