# Re: Calibration algorithms

From: Karsten Festag (karsten.festag@t-online.de)
Date: Mon May 21 2001 - 12:57:05 PDT

- Next message: Andy Angrick: "RE: something very bad??"
  - Previous message: Karsten Festag: "Re: something very bad??"
  - In reply to: Glenn Ramsey: "Calibration algorithms"
  - Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

  Hi,

  The microtek2 scanners I dealt with in the last time (Phantom 330CX and
  636CX) also do backend calibration. The white stripe inside the cover is
  the white point reference. I'm not sure about the dots but I assume they
  are the reference point for the starting position of the scanhead.
  I made up the backend calibration as follows: (you can download my code
  at http://home.t-online.de/home/karsten.festag)

  -first do a scan of the white stripe with full optical resolution and
  maximum bit depth whith the lamp switched on, then the same with the
  lamp switched off. Thus you get 2 images with the width of the CCD and
  the height of about 50...80% of the white stripe. Don't use the whole
  stripe because sometimes there are artefacts at the borders of the
  stripe.
  My Phantom 330CX provides a special command 'read shading' which reads
  the black and white shading data at once (function read_cx_shading in my
  backend). The 636CX provides information about the location and size of
  the white stripe via the 'scanner attribute' command and the backend has
  to scan the stripe like a normal image (function read_shading_image).

  -now calculate the average over the height of these images (function
  calc_cx_shading_line for the 330CX and prepare_shading_data for the
  636CX). Now you have one line of white and one line of dark pixels, each
  pixel corresponding to a pixel of the CCD. This data can be stored so
  that the scanner has to read the data not for every scan. I do a new
  calibration at the first scan when the backend was started and when the
  mode was changed (gray/color).
  By the way, if your scanner needs backend calibration, I won't recommend
  using the lineart mode of the scanner. Do a calibration corrected
  grayscale scan and make lineart out of it in the backend. Otherwise you
  get a too white middle and too black sides in your scan.

  -when you perform a scan you will have to know which pixels of the CCD
  are used for scanning because you will have to take the corresponding
  pixels of the shading data for calibration. This is especially essential
  when scanning with low resolution because only a few ccd pixels are used
  in this case.
  The Phantom scanners have a command 'read control bits'. You have to
  perform this before the 'read image' command. You recieve some bytes in
  which each set bit represents a used CCD pixel. For examlple: The 330CX
  is a 300dpi scanner with 2550 pixel. That means you need (2550 pixel)/(8
  bit per byte) = 319 control bytes. I recieve 320 control bytes and have
  some junk at the start and the end. If I scan an image in the middle of
  the scan area with 100dpi the control bits look like:
  ...00000000000000000000001001001001001001001001001001001000000000000000000...

  -now you have to create the shading data that suits the scanned image
  (condensed shading data): you have to pick the pixels out of your
  shading data that correspond to a set control bit. (function
  condense_shading)

  -now you can scan the image and take the raw image data from the scanner
  and the condensed shading data and perform the following shading
  correction:

  pixel_to_frontend = ( *from_effective - s_d ) * maxval / ( s_w - s_d );

  (*from_effective contains the raw data, s_d is the dark shading value,
  s_w the white and maxval depends on the bit depth (e.g. 255 for 8bit)

  It's a simple linear interpolation, maybe a nonlinear function suits
  better, but the results I get are pretty good.

  This is done in gray_copy_pixels / segreg_copy_pixels /
  lplconcat_copy_pixels.

  Note that some scanners seem to do only white calibration (no scan with
  dark lamp). In this case s_d is 0.

  Happy coding!

  Karsten

      --
      Source code, list archive, and docs: http://www.mostang.com/sane/
      To unsubscribe: echo unsubscribe sane-devel | mail majordomo@mostang.com

  - Next message: Andy Angrick: "RE: something very bad??"
  - Previous message: Karsten Festag: "Re: something very bad??"
  - In reply to: Glenn Ramsey: "Calibration algorithms"
  - Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

  This archive was generated by hypermail 2b29 : Mon May 21 2001 - 13:57:50 PDT