Recognition of Tifinaghe Characters Using Dynamic Programming & Neural Network

Optical Character Recognition (OCR) is one of the most successful applications of automatic pattern recognition. The field of characters recognition is very important. Several studies have been conducted on Latin, Arabic and Chinese characters (Bozinovic and Shihari, 1989; Brown, 1983; Fakir and Sodeyama, 1993; Fakir, 2001; Chaudhuri and al, 2002; Blumenstein and al, 2002; Miyazaki and al, 1974; Mezghani and al, 2008; Lallican and al, 2000; Burr, 1982) and various commercial applications have been produced such as bank cheque processing, postal automation, documents. However, for Amazigh characters, called Tifinaghe, few studies have been published in the literature. Among these researches, we find (El ayachi and Fakir, 2009; Amrouch et al, 2009; Es saady, 2009; Fakir et al, 2009; El ayachi et al, 2010). Because, characters are sensitive to noise the main problem in this field how to extracts strokes. This may be solved by the selection of the useful features customarily defined in the automatic character recognition as two types: global and local features. The principle of global features is based on the transformation of the character matrix into a new domain to extract features. The selection of local features is based on geometrical and topological properties of the character, such as strokes direction, strokes density, strokes length and position, etc. Unlike Latin characters, Tifinaghe characters are formed by loops, lines and curves. This makes it difficult to describe a character in one parametric form. In this study, invariant moments, modified invariant moments and Walsh transform are used as features for the recognition of Tifinaghe characters. Fig.1 illustrates the block diagram of the proposed recognition system. Tifinaghe texts were transferred to the computer through an image scanner. The process consists of three phases. After preliminary pre-processing of position normalization, noise reduction and skew correction), a text is segmented into lines and lines into what to be characters in the second phase. In the third phase features extraction methods are applied. In the last phase the recognition procedure is completed. In this phase a Multilayer Neural Network and Dynamic Programming Technique are used to classifier characters. These phases are described in the following sections, but before that a brief explanation about the characteristics of Tifinaghe characters is given.


Tifinaghe characters
The Tifinaghe script is used by approximately 20 million people who speak varieties of languages commonly called Berber or Amazigh. The three main varieties in Morocco are known as Tarifite, Tamazighe, and Tachelhite (El ayachi ). In Morocco, more than 40% of the population speaks Berber. In accordance with recent governmental decisions, the teaching of the Berber language, written in the Tifinaghe script, will be generalized and compulsory in Tifinaghe is an alphabetic writing system. It uses spaces to separate words and makes use of Western punctuation. The earliest variety of the Berber alphabet is Libyan. Two forms exist: a Western form and an Eastern form. The Western variety was used along the Mediterranean coast from Kabylia to Morocco and most probably to the Canary Islands. The Eastern variety, old Tifinaghe, is also called Libyan-Berber or old Tuareg. It contains signs not found in the Libyan variety and was used to transcribe Old Tuareg (El ayachi and Fakir, , rachidi, 2009). Historically, Berber texts did not have a fixed direction. Early inscriptions were written horizontally from left to right, from right to left, vertically (bottom to top, top to bottom); boustrophedon directionality was also known. Modern-day Berber script is most frequently written in horizontal lines from left to right; therefore the bidirectional class for Tifinaghe letters is specified as strong left to right. Displaying Berber texts in other directions can be accomplished by the use of directional over rides or by the use of higher level protocols. The encoding consists of four Tifinaghe character subsets: the basic set of the ″ Institut Royal de la Culture Amazighe (IRCAM) ″, the extended IRCAM set, other Neo-Tifinaghe letters in

Pre-processing
Pre-processing algorithms provides the required data suitable for further processing. In other words, it establishes the link between real word and recognition engine. Preprocessing steps consist of digitization of image document and cleaning it (by medium filter for example), converting the gray-scale image into binary image, normalizing the text (El ayachi et al, 2010), detecting and correcting baseline skew (Kayallieratou and al, 1999;Mnjunath et al, 2007), and segmenting (Casy et Lecolinet, 1996;Choisy et Belaid, 2002;Hadjar et Ingold, 2003) the text into lines and the lines into characters.

