You are on page 1of 8

International Journal of Computer Information Systems, Vol. 3, No.

3, 2011

Character Extraction Algorithm for Handwritten Character Recognition Systems


B.T.G.S. Kumara
Department of Computing and Information Systems, Faculty of Applied Sciences, Sabaragamuwa University of Sri Lanka
kumara@sab.ac.lk

W.R.Y.S. Samarasekara
Department of Physical Sciences & Technology, Faculty of Applied Science, Sabaragamuwa University of Sri Lanka
butterfan2006@gmail.com

Abstract The research work presented in this paper aims to provide algorithm for extracting characters from a document. This is the first part of a character recognition system. There are so many algorithms were implemented to extract characters from a documents. To extract characters Image Processing techniques were used. Multilevel threshold was one of them. Algorithm was written using JAVA language. Characters were able to extract from this algorithm. Keywords HCR- Handwritten Character Recognition, HR Handwritten Recognition, pixels, Threshold

recognize character of a document first it should be extracted from the document. To extract characters from a document so many algorithms were implemented. This research work aimed to implement a character extraction algorithm. II PROBLEM DEFINITION

INTRODUCTION

Writing is one medium of communication and it has a long history. After man discovered the paper, they used paper to write and store useful data. After man discovers the computer, they used to store data in the computer. But still in today world people use paper to write and keep information because writing and storing is the most simple and most reliable way. Handwriting is different from person to person. Modern science also discovers that handwriting reviles the characteristics of a person. Handwritten character recognition (HCR) is the ability of a computer to receive and interpret intelligible handwritten input from sources such as paper documents, photographs, touch-screens and other devices. The image of the written text may be sensed "off line" from a piece of paper by optical scanning (optical character recognition) or intelligent word recognition. Alternatively, the movements of the pen tip may be sensed "on line", for example by a pen-based computer screen surface. Handwritten recognition (HR) principally entails optical character recognition. However, a complete HR system also handles formatting, performs correct segmentation into characters and finds the most plausible words. With introducing neural networks, handwriting recognition now becomes more accurate and precise. To

Handwriting is different from person to person. Also the handwriting of the same person is changing due to the state of mind. Same persons speed handwriting is bit differ than usual. And the worst case of the difference is some persons handwriting is not clear and reading difficulties are occurring. Differentiation can be notice from the following fig 1 that the tale of the handwritten letter is long but in the printed letter it is same with as top. HR is harder than recognizing a printed letter. Developing an algorithm to extract handwritten character is one of the hardest challenges parts of the character recognition system.

Fig 1 Difference between handwritten character and printed character

Special Issue I

Page 1 of 55

ISSN 2229 5208

International Journal of Computer Information Systems, Vol. 3, No. 3, 2011 III METHODS AND MATERIALS In the following fig 2 the two dimension matrix of handwritten letter M is displayed. It clearly identifies the different parts of the letter. Because it has different layers or areas in the letter and can easily detect the current manipulation points. The elimination of the coordinate values that are unnecessary to the algorithm was done by the using logics between transformation coordinate values from one list to another list. The parameter coordinates was taken by the algorithm. The following fig 3 shows written letter u. It can be identified clearly with the coordinates (65,313); each of the rows of pixel in the letter has maximum X value and the minimum X value. By considering a row between those two points is the area of spreading of the letter. By considering all the rows or the entire y coordinates that spread the letter, it becomes the area of spreading of the letter.

Image processing techniques were used to extract characters from a document. Algorithm was implemented based on image segmentation techniques. A. Image Threshold Threshold is the simplest method of image segmentation. During the threshold process, individual pixels in an image are marked as "object" pixels if their value is greater than some threshold value (assuming an object to be brighter than the background) and as "background" pixels otherwise. This convention is known as threshold above. Variants include threshold below, which is opposite of threshold above; threshold inside, where a pixel is labelled "object" if its value is between two thresholds; and threshold outside, which is the opposite of threshold inside. Typically, an object pixel is given a value of 1 while a background pixel is given a value of 0. Finally, a binary image is created by colouring each pixel white or black, depending on a pixel's labels. For this study multiple level thresholds were used and it can identify the areas of a letter more easily. And it helps for development of the algorithm of virtual head cutting by facilitating easy detection of head movement if the head move into the letter other than head move on the border.

Fig 2 Two dimension matrix of handwritten letter M Two dimension matrix of handwritten letter M

Special Issue I

Page 2 of 55

ISSN 2229 5208

International Journal of Computer Information Systems, Vol. 3, No. 3, 2011

