Genetic Algorithms for Perceptual Codes Extraction

In this work a new technique for global perceptual codes (GPCs) extraction using genetic algorithms (GA) is presented. GAs are employed to extract the GPCs in order to reduce the original number of features and to provide meaningful representations of the original data. In this technique the GPCs are build from a certain combination of elementary perceptual codes (EPCs) which are provided by the Beta-elliptic model for the generation of complex handwriting movements. Indeed, in this model each script is modelled by a set of elliptic arcs. We associate to each arc an EPC. In the proposed technique we defined four types of EPCs. The GPCs can be formed by many possible combinations of EPCs depending on their number and types. So that, the problem of choosing the right combination for each GPC can be regarded as a global optimization problem which is treated in this work using the GAs. Several simulation examples are presented to evaluate the interest and the efficiency of the proposed technique.


Introduction
Since the appearance of the computer, humankind has always tried to give this machine the similar behavior.He wanted to make it capable to read and to understand automatically the handwriting.In order to do this task, it is important to study the manner that we do it.The studies of psychologists try to have answers to these questions: How we can read and recognize words?How can the reader pass from a set of features and curves to letters and words?What are the detected primitives during the process of reading?
Handwriting was developed a long time ago as a manner to expand human memory and to facilitate communication [1,2].Human are similar, they have a common education but they produce a different handwritten styles.Because written language is important, the understanding of handwriting is important too.So far, several theories and models have been proposed to study and to analyze handwriting [3][4][5][6].
Reading a word is recognizing it.So, word recognition implies the process of visual information, and its representation at the linguistic level.Psychologists call lexical access the process by which human associate the image of the word with its meaning.Most lexical access models take into account the orthographic (the way the word is written) and the phonological aspects (the way the word is pronounced) of the word [7,8].Several reading and writing models have been developed: Pandemonium model (Selfridge, 1959): this model is hierarchically composed of three levels containing respectively: feature demons, cognitive demons and decision demons.These ones operate in parallel way.In order to recognize a pattern, demons of the different levels are activated [9][10].
Logogen model (Morton, 1969): it associates at every logogen a threshold indicating the necessary activation level to recognize the word partner [9,10].
Interactive Activation model (McClelland and Rumelhart, 1981): in this model, a connexion's architecture of three layers (primitive, letters and words), is hierarchically organized.The necessary time needed to recognize one letter in a word is less than a time needed to recognize letter in isolation position [8][9][10].
Marr's model (Marr 1981): According to Marr: "Vision can be understood as an information processing task which converts a numerical image representation into a symbolic shape-oriented representation" [8,9,11].
In this paper, we present a new perceptual model which is inspired from the McClelland and Rumelhart's reading model of the human system [12].The underlying idea is derived from studies of reading systems.In the following section, we describe the proposed model.First of all, we present the architecture and the steps which compose this earlier.In section two we define the Betaelliptic model for the generation of complex handwriting movements.Based on this previous model, an Elemen-tary Perceptual Codes (EPC) extractor is established which is described in the third section.Forth section presents the Global Perceptual Codes (GPC) extractor using genetic algorithms.In the last section we present the experiments made to test the performance of the developed system.Finally, we present some conclusions and further works.

The Proposed Perceptual Model
The proposed model is interested to online handwriting.The scripter writes on a digitizing tablet using a special stylus.So that the user's written scripts are captured as they are being formed by sampling the pen's (x,y) coordinates at eventually spaced time intervals.The acquired handwriting data are pre-processed.After that we use the Beta elliptic model for the generation of handwriting movements; in this step we obtain a matrix of parameters which are used in the third step to extract the elementary perceptual codes: the representation of a character is made of four basic strokes, and a handwritten character is generated by a combination of several strokes [13].In the last stage, we use genetic algorithms to extract the global perceptual codes which are the combinations of different EPCs sets.
The architecture of our proposed model is shown in the following figure (Figure 1).Step 1: the pre-processing of handwriting is done to have the best representation of input data.The other steps will be described in the following part.

The Beta-Elliptic Model for the Generation of Complex Handwriting Movements
The beta-elliptic model is based on some assumptions: Firstly, it considers that handwriting movement, like any other highly skilled motor process, is partially programmed in advance.Secondly, it supposes that movements are represented and planned in the velocity domain since the most widely accepted invariant in movement generation is the beta function of the velocity profiles.In its simplest form, the model is based on the beta equation where t 0 is the starting time, t 1 is the ending time, p and q are intermediate parameters, as shown in Equation (1).This equation describes the velocity profile in the kinematics domain which is in turn represented by an elliptic arc that characterizes the trajectory in the static domain [14][15][16][17].
The curvilinear velocity is given by this equation: The Beta-parameters (t c , = t 1 − t c , p, q, H: Beta amplitude) are presented in the Figure 2.
The elliptic-parameters (x 0 , y 0 , a, b, θ) describe the static aspect of the handwriting movement; a: large axe of ellipse, b: small axe of ellipse, and x 0 and y 0 correspond to the coordinates of the ellipse centre O.The deviation angle θ is formed by the ellipse and the horizontal axe, and it is obtained by the Equation (4) [16][17][18].Then for each ellipse arc we have ten parameters (t, p, q, t 0 , t 1 , a, b, x 0 , y 0 , θ).
For each elementary perceptual code we affected three variables which are: the code, the type (Shaft, valley, Left oblique shaft and right oblique shaft) and the symbol (see Table 1).These codes are used later to codify handwritten scripts generated by the Beta-elliptic model.

Extraction of Elementary Perceptual Codes
Basing on the Beta-elliptic model for the generation of handwriting, each script is modeled by a series of elliptic arcs.Each elliptic arc will be coded by a set of five parameters (respectively: a, b, x 0 , y 0 and θ).With these parameters help, each script will be represented by a set of strokes.The representation of a character is made by four basic strokes, and a handwritten character was generated by a combination of several strokes [13].
Depending on the ellipse deviation angle θ from the horizontal, we subdivided the trigonometric circle into eight equidistant intervals of length π/4.Assuming the trigonometric sense, we defined a positive part going from 0 to π and a negative part going from 0 to −π.According to the orientation of ellipses we have identified four types of strokes (see Figure 4).Each stroke has the opportunity to belong to two separate intervals.The first is the positive part of the trigonometric circle and the second is the negative part.The stroke number two (Valley), belongs to two intervals containing each one a positive and a negative part.It takes into account both sides of the trigonometric circle (positive and negative) to indicate the direction of writing which is consistent with the trigonometric direction.The direction of writing gives us the obligation to use two intervals (one in the negative part of the trigonometric circle and the other in the positive part) for each stroke.This test provides a contribution to our model compared to the method of Freeman giving discreet orientation for the entire strokes forming the script and other models that do not take into account the direction of the writing.These strokes still called elementary perceptual codes (EPC).The letter ‫"س"‬ generated by elementary perceptual codes (see Figure 5(a)) is composed by only one segment i.e. the writer wrote this script without lifting pen.It is noted in the table below (see Figure 5(b)) that the number of lines in the matrix of EPCs is proportional to the number of segments making the script.The number of columns of the matrix of EPCs indicates the number of elementary perceptual codes making the letter ‫."س"‬ Then each element of the matrix indicates the corresponded code of the EPC.In our case the letter ‫"س"‬ is composed of twenty two EPCs.The first segment of the letter "D" is composed by 4 EPCs and the second is composed by nine EPCs.
Relying on human vision we can not detect the elementary perceptual codes but we detect more general features.The idea is to find a method for detecting global features that constitute the script after gathering a number of elementary perceptual codes following basic criteria.In our model we define a set of global features.These features are called global perceptual codes (GPC).

