Activity10: Preprocessing of Handwritten Text
The goal of this activity is to pre-process handwritten text for image processing. The original image I used is
with probability distribution
and 2d fft
We used a vertical mask in manipulating our fft to remove the horizontal lines.The processed fft is:
However, the lines were not removed but merely blurred out. This was not the case in activity 7.
The resulting binarized image is shown below.
The opening operation was used but without much success. We did not use the closing operation since we want to retain the holes of the letters, which is a property of the letters.
Code as follows:
chdir(“/home/jeric/Desktop/ap18645activity10”);
clear all;
getf(“imhist.sce”);
im=imread(“ac10.jpg”);
im=im2gray(im);
if max(im)<=255
im=round(im*255);
end
[val,num]=imhist(im);
h=scf(1);
plot(val, num);
ff=fftshift(fft2(im));
h=scf(2);
imshow(abs(ff), []); xset(“colormap”, hotcolormap(64));
[x,y]=size(im);
newff=ff(:,:);
filter=ones(x,y);
for j=y/2–2:y/2+2
for i=1:x/2–2
filter(i,j)=0;
end
for i=x/2+ 2 : x
filter(i,j)=0;
end
end
newff=filter.*ff;
h=scf(3);
imshow(abs(newff), []); xset(“colormap”, hotcolormap(64));
h=scf(4);
im2=abs(fft2(newff));
imshow(abs(fft2(newff)), []);
im=im2bw(im, 160/255);
h=scf(5);
imshow(im, []);
se=ones(2,2); //structuring element
im=erode(im, se); //opening
im=dilate(im, se);
im=erode(im, se); //opening
im=dilate(im, se);
[L,n]=bwlabel(im);
h=scf(6);
imshow(im, []); //preprocessed image
Rating: 6, because of the poor resulting image. The goal was not achieved.
Jing said,
July 29, 2008 at 7:02 pm
Hi Jeric,
When using morphological operations try to remember that the blob of interest should be in white and background should be black. Your opening operations worked on the white sections that’s why instead of removing them, it further enhanced the horizontal lines.