Normalization of the position
The position normalization is designed to eliminate unwanted areas and reduce the processing time. For this operation we use the histogram given by the following form: HistV pixel x y Where pixel(x, y), is the intensity of the pixel with the coordinates (x, y). In this operation, firstly, we compute the horizontal and vertical histograms, secondly, we scan the horizontal histogram in two directions: from top to bottom and bottom to top respectively until the first meeting of black pixels, finally, we scan the vertical histogram in two directions: from left to right and right to left respectively until the first meeting of black pixels. After obtaining the positions of first black pixels, unwanted areas are eliminated in the image as shown in (Fig. 3).

Baseline skew detection and correction
In many document analysis systems, printed material is scanned and stored as an image. It is later retrieved for character and graphics extraction and recognition. During the scanning process, the document may be skewed and the text lines in the image may not be strictly horizontal. The skew may cause problems in text baseline extraction and document layout structure analysis. Several methods have been developed by many researchers for skew angle detection. A skew angle is the angle that the text lines of the document image make with the horizontal direction. The skew correction is necessary for the success of many OCR systems. It consists of the extraction of the skew angle θs corresponding to baseline using Hough transform. The baseline is considered as the line corresponding to the maximum points in the horizontal projection profile. The skew angle θs is detected by observing high valued cell in the accumulative matrix in the Hough transform space. The image is then rotated by θs in the opposite direction so that the scripts become horizontal. Fig. 4(a) and Fig. 4(c) respectively show a text before and after baseline skew correction.

Segmentation
In this phase, the proposed OCR system detects individual text lines and then segments lines into characters. The lines of a text are segmented by using the horizontal histogram; we browse from top to bottom until the first line containing at least one black pixel, the line is the beginning of the first line of text, then we continue traverse until a line that contains only white pixels, this line corresponds to the end of the first line of text. With the same way, we continue to detect other text lines (Fig.5 a). The same principle is used in the vertical histogram to detect characters in each line of text ( Fig.5 b). www.intechopen.com

Features extraction
The next stage in the Tifinaghe character recognition is the feature extraction stage. Feature extraction represents the character image by a set of numerical features. These features are used by the classifier to classifier the data. In our work moments and other shape descriptors by Hu have been utilized to build the feature space. Using nonlinear combinations of geometric moments Hu derived a set of invariant moments which has the desired property of being invariant under image translation, scaling and rotation.
In addition to the invariant moments derived by Hu (Ibrahim, 2005), the modified invariant moments (Fakir and al, 2000), computed from the shape boundary for each character, and Walsh transform (Fazekas and Hajdu, 2001) are used as features.

