home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 625.lha / STScan_v2.0 / README.pp / README
Text File  |  1992-03-05  |  7KB  |  243 lines

  1. Siemens ST 400 Scanner an Image Processing Software
  2. ---------------------------------------------------
  3.  
  4. Author and Copyright 1991 by:
  5.  
  6. Frank-Christian Krügel
  7. Rabienstraße 52
  8. W-2862 Worpswede
  9. Germany
  10.  
  11. Fido: 2:240/300.44
  12.  
  13.  
  14. Licence:
  15.  
  16. This program is free software; you can redistribute it and/or modify
  17. it under the terms of the GNU General Public License as published by
  18. the Free Software Foundation version 1.
  19.  
  20. This program is distributed in the hope that it will be useful, but WITHOUT
  21. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  22. FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  23. more details.
  24.  
  25. You should have received a copy of the GNU General Public License along
  26. with this program (file: GNU_COPYLEFT); if not, write to the Free Software
  27. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  28.  
  29.  
  30. Purpose:
  31.  
  32. This program was born from the need of connecting a flatbed scanner with
  33. SCSI bus to my Amiga. It controls size (A4 or A5), number of gray scales
  34. (2 or 16) and threshold settings.
  35.  
  36. In grayscale mode the scanner sends one byte per scanner pixel and uses 64
  37. steps of gray.  These files take away a lot of memory (up to 16 Megs!) and
  38. cannot be previewed on an Amiga, which can only display 16 shades of gray.
  39. So the two least significant bits are thrown away.  For printing or using
  40. the scanned images in DTP programs grayscale pictures can be converted into
  41. bilevel (black and white) pictures.  Both Floyd-Steinberg and Ordered
  42. Dither are available for conversion.
  43.  
  44. Images can be saved to disk as IFF either completely or only a small window
  45. of them.  Data can be written in uncompressed or compressed form.
  46. An image load routine is also included in V2.0.
  47.  
  48. The file requester was changed from the Heath Requester to the file requester
  49. from the req.library.
  50.  
  51. In the right bottom there is a button for switching between full page
  52. display and window display.
  53.  
  54. Almost all scanner specific things are in the scan() function. So it should
  55. be quite simple to adapt this program to different scanners. If there is a
  56. need, simply send me the scanner and the manual, so I can create a
  57. special version for it.
  58.  
  59. This program is not 'complete'. (Name a program and I tell you what should
  60. be added!) It should be considered a first step to the final solution.
  61.  
  62. As a major enhancement image processing functions have been added:
  63.  
  64. The following functions only work with gray-level images:
  65.  
  66. Pixel operations:
  67. - view occurrence of all steps of gray
  68. - contrast enhancement
  69.  
  70. Local operators:
  71. - low pass (two steps)
  72. - high pass
  73. - relief
  74. - minimum, maximum and median operators
  75.  
  76. Conversion to bilevel images:
  77. - Floyd-Steinberg dithering
  78. - Ordered Dither
  79. - Thresholding
  80.  
  81. The following functions only work with bilevel imagel:
  82. - Conversion to grayscale image
  83. - Thinning 
  84. - Vectorization (of a thinned image)
  85.  
  86. The following functions work with both kinds of images:
  87. - Inversion
  88. - Mirror (horizontal and vertical)
  89. - Cut out an area
  90.  
  91.  
  92. Vectorization:
  93. Bilevel images can be converted into vector format. The conversion
  94. consists of three steps:
  95. - Loading or scanning a bilevel image 
  96. - Thinning
  97. - Vectorization
  98.  
  99. The vectorization routine outputs a text file that has the following format:
  100. <x11> <y11>    \
  101. <x21> <y21>    /First vector
  102.         empty line as separation
  103. <x12> <y12>    \
  104. <x22> <y22>    /Next vector
  105.         empty line as separation
  106. ....
  107.  
  108. This file can be loaded directy into IntroCad 2 using the "<--- TXT" function.
  109. Other PD-programs as MPlot use this kind of format as well. With MPlot
  110. there are some utility programs to convert the TXT file into ICAD native format,
  111. Aegis Draw, or DXF.
  112. Warning! While detecting the pixel chains each pixel that is recognized is
  113. set to white in order to prevent processing pixels twice. So it's a good
  114. idea to save the image before vectorization.
  115.  
  116.  
  117. You need:
  118.  
  119. - This disk
  120. - an Amiga
  121. - at best a flicker-free screen
  122. - as much memory as you can get (the largest pictures need 8MB)
  123. - a SCSI interface with the Commodore 'Exec level Direct SCSI' programming
  124.   interface
  125. - a SCSI scanner with cable. When using not a Siemens scanner the program
  126.   has to be adapted and recompiled
  127.   With Version 2 a scanner is no longer necessary. Without scanner the
  128.   "Scan" and the "Test Scanner" menu items are disabled.
  129. - Aztec C 5.0 (It should also work with Lattice, but this is untested!)
  130.   for Recompiling
  131. - The "req.library" including header files from Fish 419.
  132.  
  133. Recompiling:
  134.  
  135. Simply change to the directory containing all source files and type 'make'.
  136. The program does not rely on specific path names etc.
  137.  
  138.  
  139. Start:
  140.  
  141. Type 'stscan' or double-click icon. Make sure that the scanner is ready
  142. when booting and when starting the program. Note: The Siemens Scanner
  143. is hardwired on SCSI Unit 3, LUN3. Do not have any other SCSI device
  144. with the same unit number connected to the bus
  145.  
  146.  
  147. Still to do:
  148.  
  149. Compiling two different versions for PAL and NTSC machines isn't very nice.
  150. An automatic detection should be added here.
  151. Some parts of the image processing routines have to be optimized for speed.
  152. The vectors generated by the vectorization module could be optimized,
  153. so that there are longer but fewer vectors. Splines or Beziers would also
  154. be very nice, but don't expect them before the fifth release.
  155.  
  156. How the Siemens Scanner works:
  157.  
  158. For a better understanding here is a short description of how the scanner is
  159. controlled.
  160.  
  161.  
  162. 1. Turn scanner light on:
  163.    Send 'Mode Select' with Vendor Specific Bit (bit 7 of 5th byte of cdb) set
  164.  
  165.     Command Descriptor Block:
  166.     0x15 (Command)
  167.     (LUN<<5)
  168.     0
  169.     0
  170.     0
  171.     128 (Vendor Specific Bit)
  172.  
  173. 2. Wait 2 sec. for maximum light intensity
  174.  
  175. 3. Send Window Descriptor Block to Scanner
  176.  
  177.     Command Descriptor Block:
  178.     0x24 (Command)
  179.     (LUN<<5)
  180.     0
  181.     0
  182.     0
  183.     0
  184.     0
  185.     Upper byte of data length, always 0
  186.     Lower byte of data length, always 40=0x28
  187.     0
  188.  
  189.     Window Descriptor Block
  190.     typedef struct DefWindow
  191.     {  ULONG dummy1;
  192.        UWORD dummy2;
  193.        UWORD wpsize;    /*data length - 8*/
  194.        UBYTE winnr;        /*window number starting with 1*/
  195.        UBYTE dummy3;
  196.        UWORD resx;        /*horizontal resolution in dpi*/
  197.        UWORD resy;        /*verical resolution, same as horizontal*/
  198.        UWORD cornerx;    /*left upper corner..*/
  199.        UWORD cornery;    /*..of scanning area*/
  200.        UWORD width;        /*size of ..*/
  201.        UWORD height;    /*..scanning area*/
  202.        UBYTE dummy4;
  203.        UBYTE threshold;    /*0..64*/
  204.        UBYTE size;     /* temporary storage, ignored by scanner */
  205.        UBYTE halftone;    /*0:bilevel 2:grayscale*/
  206.        UBYTE bitspixel;    /*1:bilevel 8:grayscale*/
  207.        UBYTE dummy5;
  208.        UWORD dummy6;
  209.        ULONG dummy7;
  210.     };
  211.     Dummies are set to 0.
  212.  
  213. 4. Start Scanning
  214.  
  215.     Command Descriptor Block:
  216.     0x1b (Command)
  217.     (LUN<<5)
  218.     0
  219.     0
  220.     0
  221.     0
  222.  
  223. 5. Read 32k of Data until the complete image has been read
  224.  
  225.     Command Descriptor Block:
  226.     0x28 (Command)
  227.     (LUN<<5)
  228.     0
  229.     0
  230.     0
  231.     0
  232.     0
  233.     Upper byte of data length
  234.     Lower byte of data length
  235.     0
  236.  
  237. The scanner only has 2 MB of internal memory.  Large gray scale images can
  238. exceed this memory limit.  In this case you have to divide to page into
  239. horizontal stripes with the full width and a maximum height of
  240. (0x200000L/width) raster lines, which produce less than 2 MB each.  Then
  241. scan each stripe as described above util the whole picture is processed.
  242.  
  243.