home *** CD-ROM | disk | FTP | other *** search
- Siemens ST 400 Scanner an Image Processing Software
- ---------------------------------------------------
-
- Author and Copyright 1991 by:
-
- Frank-Christian Krügel
- Rabienstraße 52
- W-2862 Worpswede
- Germany
-
- Fido: 2:240/300.44
-
-
- Licence:
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation version 1.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- more details.
-
- You should have received a copy of the GNU General Public License along
- with this program (file: GNU_COPYLEFT); if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-
- Purpose:
-
- This program was born from the need of connecting a flatbed scanner with
- SCSI bus to my Amiga. It controls size (A4 or A5), number of gray scales
- (2 or 16) and threshold settings.
-
- In grayscale mode the scanner sends one byte per scanner pixel and uses 64
- steps of gray. These files take away a lot of memory (up to 16 Megs!) and
- cannot be previewed on an Amiga, which can only display 16 shades of gray.
- So the two least significant bits are thrown away. For printing or using
- the scanned images in DTP programs grayscale pictures can be converted into
- bilevel (black and white) pictures. Both Floyd-Steinberg and Ordered
- Dither are available for conversion.
-
- Images can be saved to disk as IFF either completely or only a small window
- of them. Data can be written in uncompressed or compressed form.
- An image load routine is also included in V2.0.
-
- The file requester was changed from the Heath Requester to the file requester
- from the req.library.
-
- In the right bottom there is a button for switching between full page
- display and window display.
-
- Almost all scanner specific things are in the scan() function. So it should
- be quite simple to adapt this program to different scanners. If there is a
- need, simply send me the scanner and the manual, so I can create a
- special version for it.
-
- This program is not 'complete'. (Name a program and I tell you what should
- be added!) It should be considered a first step to the final solution.
-
- As a major enhancement image processing functions have been added:
-
- The following functions only work with gray-level images:
-
- Pixel operations:
- - view occurrence of all steps of gray
- - contrast enhancement
-
- Local operators:
- - low pass (two steps)
- - high pass
- - relief
- - minimum, maximum and median operators
-
- Conversion to bilevel images:
- - Floyd-Steinberg dithering
- - Ordered Dither
- - Thresholding
-
- The following functions only work with bilevel imagel:
- - Conversion to grayscale image
- - Thinning
- - Vectorization (of a thinned image)
-
- The following functions work with both kinds of images:
- - Inversion
- - Mirror (horizontal and vertical)
- - Cut out an area
-
-
- Vectorization:
- Bilevel images can be converted into vector format. The conversion
- consists of three steps:
- - Loading or scanning a bilevel image
- - Thinning
- - Vectorization
-
- The vectorization routine outputs a text file that has the following format:
- <x11> <y11> \
- <x21> <y21> /First vector
- empty line as separation
- <x12> <y12> \
- <x22> <y22> /Next vector
- empty line as separation
- ....
-
- This file can be loaded directy into IntroCad 2 using the "<--- TXT" function.
- Other PD-programs as MPlot use this kind of format as well. With MPlot
- there are some utility programs to convert the TXT file into ICAD native format,
- Aegis Draw, or DXF.
- Warning! While detecting the pixel chains each pixel that is recognized is
- set to white in order to prevent processing pixels twice. So it's a good
- idea to save the image before vectorization.
-
-
- You need:
-
- - This disk
- - an Amiga
- - at best a flicker-free screen
- - as much memory as you can get (the largest pictures need 8MB)
- - a SCSI interface with the Commodore 'Exec level Direct SCSI' programming
- interface
- - a SCSI scanner with cable. When using not a Siemens scanner the program
- has to be adapted and recompiled
- With Version 2 a scanner is no longer necessary. Without scanner the
- "Scan" and the "Test Scanner" menu items are disabled.
- - Aztec C 5.0 (It should also work with Lattice, but this is untested!)
- for Recompiling
- - The "req.library" including header files from Fish 419.
-
- Recompiling:
-
- Simply change to the directory containing all source files and type 'make'.
- The program does not rely on specific path names etc.
-
-
- Start:
-
- Type 'stscan' or double-click icon. Make sure that the scanner is ready
- when booting and when starting the program. Note: The Siemens Scanner
- is hardwired on SCSI Unit 3, LUN3. Do not have any other SCSI device
- with the same unit number connected to the bus
-
-
- Still to do:
-
- Compiling two different versions for PAL and NTSC machines isn't very nice.
- An automatic detection should be added here.
- Some parts of the image processing routines have to be optimized for speed.
- The vectors generated by the vectorization module could be optimized,
- so that there are longer but fewer vectors. Splines or Beziers would also
- be very nice, but don't expect them before the fifth release.
-
- How the Siemens Scanner works:
-
- For a better understanding here is a short description of how the scanner is
- controlled.
-
-
- 1. Turn scanner light on:
- Send 'Mode Select' with Vendor Specific Bit (bit 7 of 5th byte of cdb) set
-
- Command Descriptor Block:
- 0x15 (Command)
- (LUN<<5)
- 0
- 0
- 0
- 128 (Vendor Specific Bit)
-
- 2. Wait 2 sec. for maximum light intensity
-
- 3. Send Window Descriptor Block to Scanner
-
- Command Descriptor Block:
- 0x24 (Command)
- (LUN<<5)
- 0
- 0
- 0
- 0
- 0
- Upper byte of data length, always 0
- Lower byte of data length, always 40=0x28
- 0
-
- Window Descriptor Block
- typedef struct DefWindow
- { ULONG dummy1;
- UWORD dummy2;
- UWORD wpsize; /*data length - 8*/
- UBYTE winnr; /*window number starting with 1*/
- UBYTE dummy3;
- UWORD resx; /*horizontal resolution in dpi*/
- UWORD resy; /*verical resolution, same as horizontal*/
- UWORD cornerx; /*left upper corner..*/
- UWORD cornery; /*..of scanning area*/
- UWORD width; /*size of ..*/
- UWORD height; /*..scanning area*/
- UBYTE dummy4;
- UBYTE threshold; /*0..64*/
- UBYTE size; /* temporary storage, ignored by scanner */
- UBYTE halftone; /*0:bilevel 2:grayscale*/
- UBYTE bitspixel; /*1:bilevel 8:grayscale*/
- UBYTE dummy5;
- UWORD dummy6;
- ULONG dummy7;
- };
- Dummies are set to 0.
-
- 4. Start Scanning
-
- Command Descriptor Block:
- 0x1b (Command)
- (LUN<<5)
- 0
- 0
- 0
- 0
-
- 5. Read 32k of Data until the complete image has been read
-
- Command Descriptor Block:
- 0x28 (Command)
- (LUN<<5)
- 0
- 0
- 0
- 0
- 0
- Upper byte of data length
- Lower byte of data length
- 0
-
- The scanner only has 2 MB of internal memory. Large gray scale images can
- exceed this memory limit. In this case you have to divide to page into
- horizontal stripes with the full width and a maximum height of
- (0x200000L/width) raster lines, which produce less than 2 MB each. Then
- scan each stripe as described above util the whole picture is processed.
-
-