Monday, August 3, 2009

Activity 10 - Preprocessing Text

In the last activity, morphological operations were used to help estimate the area of “cells.” In this activity, we apply morphological operations in conjunction with techniques involving Fourier Transforms to process text. A scanned image is provided for us, a copy of which is shown below.
























figure 1.

The task is to choose a portion of the text, remove the lines from the form, and extract the text. Line removal is easily handled by noting that in the FT, lines exhibit as bright spots along the x and y axis. We simply mask these frequencies to eliminate them. Note however that the image needs to be rotated in order for the lines to be horizontal and vertical. As we have learned from the FT exercises, the FT also rotates with the image. It would be more difficult to mask the frequencies if they lie at some small angle from the horizontal and vertical. Extraction is done by converting the image to black and white by proper thresholding. For example, the histogram of the grayscale might look like that in the following figure.


The portion that highly resembles a Gaussian is the background, the bright/near white portion of the image. We must set the threshold just to the left of where it begins (shown in arrow). Afterwards, we can fine tune the threshold by observing the resulting black an white image.


figure 2.

Cleaning needs to be done after isolation because some noise is inevitably carried over. I used erosion to remove small isolated points and dilated to bring back the original size. Then thinning is used to obtain one pixel thick characters.







figure 3.

The reconstruction of the letters was not very good.

The morphological operations that we have learned may also be used to rcognize certain words. We can use the process of isolation and thinning above to find instances of the word description in the document above. The entire document is binarized and then the thinned version of description is used as the eroding element for the document. At the location where the thinned version is exactly contained within the word, we get a white point. Elsewhere, we get black.







figure 4. Click to see a bigger version


Rating: I accomplished everything that is asked for. But I am not satisfied with my reconstruction of the letters. So I rate my work 9.

1 comments:

  1. You did something unique with the word recognition part and i think the recovered letters are not bad. For this you deserve a 10.

    ReplyDelete