Fig 3 Two dimension matrix of handwritten letter U with border value

The flowing fig 4 shows each minimum and maximum coordinate point in read blocks of the each row. B. Character (object) extraction algorithm Not like printed letters the nature of the handwritten letter is slightly changing even for one letter. The hardness of it was already highlighted on above. The basic idea of the algorithm is a virtual head that throws the coordinates of the pixel when the head is found the border of the character. The head is move on to the border while it throws the coordinates. So the coordinates of the border of each character is thrown by this head. Two kinds of coordinates are throwing by this head. One coordinate is thrown by going down from the left border of the object/character. The other one is the coordinates throwing by going up from the left border of the character. The starting point of going up is depending on the nature of the letter as well as nature of the border. Even for the same kind of letter, the point is changeable.

The following fig 5 present two types of handwritten letter s that was written by the same user. The red line indicate the path of the head that gone upward and blue indicate the path that the head gone to down. The reason for the difference is the one more pixels length of the second s tale respect to the top. That is indicated by the green arrow. The green symbol shows the starting points of the two coordinate lists. When the head projected on the line that indicated by green, in the first figure it is first touch at the upper part of the character S but in the second one it is not touched the upper part so that difference make the difference of the starting point. Likewise letter to letter the starting point changes according to the nature of letter. By adding two coordinate lists together the boarder of the full letter is created. After that the spreading area is taking according to the method indicated above and makes an array for the each letter by grabbing the pixel values according the total coordinate list, and then throws the output of image object.

Fig 4 Two dimension matrix of handwritten letter U with minimum and maximum coordinate points

Special Issue I

Page 3 of 55

ISSN 2229 5208

International Journal of Computer Information Systems, Vol. 3, No. 3, 2011

Fig 5 Two dimension matrix of two types of handwritten letter S

IV

PROGRAMMING LANGUAGE AND ALGORITHMS If (pixel at (x-1, y) not on object && pixel at (x, y+1) not on object && pixel at (x+1, y) not on object) then, Activate right corner left access. (rCLAc=1) If (pixel at (x, y-1) on object && head goes up) then go to left pixel Else {go head one pixel down to coordinate(x, y+1)} If (left in fix enable) then {Activate left corner right access & disable left corner top access} Else {activate left corner top access} If (down fix is enabled) then {Activate right corner top access & disable right corner left access}

