home *** CD-ROM | disk | FTP | other *** search
/ Archive Magazine 1995 / ARCHIVE95.iso / discs / shareware / share_40 / read / !Read / !Help < prev    next >
Text File  |  1990-09-06  |  12KB  |  230 lines

  1. Read - A character reader for monospaced fonts
  2.  
  3. VERSION 0.0
  4.  
  5. INTRODUCTION
  6.   Read is an attempt at OCR for the Archimedes. It can load a scan from the
  7. Watford scanner, or load a two-colour sprite file. It then attempts to turn
  8. the image into text.
  9.   Read needs to be trained in the particular font used. It only works with
  10. monospaced fonts, i.e. equal spacing between letters, and between lines.
  11.   Once a font has been learnt it can be stored for future use.
  12.   So far I have attempted to train it in two fonts, Epson MX80 double
  13. emphasised printout and program listings from the Acorn User's "Yellow
  14. Pages".
  15.   The first has been fairly successful with < 1% errors, and the second less
  16. so with 5% or more errors.
  17.  
  18. Read is started from the RISC-OS desktop in the usual way by double clicking
  19. on its sprite. It installs a sprite on the iconbar with the word 'font'
  20. under it, indicating that it needs a font.
  21.   Read needs to have seen the !System directory, and to find version 3.5 or
  22. later of the shared C library in !System.Modules.
  23.   Read is controlled by two menus, one on the iconbar and one on the main
  24. window.
  25.     Menu options are denoted as follows in this file:-
  26.  
  27.     <window->save->sprite> means the sprite option from the save option of
  28. the window menu.
  29.  
  30. LOADING A SCAN
  31.    To load a sprite file drag it to the iconbar icon, or to the main window
  32. if it is open. The sprite file must contain exactly one sprite, and this
  33. must be in a two-colour mode.
  34.    If the load is successful the main window appears and displays the
  35. sprite, and a red or green grid. Closing this window deletes the sprite and
  36. frees the memory it uses.
  37.    If the sprite has a pallette it is ignored. Read needs the sprite to have
  38. colour 0 as background and colour 1 as writing. In the standard desktop
  39. pallette this will appear as black writing on a white background. Read will
  40. swap the colours if it thinks it is the wrong way round. If it appears
  41. wrongly, invert the sprite using <window->process->invert> (see below).
  42.    If you have a Watford hand scanner you can scan directly into read.
  43. Select the desired size of scan and resolution using <iconbar->size> from
  44. the iconbar menu. You can change the units of the scan size by clicking on
  45. the icon displaying the units. The measurements will be rounded to an exact
  46. number of pixels, with the horizontal size a multiple of 32 pixels. The
  47. amount of memory required is updated when you change units or click on
  48. <Check>. The font memory will not be known unless you have loaded a font. If
  49. the free memory goes negative you had better try a smaller scan.
  50.   To start the scan click on <iconbar->scan>. If this is shaded you have not
  51. got a Watford scanner, it is not running, or the dpi switch does not agree
  52. with the setting in <iconbar->size> .
  53.   The iconbar text should change to "scan". Read now waits for you to finish
  54. scanning. The sprite should now appear as above.
  55.   Sprites are displayed at a size that shows each pixel, They are converted
  56. to mode 0 if you are in a 256 line mode or mode 18 if you are in a 512 line
  57. mode.
  58.   You can save the scan from the <save->sprite> option of the window menu.
  59. The <process> option of the window menu allows you to invert the sprite
  60. (swap black and white), turn the sprite upside-down (it may be easier to
  61. scan some things upside-down) or shear the sprite.Scans should normally be
  62. done at 400 dpi unless the characters are very large.
  63.   <window->process->shear> slides the right hand side up or down while
  64. keeping the left hand side fixed. It may be used to correct slightly slanted
  65. scans. You can shear the whole sprite or all below a given line, If you
  66. select <window->process->Part> the part of the sprite scanned is taken to be
  67. that on and below the top of the grid at this time.
  68.  The shear required is entered in the writeable menu icon,positive for
  69. up,negative for down. Selecting this icon performs the shear.A shear factor
  70. of 100 or so may be needed to see any result.
  71.  The shear is reversible,except for losses at the top and bottom of the
  72. region, as long as the shear is performed on the whole sprite, or parts are
  73. taken lower down each time. In these cases the shear factor is not
  74. cumulative, so you should enter the total effect you want,rather than the
  75. change required.  
  76.  
  77. LOADING A FONT
  78.  
  79.   Fonts come in two varieties, count fonts which can still be taught new or
  80. improved character shapes, and pixel fonts that are 'frozen', but smaller.
  81.   You can load either font by dragging the font file to the window or
  82. iconbar. The iconbar text will change to "box" and the grid to green.
  83.   You can save a font from <window->save->counts> or <window->save->pixels>.
  84.  
  85. STARTING A NEW FONT
  86.   To start a new font you must set the sizes of the characters. This is done
  87. by setting the grid over a block of text. The grid spacing can only be
  88. changed when in "new font" mode. This is indicated by a red grid, and the
  89. word "font" on the iconbar. If you have already loaded or started a font you
  90. can get back here by selecting <window->New Font>. Any font in memory will
  91. be lost.
  92.   In "new font" mode the top left corner of the grid can be set by clicking
  93. select on the window, and the bottom right by clicking alter. Fine
  94. adjustment can be made using the arrow keys for the top right, and <shift>
  95. arrow keys for the bottom left. The number of characters in your grid must
  96. be set using the <grid> option on the window menu.
  97.    It is likely that it will not be possible to ensure that all the
  98. characters fall exactly in the grid rectangles. This does not matter, at
  99. this stage we are only setting the character sizes. Ensure that the number
  100. of rows and columns are correct, line up the top of the top row of boxes
  101. with the top of the first row of characters, and the top of the bottom row
  102. of boxes with the top of the bottom row of characters. Chose characters of
  103. similar height or estimate the height of a fixed character. If there is much
  104. of a slant to the text use the characters at one end, shear till level, or
  105. better scan again. Do the same with the edges.
  106.    When you have set your grid correctly select <window->New Box>. The grid
  107. will turn green and the iconbar text turn to "box".
  108.  
  109. SETTING THE BOX                              
  110.   The box can be set in "New box" mode. The grid is then green and the
  111. iconbar says box. To get to "New box" mode you must load a font or start a
  112. new font. If you have previously set a box you can get back to "New box"
  113. mode by selecting the <window->New Box>. Any text read into memory will be
  114. lost. 
  115.   The box indicates the part of the sprite to read and the number of
  116. characters and lines to look for. The number of rows and columns can be set
  117. from <window->grid>. The grid is rigid and can be moved by the arrow keys.
  118. <Select> positions the top right corner.
  119.   The grid should be set so that the top is as low as possible without
  120. touching the first row of characters, and without the base of the first row
  121. touching the second row of characters. Do not worry about lower rows! Adjust
  122. the grid sideways so that the first row of characters are centered in their
  123. boxes as far as possible.
  124.  
  125. READING
  126.   Reading can be started by selecting one of three options:-
  127.     <window->Learn>    -   Stop at each character. 
  128.     <window->Read>     -   Stop when unsure.      
  129.     <window->Non Stop> -   Stop when required number of rows have been read.
  130.  
  131.  The selected menu item will be ticked. You can stop the read by selecting
  132. the ticked option again, or change to another read mode by selecting it.
  133.  
  134.   Obviously if you have just started a new font you should use <Learn>.
  135.  
  136.   The line number reached is displayed on the iconbar. The line and
  137. character are outlined in the scan. When the scan is completed "halt"
  138. appears on the iconbar and the machine beeps. You can now save the text read
  139. from <window->save->text>. In "Non Stop" mode you can save in mid-read.
  140.  
  141. LEARNING
  142.    When learning the machine stops at every non-space character. Blue lines
  143. in the window indicate the current character and line. The text found so far
  144. is displayed including the machines best guess at the character found. You
  145. can enter the correct character below if needed. The buttons then act as
  146. follows.
  147.    <Learn> - learn the guess or character entered.
  148.    <Set>   - set the character in the text but do not learn.
  149.    <Read>  - change to read mode.
  150.    <Fast>  - change to non-stop mode.
  151.    <Check> - check the scan against another character (see below).
  152.    <Halt>  - stop. You can restart where you left off by selecting
  153. <window->learn>,<window->Read> or <window->NonStop>. To start from the
  154. beginning select <window->New Box> then one of these.
  155.  
  156.   When the machine stops you can enter more than one character. It will
  157. learn or set these according to the mode, up to the end of the current line.
  158.   
  159.   In read mode the machine stops for instructions only when unsure.
  160.  
  161. LEARNING FROM FILE
  162.   If you have a text file of the text of a scan you can teach the font by
  163. setting the box and then dragging the file onto the window.
  164.   This is useful for teaching a printer font. The basic utility TestFile
  165. produces a suitable file. Print this and scan the result, then teach the
  166. font from the file. If you then read the scan you can judge the result using
  167. the compare utility provided.
  168.   The third basic utility provided can be used to display a count font on
  169. the screen, this is useful to check you have not made any mistakes teaching
  170. the font.
  171.    ADJUSTMENT
  172.           Six parameters control the operation of read. These can be
  173. adjusted from <window-adjust>.
  174.  "Space threshold" determines the number of black pixels in a character
  175. before read does not assume it is a space. Too large a value will cause full
  176. stops and other small characters to be read as spaces. Too large will slow
  177. read down and produce spurious small characters.
  178.  "Query threshold" determines when the machine stops in read mode. Larger
  179. values make it stop more often.
  180.  The other 4 determine the weighting given to various factors when read
  181. choses a character, adjusting these can lead to fewer errors. Leave one
  182. unchanged, as scaling them all by the same factor will have no effect.
  183.  One way to set them is to use the compare utility and a scan with a
  184. prepared correct text file.  
  185.  
  186. COMMAND LINE ARGUMENTS
  187.   Read accepts a number of command line arguments, separated by spaces, of
  188. the form -letternumber, with no spaces between the - letter and number.
  189.  letter  default                   
  190.    d        4    - scanner dpi 1,2 or 4 for 100,200,400dpi 
  191.    x       704   - scan width in pixels, this must be a multiple of 32
  192.                    between 32 and 1664/d
  193.    y      3200   - scan height in pixels
  194.    w       40    - grid width in characters
  195.    h       98    - grid height in lines
  196.    f      1638   - filetype of ReadFont files
  197.  
  198. E.g. If you change the last line in !Run to 
  199.     Run <Read$Dir>.!RunImage -h60 -f2989 you will get a grid height of 60
  200. lines and the ReadFont filetype will be 2989=BAD hex. You will need to
  201. change the 666 in !Boot to BAD and rename the sprite file_666 to file_BAD in
  202. !Sprites.
  203.  
  204.  
  205. DIFFICULTIES
  206.   Read does not cope well if lines are slanted or unevenly spaced.
  207.   It is quite difficult to scan a magazine page sufficiently accurately. I
  208. resorted to cutting out the pages. Small consistent slants can be coped with
  209. using <window->process->shear>, but unfortunately slants often vary down a
  210. column. This either requires rescanning or using several boxes and combining
  211. the results.
  212.   My first attempts at reading a printer font caused problems until I fount
  213. that the spacing of the first line was smaller than the rest. This was
  214. corrected by pulling the printer paper taught before starting to print.
  215.  
  216. TO DO
  217.      1) Improve the line finding routine to cope with slanted lines.
  218.      2) Implement 90 degree rotations to allow sideways scanning.
  219.      3) Reduce error rate?
  220.      4) Read proportionally spaced fonts??
  221.  
  222. COMMENTS PLEASE
  223.  
  224.   I would welcome bug reports, criticism (constructive or otherwise),
  225. modifications or suggestions for modifications.
  226.  
  227.                   Chris Stretch
  228.                                  Archive and Arcade BBS No.62
  229.                          CBTP13@JANET%UK.AC.ULSTER.UCVAX
  230.