Activity 08: Application of Morphological Operations - Preprocessing Text
Before the appearance of computers, or even typewriters, simple writing on a piece of paper was the one of the more primitive ways of writing something. Writing is representing words in a language into set of symbols (depending on which language or alphabet).
What is interesting is that each person has a unique way of writing thus hand-written texts by each person is different. Hand-writing, even today, is popularly used to identify a person. (like forgery)
In this activity, I tried to extract handwritten text from a scanned document. Note that sometimes, handwritings are very difficult to discern specially if the writing is "ugly".
The scanned image used was
Initial observation of the scanned image was that it was tilted. The image was therefore rotated accordingly to have the horizontal lines aligned properly. This was done using Gimp 2. The gridlines were used as reference. Though not the all the horizontal lines were corrected (specially the edges), the lines in the middle part were aligned properly.
For processing, a specific part of the image only were considered. The cropped image, which is the focus is shown below.
The first processing was the removal of horizontal lines. This was done using Fourier transform (FT), and masking the portions (horizontal and vertical) of the FT. Applying the inverse Fourier Transform,the new image was produced. To properly show the portions to be masked, the center was initially covered. The mask, absolute of FT, and the result are shown in the figure below.
Now, the image was binarized afterwards. The result was then inversed so that the text is white, and the background is black. Plotting the histogram of the image, the threshold was chosen accordingly (threshold=65%) and the image was binarized. This is shown in the image below.
After binarizing, multiple processing was done to the image to clean and enhance it. The opening morphological operation with a structure element of 2x4 was applied to remove isolated pixels. The closing morpholigical operation was then done to close gaps in letters. It was however noted that this was not enough, so the images were dilated first with a structure element of 2x5 and was eroded with the same struture element. The results are shown below.
It was noted that there were 69 clusters formed. However there were actually only 46. From this number, it can be deduced that some letter were disintegrated were were divided to several parts instead of only one.
The resulting extracted image was not that clear however it was noted that the words "cable", "VGA", and "USB" were discerable.
For this activity, I give myself a 10/10 for producing the result. I was able to clean the image as well as remove the horizontal lines. Some words were also discernable after processing compared to the original binarized image where it was not clear at all.
What is interesting is that each person has a unique way of writing thus hand-written texts by each person is different. Hand-writing, even today, is popularly used to identify a person. (like forgery)
In this activity, I tried to extract handwritten text from a scanned document. Note that sometimes, handwritings are very difficult to discern specially if the writing is "ugly".
The scanned image used was
![]() |
Scanned Image (with handwritings) |
For processing, a specific part of the image only were considered. The cropped image, which is the focus is shown below.
![]() |
Cropped image from original scanned image |
![]() |
Mask for the cropped image |
![]() |
FT modulus of the Image (with the center masked) to show other peaks |
![]() |
Resulting image after masking (removal of horizontal lines) |
![]() |
Inverse binarized image with threshold of 0.65 |
![]() |
Resulting images after applying different morphological operations (clockwise from upper left): close, dilate, dilate and erode, open |
The resulting extracted image was not that clear however it was noted that the words "cable", "VGA", and "USB" were discerable.
For this activity, I give myself a 10/10 for producing the result. I was able to clean the image as well as remove the horizontal lines. Some words were also discernable after processing compared to the original binarized image where it was not clear at all.
Comments
Post a Comment