This letter cutting algorithm is consisting of 8 main parts. The main loop of the algorithm While (x coordinate<X end Border && y coordinate<=y end border&& y coordinate >=the beginning y coordinate) { //The current pixel is consider as x, y in this document //part one (main situation one)

If (pixel at (x-1, y) on object && pixel at (x+1, y) on object If (right down fix is enabled && head goes up && pixel && pixel at (x, y+1) on object) then, at (x+1, y-1) not on object) then If (pixel at (x+1, y-1) not on object && pixel at (x+2, y-1) {Start down head movement} not on object) then Move current point to 8 naber (x+1, y-1) // part three (main situation three) Else if (pixel at (x+1, y-1) on object) then drive head back (head goes up) Else if (pixel at (x+1, y-1) not on object) then drive head If (pixel at (x-1, y) on object && pixel at (x, y+1) not on object && pixel at (x+1, y) not on object) then, back (head goes up) and one pixel left [(x, y-1) then (x+, If (pixel at (x, y-1) on object && head goes up) then, y-1) [While (pixel at (x-1, y) on object) => go to one While (pixel at (x, y) on object && pixel at (x+1, y) on pixel down// go head down until pixel at (x-1, y) on object && y coordinate<=y end border&& y object] coordinate >=the beginning y coordinate) Go to left pixel {Go left pixel, Activate left corner right access} Else {go to down pixel} //Disable down fix, Enable left corner top access, disable left //part two (main situation two) corner right access If (pixel at (x-2, y) not on object && pixel at (x-2, y-1) not on object) then enable dot fix

Special Issue I

Page 4 of 55

ISSN 2229 5208

International Journal of Computer Information Systems, Vol. 3, No. 3, 2011 [For(x++) until cove switch value reach; if(pixel at (x,y) on object) then enable left right cove(lftRCove=1);] if(left right cove desabled )// lftRCove=0 Then break; Enable down fix; ] Disable leftwrite cove (lftRCove=0); disable left bottom point (lftBP=0); //part six (main situation six) If (pixel at (x-1, y) on object && pixel at (x, y+1) on object && pixel at (x-1, y) not on object) then, If (left corner top access enabled) then go to right pixel Else if (left corner right access enabled) then, If (head goes down)// vDrive>0 then Go one pixel up(x, y-1); start to go up word Else {go one pixel up(x, y-1)} If (left in fix enabled) then go to left pixel(x-1, y) If (current x coordinate>maximum x coordinate) then update the maximum x coordinate to current x coordinate // check column // part seven (main situation seven) If (pixel at (x-1,y) on object && pixel at (x,y+1) not on object && pixel at (x+1,y) on object) then, Go one pixel down(x, y+1)/up(x, y+1) //follow the initial direction If (head goes up && pixel at (x+1, y) on object) the go to right pixel(x+1, y) // part eight (main situation eight) If (pixel at (x-1, y) not on object && pixel at (x, y+1) on object && pixel at (x+1, y) on object) then, If (right corner left access enabled) then, If (head goes down) then, If (pixel at (x, y-1) on object) then go to left pixel(x-1, y) Else go one pixel up(x, y-1) Start to go up (-1) Else if (head goes up) then, If (pixel at (x, y-1) on object) then go to left pixel(x-1, y) Else go one pixel up(x, y-1) If (pixel at (x-1, y) not on object && pixel at (x, y+1) not on object && pixel at (x+1, y) not on object && pixel at (x+1, y-1) not on object) then go to right pixel(x+1, y) Else if (right corner top access enabled) then,// rCTAc==1 While (pixel at (x, y+1) on object && y coordinate<=y end border&& y coordinate >=the

[While (pixel at (x-1, y+/-1) not on object && dot fix disabled && y coordinate<=y end border&& y coordinate >=the beginning y coordinate) then, For(y=y+1) //until pixel at (x, y) < cove switch value and left to right cove disabled Then, If (pixel at (x, y) on object) then enable left to right cove If (left to right cove disabled) then break; go to right pixel; enable left corner right access; go one pixel down] //Disable left right cove; disable dot fix; // dot fix is solution for behavior when head find a dot If (current x coordinate>maximum x coordinate) then update the maximum x coordinate to current x coordinate // check column // part four (main situation four) If (pixel at (x-1, y) on object && pixel at (x, y+1) not on object && pixel at (x+1, y) on object) then, Enable right corner left access; disable left corner top access; disable right corner top access; If (pixel at (x+1, y+1) not on object) then enable right down fix If (left in fix enabled) then go to left pixel(x-1, y) else go to right pixel(x+1, y) // part five (main situation five) If (pixel at (x-1, y) not on object && pixel at (x, y+1) not on object && pixel at (x+1,y) on object) then, Disable right corner left access; enable right corner top access; enable letter detect; enable down fix; If (pixel at (x+1, y-1) not on object && head goes up) then, Enable right cornet left access; go to right pixel(x+1, y); go to one pixel up(x, y-1); start to go down word (+1); Else { If (pixel at (x, y-1) on object && head goes up (-1)) then go to left pixel(x-1, y) Else {go one pixel down/up // continue current travelling direction} If (head goes down (+1)) then, [While (pixel at (x+1, y-1/+1) not on object && pixel at (x, y-1/+1) not on object && y coordinate<=y end border&& y coordinate >=the beginning y coordinate) then, Go to right pixel(x+1, y); go to one pixel down(x, y+1) enable left in fix; //variable If(left bottom point disabled) then, enable left bottom point; add y coordinate to cove switch(coveSwitch=coveSwitch+y)

Special Issue I

Page 5 of 55

ISSN 2229 5208

International Journal of Computer Information Systems, Vol. 3, No. 3, 2011 beginning y coordinate) => go to left pixel(x-1, y), enable left corner right access (lCRAc=1) } As the programming language Java was used. Net Beans IDE 7.0/70.1 was the Enhancing Tool. V RESULTS AND DISCUSSION 1) Adapting the algorithm to row system When adapting an algorithm that can extract characters in a row to the full a row system two things must be done. Avoid the parts of the letters that are coming by the upper row and adding the parts of the letters those cuts buy the row. Avoiding the parts of the letter must do by carefully developing the algorithm to avoid creating extra errors in the algorithm because of the row. The adding parts can be done by extending the lower boundary of the letter before cutting the letter. But to done those things it must has a flexible and accurate row detecting system. So the first step is creating a good row detection system.

