Wednesday, August 22, 2012

Pre-processing Text using Morphological Operations

Shown below is an image of a scanned receipt. 




A portion of this receipt which contains the handwritten part is cropped. This cropped image is then used for image processing.

Cropped portion of the scanned receipt

The image is converted to grayscale and then to black and white at a threshold of 0.4.
Black and white conversion of the cropped image

Using the imcomplement function of Scilab, the 1's and 0's were inverted so that the value of the handwritten part are now 1's.

Inverted image

In order to get rid of the lines, a mask has been used. The zero values in the mask are determined by the pixel location of the lines. This was done manually. The pixel locations were determined by using Paint.

Mask Filter
After applying the mask filter, a cleaner image was produced.


However, due to the mask filter, the writings look cut. To connect the lines, morphological operations were applied. The first morphological operation applied was the Close operation. The result of which is shown below.

Structuring Element for the Close Operation
Resulting image after the Close Operation
Another morphological operation, the dilation, was also applied after the close operation to connect the remaining broken lines.

Resulting image after dilation
So far, this is the best image I can process. As you can see, the word VGA is already quite readable.

I have applied a combination of techniques learned in class just to process the image right. Unfortunately, I still haven't come up with the correct techniques to correctly produce the expected image.

For this activity, I give myself 8 out of 10. :)

No comments:

Post a Comment