Tuesday, July 22, 2008

A10: Preprocessing HandwrittenText

First, we to sample from the larger image such that details are focused on the texts. By doing so,we can remove unwanted informations by blocking their frequency. The figure below is the original sampled image.Figure 1 sample cropped image

The filter used is designed based from the information obtained from the fft of the image above.

Figure 2 FFT of the sample image

The maximums along the vertical should be blocked to remove the horizontal lines in the original image. But the center should be excluded. The figure below is the filter designed for this particular sample.

Figure 3 Designed filter

After filtering the image by convolution in the Fourier space, the inverse fft will now be the new image to be binarized. The threshold is predetermined using GIMP.

Figure 4 Inverse fft'd image

The image above is binarized and using some erosion and dilation, the unwanted geometries are removed. The resulting binary (thresholded) image, and reconstructed image and labeled image are shown in below.
a.) binary image
b. reconstructed image

c. labeled image


Rating: Based from the reconstructions I've done, no significant enhancement is observed.But, the results have small deviations from the original image. I am confident that I did well in the activity except regarding thereadability so I'll give myself 10.0points.

Code:
im=imread('C:\Documents and Settings\gpedemonte\Desktop\text.bmp');
imf=imread('C:\Documents and Settings\gpedemonte\Desktop\filter4.bmp');

ft1=fft2(im);
ft2=fftshift(imf);
imft=ft1.*ft2;

im3=real(fft2(imft));
scf(1);
imshow(im3,[]);
im4=im2bw(im3, 115/255);
scf(2);
imshow(im4,[]);
//
m=[1 1]
////
im5=erode(im4,m);
scf(3);
imshow(im5,[]);

im6=bwlabel(im5);
scf(4);
imshow(im6,[]);

No comments: