[sane-devel] How to reverse-engineer scanner sensor data (CIS)

m. allan noah kitno455 at gmail.com
Thu Oct 4 12:24:13 UTC 2007


On 10/4/07, Alexander Grau <alexandergrau at gmx.de> wrote:
> Hello,
>
> I try to get the following scanner working under Linux (with sane or
> directly
> without libusb).
>
> * Q-Scan Mini FlatBed Scanner DIN A5, Portable Peripheral CO., Ltd.
> * USB 2.0, QS-113C chipset
> * CIS sensor (600 x 1200 dpi), 24 bits/pixel - no brand of CIS to be
> find in the scanner
> * http://www.griden.ru/a5.html
>
>
> 1. I did try the sane "sane-mustek_usb2" module (supporting the QS-113
> chipset).
> The scanner motor, lamp etc. works, but the image output is mostly a
> very dark image
> (I assume because my scanner has a CIS sensor and this module only
> supports CCD).

probably missing color calibration step?

> 2. Second approach was to capture a 1-bit, 8-bit (gray) and 24-bit
> (color) scan with
> usbsnoop and the Windows TWAIN driver and make a libusb c program of it
> by parsing it with
> "usbsnoop2libusb.pl". The resulting c code
> (http://grauonline.de/alexwww/qscan/testcolor.zip)
> works excellent (scanner motor, lamp etc. work), but I have absolutely
> no idea how
> to decode the image data I get back...
>
> The data I get back is 11072538 bytes long (TWAIN driver scans a 1275 x
> 720 pixels
> 24-bit color image) and repeats like this:
>
> 451 bulk read returned 64000 bytes
> 452 control msg returned 8 bytes
> 453 control msg returned 4 bytes
> 454 bulk read returned 28160 bytes
> 455 bulk read returned 108 bytes
> 456 control msg returned 4 bytes
> 457 control msg returned 4 bytes
> 458 control msg returned 4 bytes
> 459 control msg returned 4 bytes
> 460 control msg returned 8 bytes
> 461 control msg returned 4 bytes
>

some chips have limitations on the size or alignment of the blocks
they will transfer, so you see things like: 64k transfer, then a
smaller one, then still smaller.

> ...and so on (http://grauonline.de/alexwww/qscan/libusb_answers_partial.zip)
>
> The scanned Windows image is a 50 % red + 50 % green image
> (http://grauonline.de/alexwww/qscan/win_color.jpg).
>
> The data I get with the Linux code of the same image is a mixture of red
> and green:
> (http://grauonline.de/alexwww/qscan/linux_color.jpg).

that light-colored stair-step repeating from top left to bottom right
indicates that there is some data in the stream which is not part of
the image. perhaps the 108 bytes is some sort of footer?

>
>
> Questions:
>
> 1. What is the best approach to decode CIS data? How is the format with
> other scanners?
> 2. Could the color change because of timing problems? I think the time
> critical
>   parts are done in the scanner ASIC, so timing shouldn't be a problem
> here (and the ASIC
>   is programmed the same way as the TWAIN driver does)
> 3. Is my approach hopeless without color correction? Also, from digital
> cameras I
>   know there must occur some interpolation between the pixel colors. Is
> this needed
>   for CIS too?

you will likely need color correction, but it can often be 'faked'.

allan

>
> Any further hints are appreciated!
>
> Best regards,
> Alexander Grau
>
> (a l e x a n d e r g r a u  <at>  g m x  <dot>  d e)
>
>
> --
> sane-devel mailing list: sane-devel at lists.alioth.debian.org
> http://lists.alioth.debian.org/mailman/listinfo/sane-devel
> Unsubscribe: Send mail with subject "unsubscribe your_password"
>              to sane-devel-request at lists.alioth.debian.org
>


-- 
"The truth is an offense, but not a sin"



More information about the sane-devel mailing list