Raw image |
After binarizing the cropped area, we erode it with horizontal structuring element. This must be longer than the length of one letter in the text, but it must be short enough so that the slight tilt of the lines would not pose a problem.
From the dilation, we get an image containing only the horizontal lines. Inverting this gives us a filter that is zero only on these lines. Multiplying this filter with the binarized image isolates the text. As a final step, we thin the image to make the letters one pixel thick simply by applying thin(Im).
(left) cropped are (middle) binarized image (right) isolated text |
Plus, since this code deletes all horizontal lines, it would erase part of the text if the text happened to intersect a horizontal line. This can be remedied a little by dilation of a short vertical structuring element.
Here's the code that takes the cropped picture and isolates the text. :)
Since I was successfully able to do the required task, I give myself a grade of 10/10.