Extraction of Global Perceptual Codes
In our model ten global perceptual codes GPCs are defined varying from the shaft to the ain and different possibilities of combinations which differ in type and length.The following table (see Table 2) presents the GPCs with their different types, numbers, symbols and a few    A set of GPCs can define the characteristic properties of the symbols to be recognized and at the same time make it possible to form a linguistic definition of a character or a word in a coded form.GPCs extraction is also sometimes termed as data reduction, since it extracts the required information from a huge amount of data and thus reduces the processing time considerably if we compare to the case when we use only the EPCs to define the characteristic properties of the symbols to be recognized.Considering the important variability of the matrix length of the EPC which forms an unspecified GPC and also the great number of possible combinations of the EPCs associated with each GPC, we cannot use a deterministic optimization method for the choice of the best combination of the EPC and the fixing length of their matrix.Consequently, we propose the genetic algorithms (GAs) as an indeterminist optimization technique.
The Figure 8 presents the architecture of the proposed global perceptual codes extractor based on genetic algorithms.Indeed, for each GPC we have developed a genetic algorithm.Each one treats a matrix of elementary perceptual codes and generates a set of GPCs forming the initial script.The generated GPCs may contain redundancies (i.e.GPCs that have the same location in the script) or overlaps between some of them.To resolve theses problems we have proposed a refinement stage.

Genetic Algorithms
Genetic algorithms are a family of computational models inspired by evolution.These algorithms encode a potential solution to a specific problem on a single chromosome and apply recombination operators to them so as to preserve critical information.GAs are often viewed as function optimizers, although the range of problems to which GAs have been applied is quite broad.The major reason for GAs popularity in various search and optimization problems is its global perspective, wide spread applicability and inherent parallelism.GA starts with a number of solutions known as population.These solutions are represented using a string coding of fixed length.After evaluating each chromosome using a fitness function and assigning a fitness value, three different operators-selection, crossover and mutation-are applied to update the population.An iteration of these three operators is known as a generation.If a termination criterion is not satisfied, this process repeats.This termination criterion can be defined as reaching a predefined time limit or number of generations or population convergence [19][20][21][22][23].
The considered genetic algorithms have the following properties:

Chromosome Representation
Unlike the traditional genetic algorithms (GAs) that adopt binary bit strings to encode a chromosome, a more direct representation is used in our model.As we can see in Figure 9 the chromosome is presented by a set of EPCs which form a GPC.

Initialization of the Population
The initial population is randomly generated, with the number of chromosomes is set at 100.The size of each chromosome varies from 3 to n elementary perceptual codes (with 3 is the minimum size of a GPC and n is the maximum number of EPC forming a segment of the  original script).During the generation of the initial population, if there are chromosomes whose size is less than n we complete by zeros.Figure 10 presents an example of an initial population.