Algorithm was run on Intel(R) Core(TM) i5 CPU , M 430 @ 2.27GHz, 2267 MHz, 2 Core(s), 4 Logical Processor(s) system with 4 GB RAM and Windows 7 Home premium(sp1) operating system and core 2 Duo 2.8 GHz system with 2GB RAM and windows vista operating system. Individual characters could be extracted as the final output of the research. Following fig 6 shows the sample output of the algorithm. A. Problems occurred during the creation of algorithm 1) Finding rows A row can be easily detected by checking whether each row contain lower level of pixels and getting the coordinates of the image when found higher level pixels after the lower level of pixels. The major problem in finding rows is the row space is covering by the letter, like in the following fig 7. In the figure it shows that the down part of the g is covers the enter row with the upper part of the letter f. Also when considering the pixel density of the letter g, the down part of the letter also have considerable amount of pixels. So even when the codes written for penetrate the letter down part is again taken as another row. The solution is getting small portions but large number of portions and predicts the average row. But the coding must facilitate or maintain its efficiency when a short row is detected. Obviously the size of the pixels of the portion often becomes 0 when short row meets.

2) Coordinates repeating problem The virtual head usually starts to throw the coordinates from left side. And also it is usually starts by going down on the left border of the character. The direction is always down until algorithm finds the logic to go up on the left border. Until that the head goes repeatedly down from meeting point of the border of the character. So the turn before algorithm grabs an upper travelling logic is the final down travelling coordinate list given by moving the virtual head. That list was saved by considering the next list and the previous list generated by the head. So the repeated problem is solved for the algorithm but uneasily generation of the list still happens. And that may cause to reduce the efficiency of utilizing resources. The below fig 8 demonstrates the problem. The blue arrows show the downward starting points and the red one shows the beginning of upward starting point.

Fig 6 Sample output

Special Issue I

Page 6 of 55

ISSN 2229 5208

International Journal of Computer Information Systems, Vol. 3, No. 3, 2011

Fig 7 Handwritten document

Fig 8 Handwritten character matrix for demonstrate Coordinates repeating problem

VI

CONCLUSIONS Coordinates repeating problem was end up with two lists. Character (object) extraction algorithm was used and problem was solved up with a feasible solution. This algorithm can be further developed and used for HCR systems with accurate results.

To recognize characters of a document first it should be extracted from the document. To extract characters from a document so many algorithms were implemented. This research work aimed to implement a character extraction algorithm. Image processing techniques were used to extract characters from a document. Algorithm was implemented based on image segmentation techniques such as Image threshold. Some problems occurred during the creation of algorithm. Finding rows problem was solved by getting small portions but large number of portions and predicts the average row. Adapting the algorithm to row system can be resolved by creating a good row detection system.

Special Issue I

Page 7 of 55

ISSN 2229 5208

International Journal of Computer Information Systems, Vol. 3, No. 3, 2011 REFERENCES [1] Bar-Yosef, I., Beckman, I., Kedem K., and Dinstein I.:Binarization, character extraction, and writer identification of historical Hebrew calligraphy documents, IJDAR. [2] Gonzalez R.C., and Woods R.E.: Digital Image Processing, Addison-Wesley, 2002. [3] Alata M., and Al-Shabi M.:Text Detection and Character Recognition using Fuzzy Image Processing, Journal of electrical engineering, VOL. 57, NO. 5, 2006, 258267. [4] Mizukami Y.:A handwritten Chinese character recognition system using hierarchical displacement extraction based on directional features, Pattern Recognition Letters Volume 19, Issue 7, May 1998, Pages 595-604 . [5] Al-Badr, B., Haralick, R.M..: A segmentation-free approach to text recognition with application to Arabic text, IJDAR 1(3), 147166 (1998). [6] Bar-Yosef, I.:Input sensitive thresholding for ancient Hebrew manuscript. Pattern Recognit. Lett. 26, 11681173 (2005). [7] Zhuang, Y., Zhang, X., Wu, J., Lu, X.: Retrieval of Chinese calligraphic character image. In: 5th Pacific Rim Conference on Multimedia, Tokyo, Japan. pp. 1724. Part I, (2004)

AUTHORS PROFILE Mr.B.T.G.S. Kumara received his M.Sc. degree from University of Peradeniya, Sri Lanka, in 2010 and B.Sc degree from Sabaragamuwa University of Sri Lanka, In 2006. This author is currently working as a lecturer in computer science in department of Computing and Information Systems, Sabaragamuwa University of Sri Lanka.

Mr.W.R.Y.S. Samarasekara is an undergraduate of Sabaragamuwa University of Sri Lanka.. This Author is following B.Sc special degree programme in Computer Science and Technology.

Special Issue I

Page 8 of 55

ISSN 2229 5208

You might also like