Invariant moments
Let (,) f xy be 1 over a closed and bounded region R and 0 otherwise. Define the (,) p qt h moment as: The central moments can be expressed as The central moments are invariant to translation. They can also be normalized to be invariant to scaling change by the following formula. The quantities in equation (6) are called normalized central moments Invariant moments derived by Hu (Hu, 1962) were frequently used as features for shape recognition and were shown to be invariant to scaling, translation and rotation (Tables 2, 3

Modified Invariant Moments
In this phase features are extracted from the external contour of the character (Fig.6). In order to differentiate between the characters illustrated in Fig.7that The modified central moments are invariant to translation.
Theorem 1: For  pq defined in equation (9), is scaling invariant for p, q = 2, 3, … Proof: Suppose C is a smooth curve in the plane, C' is the curve obtained homogeneously by rescaling the coordinates by a factor r, then The quantity in equation (34) is invariant to a homogenous scaling. Theorem 2: Suppose C is a smooth curve in the plane and C' is the curve obtained by rotating C an angle  clockwise, then Where  ' i is defined as in equations (18, 19, 20, 21, 22, 23 and 24)

Walsh transform
The Walsh transformation is given by: Where () i bx is the ith bit in the binary expansion of x (it is equal either 0 or 1). Table 6 represents the seven first elements of the vector Walsh calculated for one character with four transformations. While Table 7

Characters recognition
In the character recognition system, the recognition is the last phase which is used to identify the segmented character. Where we use two techniques: the Neural Network (Hamza, 2008;Gu and al, 1983;Alnsour and Alzoubady, 2006;Asiri and Khorsheed, 2005) and Dynamic Programming (Sylvain and al, 2003).

Neural network
Characters are classified according to their computed features by means of artificial neural networks. Among the many applications that have been proposed for neural networks, character recognition has been one of the most successful. Many neural network architectures have been used in optical character recognition implementation. MLP is usually a common choice. Unfortunately, as the number of inputs and outputs grow, the MLP grows quickly and its training becomes very expensive. In addition, it is not easy to come up with a suitable network design and many trail-and-error cycles are required. The Neural Network (Fig.8)   The processing of Neural Network consists of five steps: Step 1. Initializing of weights connections The weights are randomly selected.

Step 2. inputs propagation
The inputs i E are presented to input layer:  ii XE . We propagate to hidden layer as follows After hidden layer, the output layer is given by where the values 0 X and 0 Y are scalars and f is the activation function given by Step 3. Error back propagation For each example of applied learning base input of the network, we calculate the error at output layers by the where k S desired output and k Z the actual output. In the next, we propagate this error on the hidden layer; the error of each neuron of the hidden layer is given by Step 4. Correction of connections weights We change the weights connections as follows  Between input layer and hidden layer:  Between hidden layer and output layer: and Where   (0 . 9 ) is the learning parameter determinate experimentally.
Step 5. (Loop) Loop in step two allows computing the error threshold (0.0001), and the number of terations (50000). After the learning of Network and the execution of Tifinaghe characters recognition system to recognize a text, we use the Euclidian distance to identify characters.
With, k t is a desired output and o is the output of Network.

Dynamic programming
Dynamic Programming was applied to speech recognition by Tappert et al 1982, by Sakoe andChiba, 1978 to recognize Latin character and by El ayachi and al, 2010 to recognize Tifinaghe characters. The Dynamic Programming strategy is a useful technique for the problem of optimization. It is often used to find the shortest path from one place to another and solve the comparative problem between two strings.
The operation of Dynamic Programming (for invariant moments) is based on the following steps: Step 1. Compute the matrix d between the vector of segmented character car V and each one of the Tifinaghe characters vectors ref V . The matrix d is given by: Where  ,1 , 2 , . . . , 7 xy Step 2. Calculate the optimal path from point (1,1) to point (,) xy by the following recursive relationship: Sxy is eva4luated on the area     1,7 * 1,7 that is browsed column by column or row by row starting from point (1,1) .
Step 3. Calculate the dissimilarity indices using the following form:

Experiments results
Experiments have been performed to test the above system. The developed Tifinaghe text recognition system has been tested on printed text. The system designed in Matlap for the recognition. The image to be tested is captured using a scanner. Before the recognition phase a database of 360 images is made. All tests are applied on 124 characters. The system is working fine and showing a good recognition rate (Table 8). It has been noticed that the extracted features of the images produced from segmentation module deviate a lot from the respective results in the training set. It seems that the resolution differences are affecting the geometric moments of the image, making them highly variant. It is expected that the recognition rate of the system can be improved by normalizing the training set as the characters that result after the segmentation phase. The system has been implemented on Intel (R) Core (TM) 2 Duo, CPU T5870 @ 2.00 Ghz, with a RAM: 2.00 Go.
The system is still under development.

Conclusion & perspectives
Two recognition methods based on neural network and dynamic programming has been presented. The system recognition consists of three phases including pre-processing, features extraction and recognition. The pre-processing includes position normalization, baseline skew correction and segmentation. The skew angle is determined by using Hough transform. The segmentation process consists of two steps: (a) segmentation of text into lines using horizontal histogram, (b) segmentation of lines into characters using vertical histogram. In features extraction phase a set of 7 invariant moments descriptors, 7 modified invariant moments descriptors and 7 Walsh coefficients have been used to represent the numerical features of the character extracted. Finally the numerical features are passed to the classifiers to recognize the character. The programs were written using Matlap. As mentioned previously, no efficient technique has been found for Tifinaghe scripts recognition. This field is of importance for future research.