The OCR Application
Once launched, the OCR application will display a simple GUI interface that will allow you both to train and use the neural network. This program is shown in Figure 7.1.

Figure 7.1: The OCR Application
Once stated, this program is not immediately ready to recognize letters. This program must first be trained from actual drawn letters before it is able to recognize your input. Letter training files are stored in the same directory as the OCR application. The name of the training sample is sample.dat. The OCR program contained on the CD-ROM for this book contains a ready-made sample.dat file.
The sample.dat file that is contained on the book's CD-ROM contains handwriting samples for the author of this book. If you use this sample.dat file to recognize your own handwriting your results may be worse than if you had created a training file based on your own handwriting. Creating a sample based on your own handwriting will be covered in the next section. For now you are probably anxious to see this program recognize handwriting, so we will begin by showing you how to do that.
To make use of the provided sample.dat file you should click the "Load" button on the OCR application. This will attempt to load a handwriting file named "sample.dat". You should see a small message box indicating that the file was loaded successfully. Now that the file has been loaded, you should see all of the letters listed that the program has been trained for. This example training file only contains entries for the capital versions of the 26 letters of the Latin alphabet.
Now that the letters have been loaded you must train the neural network. By clicking the "Train" button the application will begin the training process. The training process may take anywhere from a few seconds to several minutes, depending on the speed of your computer. Once training is complete, you will be shown a small message box that will state that training has completed.
Using the Sample Program to Recognize Letters
Now that you have a training set loaded and the neural network has been trained, you are ready to recognize characters. The user interface used to recognize the characters is very easy to use. You simply draw the character that you would like to be recognized in the large rectangular region labeled "Draw Letters Here". Once you have drawn the letter you can select several different options.
The letters that you draw are downsampled before they are recognized. This is because the letter that you have drawn is too high of a resolution to be understood by the neural network. By down sampling the image, the image is mapped into a small grid which is five pixels wide and seven pixels high. If you click the "Downsample" button you can see the downsampled version of your letter. Clicking the "Clear" button will cause the drawing and downsampled regions to be cleared.
You will also notice that a box is drawn around your letter when you down sample. This is a cropping box. The purpose of the cropping box is to cut out any white space that is not essential to the image. This also has the desirable effect of causing the program to not care about the position of the letter. You could draw the letter in the center, near the top, or some other location, and the program would still recognize the letter the same way.
If you would like to actually recognize a letter you should use the "Recognize" button. Drawing a letter to the letter input area and clicking the "Recognize" button will cause the application to downsample your letter and then attempt to recognize it using the Kohonen neural network. The advantage of downsampling to such a size is two fold. First, the lower resolution image requires fewer input neurons than would a full-sized image. Secondly, by downsampling everything to a constant size, it does not matter how large, or how small, you draw the image to be trained or recognized. By down sampling the image, the size is neutralized.
The pattern will then be presented to the Kohonen neural network and the winning neuron will be selected. Chapter 7 introduced you to Kohonen neural networks. If you recall from Chapter 7 a Kohonen neural network has several output neurons. One of these output neurons will be selected as a winner for each pattern of data that is entered. The number of output neurons that was chosen for the Kohonen neural network used by this program matches the number of letters that are in the sample set. Because there are 26 letters in the sample set, there will bee 26 output neurons.
The input the neural network comes from the down sampled image. The exact process for how the downsampled image will be presented to the neural network will be discussed in the next section. The program will respond to the letter you entered by telling you both which neuron fired, and also which letter the program believes that you have entered.
I have found that using my own handwriting that this program generally achieves approximately a 80-90% success rate. If the program is not recognizing your letters ensure that you are writing clear capital letters. You may also try training the neural network to recognize your own handwriting, as covered in the next section.
Training the Sample Program to Recognize Letters
You may find that the program does not recognize your handwriting as well as you think that it should. This could be because the program was trained using the author's own handwriting. Perhaps my handwriting is not representative of the entire population. My earlier grade school teaches would surely agree to that. In this section you will learn to train the network to recognize your own handwriting.
You have two choices as to how to train the neural network program. First, you can choose to start from a blank training set and enter all 26 letters for yourself. You can also choose to start from my training set. If you start from my training set you can replace individual letters. This would be a good approach if the network were recognizing most of your characters, but failing on a small set. You could retrain the neural network for the letters that the program was failing to understand.
To delete a letter that the training set already has listed you should select that letter and press the "Delete" button on the OCR application. Not that this is the GUI's "Delete" button and not the delete button on your computer's keyboard.
To add new letters to the training set you should draw your letter in the drawing input area. Once your letter is drawn you can click the "Add" button. This will prompt you for the actual letter that you just drew. What ever character you type for this prompt will be displayed to you when the OCR application recognizes the letter that you just drew.
Now that you have your training set complete you should save it. This is done by clicking the "Save" button on the OCR application. This will save the training set to the file "sample.dat". If you already have a file named sample.dat, it will be overwritten. Because of this it is important to make a copy of your previous training file if you would like to keep it. If you exit the OCR application without saving your training data, it will be lost. When you launch the OCR application again you can now click "Load" to retrieve the data you previously stored to the sample.dat file.
In the previous two sections you learned how to use the OCR application. As you can see it is adept at recognizing characters that you have entered. This demonstrates a good use of the Kohonen neural network. In the next section we will examine how this program was actually written.