Selection
Selection in genetic algorithms aims at giving a higher probability for reproduction to better individuals in a population so that their favorable characteristics can be inherited by even fitter offspring [24,25].This is where the principle of "survival of the fittest" applies.Here, we keep the best parent (based on the fitness value) from the current population as one of the candidates in the next generation.This selection method is called "Elitism".For the other candidates, the roulette selection scheme [19,[26][27] is applied.The individuals selected will then go through crossover and mutation.

Crossover
The essence of any crossover operator is to exchange the components of two parents to form new offspring [26][27].In our experiments, it was found that a crossover probability Pc = 0.6, or higher, produced good results.One point crossover is realized by cutting the chromosomes at a randomly chosen position and then swapping the segments between the two parents [28,29].

Mutation
Mutation in evolutionary algorithms is another search operator.Its main function is to introduce new genetic material and maintain a certain level of diversity in a population since crossover does not introduce any new genetic material [28,29].In our approach, the remaining candidates of the next generation (after crossover) are formed by the mutation operations.

Fitness Evaluation
In our model the value of the fitness evaluation is the percentage of correspondence between the elementary perceptual codes that establish a chromosome and each part of the script to be addressed.The search for the existence of a GPC in a script (matrix of EPCs) and the value of the fitness evaluation requires: browse EPCs script by comparing them with the first EPC of the required GPC.In Figure 11 and for research of Right oblique shaft GPC we seek firstly it first EPC, which is 4 (as shown in the figure).If we found the first EPC of the GPC needed in the matrix of EPCs forming the script, we safeguard the position of the first EPC (in our example, the EPC 4) in the script EPCs matrix as an initial position (pi = 13).Then we compare the rest of EPCs of the required GPC with EPCs forming the script from the initial position +1 (initial position + 1 = position 14 in the Figure 11).If there is at least two successive EPCs of the required GPC that have no correspondents in the matrix of EPCs composing the script we stop researching and we safeguard the final position which is the last position of EPC found in the script EPCs matrix.If the number of EPCs found is greater than or equal to 3 EPCs (the smallest size of GPC) then we retain the initial and final position of the GPC in the matrix of EPCs, the code of GPC and the fitness value (see Equation (10)).
where f GPC is the fitness value of the GPC, N EPC_C is the number of EPCs which have a correspondence in the matrix of EPCs composing the script and N EPC is the number of EPCs forming the required GPC.
In Figure 11 we give an example of fitness calculation for the GPC Right oblique shaft in the position 13 and the GPC left oblique shaft in the position 3.In our example we retain only the GPC Right oblique shaft with the initial position (pi = 13), the final position (pf = 16) and the fitness value which is equal to 4/5 (where 4 is the number of EPCs of GPC Right oblique shaft which have correspondences in EPCs matrix of the letter ‫,"س"‬ and 5 is the size of this GPC (number of EPCs composing the GPC Right oblique shaft)).

Extraction Criteria for the GPC
For the different GPCs already presented in Table 2 we applied several extraction criteria.Among these criteria there is a criterion which is applicable to all GPCs: we should not find two or more consecutive EPCs in the same GPC if they do not exist in the EPCs matrix forming the script.

Extraction Criteria for the Simple GPCs
For all simple GPCs (Shaft, Valley, Left oblique shaft and Right oblique Shaft) we use the same extraction criterion.
In the first place we seek a series of EPCs of the same type as the needed GPC.For example to extract the GPC Right oblique shaft, we must seek a series of EPCs Right oblique shaft.If there are two or more EPCs that are not of the same type as the needed GPC or are not of the same type as the EPCs forming the script, we stop searching, and the GPC is not considered.If the length of the following EPCs found is greater than or equal to three, we retain this suite as a GPC with the initial and final positions in the script and the value of the fitness.

Extraction Criteria for the Complex GPCs
The GPCs considered as complex are the half occlusions, the occlusions and the Ain.We will detail the extraction methods for the Right opening occlusion and the Ain as follows.
In the case of the GPC Right half opening occlusion represented in Figure 12 and written from top to bottom, it is necessary that these conditions must be verified:  The first EPC is a valley or a Left oblique shaft,  The last EPC is a valley or a Right oblique shaft,  X 0j < max (X 0i , X 0f ),  X 0m < min (X 0i , X 0f ),  min (Y 0i , Y 0f ) < Y 0j < max (Y 0i , Y 0f ).where: (X 0i , Y 0i ): the center coordinate of the ellipse forming the first EPC, (X 0f , Y 0f ) are the center coordinate of the ellipse forming the last EPC, and   , j i f  , i: initial, f: final.
For the GPC ain represented in the figure below (Figure 13) we calculate the equations of the first EPC and the last EPC in the tested GPC, and then we check if there is intersection between the two EPCs (Pi: intersecttion point).Thus we look for the existence of two inflexion points P1 and P2 where there is a sudden change of the angle deviation of the EPCs forming the GPC.For example, we have a set of EPCs Right oblique shaft and a set of EPCs valley after the P1 point and a last set of EPCs Left oblique shaft after point P2.

Refining
After the execution of the ten genetic algorithms (a genetic algorithm for each GPC) we used a process of refinement of the results obtained after this execution.
In this stage we favor complex GPCs (Ain, Occlusion an half occlusions) to simple GPC.In fact, we firstly d To determine the final set of GPCs forming the letter "W", we use the stage of refinement already introduced.Knowing that the final refinement favors complex GPC (Ain, Occlusion and half occlusions) compared to other GPCs (Shaft, valley, Left oblique shaft and Right oblique shaft), the final result generated by the GPC extractor (after refinement) is: two Up half opening occlusions.

Simulation Results
In the following part we present some examples of EPCs extraction and then GPCs extraction.Referring the simulation examples, we can note the reduction of the perceptual codes representing a script using the GPCs comparing to case when the EPCs are adopted.An other interesting advantage is that the use of GPCs provides much more significant representation of the script.

Conclusions
In this paper, we present a new method of features extraction of online handwriting.This method has attempted to overcome the inherent ambiguities of handwriting with the help of genetic algorithms.It was the difficult part of the whole handwriting recognition system as the features extraction had to be robust to cope up with the handwriting variety and changes due to mood, health and different writing styles.
To extract the GPCs of an online script we use the Beta-elliptic model to modelise and to extract parameters of handwriting.With the help of these parameters we developed an EPC extractor.For each elliptic arc and with its deviation angle we define four types of EPCs.The human visual sense is selectively activated in response to global form.For this reason we developed a GPC extractor composed of ten GPCs.A GPC is a combination of a set of EPCs according to well defined criteria.For each GPC we used a genetic algorithm to optimize the choice of a good combination (number and type of EPCs composing the GPC) of EPCs.Finally a lot of proposition was giving by the GPC extractor to compose the script.To choice the best and significant proposition a stage of refinement was developed.
These GPCs can be used to develop a handwriting recognition system.

Figure 1 .
Figure 1.The architecture of the perceptual model.

Figure 3 (
Figure 3(a) presents the brute example of the Arabic letter ‫"س"‬ and the Figure 3(b) presents this letter generated with the Beta-elliptic model.

Figure 3 .
Figure 3. (a) The brute example of the Arabic letter "
criteria.It means a few sets of EPCs able to build each GPC.Referring to the Figure7, we can note that there are many possible combinations of elementary perceptual codes that can form the GPCs which vary depending on the number of EPCs and their types.Likewise for the other global perceptual codes.Because of the variety of combinations possibility concerning either the number or the type of EPCs that form a GPC, a problem of choosing the right combination for each GPC arises.This problem of choice may therefore be regarded as a problem of global optimization.

Figure 10 .
Figure 10.Example of initial population.

Figure 11 .Figure 13 .Figure 14 .
Figure 11.Search of GPC (Right oblique shaft and Left oblique shaft) in the EPCs matrix of the letter ‫."س"‬

Figure 15 (
a) represents the generation of the capital letter "D" by EPCs.The EPC extractor has detected 13 EPCs forming the letter "D".Using the EPCs as inputs, the GPC extractor generated several GPCs building the letter "D".A refinement stage is necessary to maintain the better ones (GPC 1 = Shaft and GPC 6 = Left half opening occlusion) (see Figure 15(b)).By the same way, the Arabic letter ‫,"س"‬ the French word "un" and the Arabic word ‫"سعد"‬ was generated by the EPCs (see respectively Figures 16(a), 17(a) and 18(a)), and then theses scripts ‫,"س"(‬ "un" and ‫)"سعد"‬ was generated by the GPCs (see respectively Figures 16(b) , 17(b) and 18(b)).

Figure 15 :
Figure 15: (a) Generation of the letter "D" with the EPCs; (b) Generation of the letter "D" with the GPCs.

Figure 16 .
Figure 16.(a) Generation of the arabic letter ‫"س"‬ with the EPCs; (b) Generation of the arabic letter ‫"س"‬ with the GPCs.

Figure 17 .
Figure 17.(a) Generation of the word "un" with the EPCs; (b) Generation of the word "un" with the GPCs.

Figure 18 .
Figure 18.(a) Generation of the Arabic word ‫"سعد"‬ with the EPCs; (b) Generation of the Arabic word ‫"سعد"‬ with the GPCs.