Monday, August 11, 2008

Activity 10: Preprocessing Handwritten Text




After cropping a portion from the image above, the new image's Fourier Transform was determined.
im=imread('C:\Users\nez\Documents\tresloco\ap186_2\activity 10\a.jpg');
img = im2gray(im);
imgfft=fft2(img);
scf (1);
imshow(imgfft);
imwrite (imgfft, 'C:\Users\nez\Documents\tresloco\ap186_2\activity 10\imgray.jpg')

With the use of techniques learned from previous activities, the lines were removed using a filter just like the one below.

filter=imread('C:\Users\nez\Documents\tresloco\ap186_2\activity 10\f.jpg');

imf = im2gray(filter);

imffft=fftshift(imf);

imffft=ff1.*ff2; The image is then convolved with the filter, converted to binary, and cleaned using the closing/opening operator.

//filtering the image

a=real(fft2(imffft));

scf(2)imshow(a,[]);

imwrite (a, 'C:\Users\nez\Documents\tresloco\ap186_2\activity 10\imfilter.jpg')

//binarize the image

b=im2bw(a, 127/255);

c=1-b;

scf(3);imshow(c,[]);

imwrite (c, 'C:\Users\nez\Documents\tresloco\ap186_2\activity 10\imbinary.jpg')

//opening operation

SE = ones(2,2);

d=erode(c,SE);

e=dilate(d,SE)scf(4);

imshow(e,[]);

imwrite (e, 'C:\Users\nez\Documents\tresloco\ap186_2\activity 10\imcloseopen.jpg')


After this is done, the image is then labelled.
//labelling the image
imfinal=bwlabel(e);
scf(5);
imshow(imfinal,[]);
//imwrite (imfinal, 'C:\Users\nez\Documents\tresloco\ap186_2\activity 10\imlabel.jpg')


Grade: 6/10 - I passed it too late.
Acknowledgement: Jorge Presto

No comments: