# A Particle Swarm Optimization Algorithm for Neural Networks in Recognition of Maize Leaf Diseases

Jia Tao

<figure><img src="image_1.png" /></figure>

## To cite this version:

Jia Tao. A Particle Swarm Optimization Algorithm for Neural Networks in Recognition of Maize Leaf Diseases. 8th International Conference on Computer and Computing Technologies in Agriculture (CCTA), Sep 2014, Beijing, China. pp.495-505, 10.1007/978-3-319-19620-6_56. hal-01420265

HAL Id: hal-01420265

https://inria.hal.science/hal-01420265

Submitted on 20 Dec 2016

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_2.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
# A Particle Swarm Optimization Algorithm for Neural Networks in Recognition of Maize Leaf Diseases

Jia Tao

College of Information Science and Technology, Agricultural University of Hebei, Baoding, 071001
taojiand@126.com

**Abstract.** The neural networks have significance on recognition of crops disease diagnosis, but it has disadvantage of slow convergent speed and shortcoming of local optimum. In order to identify the maize leaf diseases by using machine vision more accurately, we propose an improved particle swarm optimization algorithm for neural networks. With the algorithm, the neural network property is improved. It reasonably confirms threshold and connection weight of neural network, and improves capability of solving problems in the image recognition. At last, an example of the emulation shows that neural network model based on pso recognizes significantly better than without optimization. Model accuracy has been improved to a certain extent to meet the actual needs of maize leaf diseases recognition.

**Keywords:** neural network optimization; Particle swarm optimization; Opposition-Based Learning; maize leaf diseases

## 1 Introduction

Grey speck disease, brown spot and leaf blight are important leaf diseases in the warm and humid maize areas in china, and they have become more and more serious for recent years[1-3]. The traditional identification method is observing with naked eyes by plant protection expert and seasoned farmers which is a time consuming and costly process [4-5]. In recent years, with the development of the image processing and pattern recognition technology, Automatic recognition by neural network has been an active topic in the field of disease recognition. But traditional neural network has the weaknesses such as slow convergent speed, easy getting into local minimum and low rate of correct motion pattern recognition. Particle swarm optimization (pso) is an evolutionary computation technique, it can be used to solve many kinds of optimization problem. In this paper, an improved particle swarm optimization (pso) algorithm is applied to solve the problem, and the improved methods is used in recognition of maize leaf diseases. Experiments show that the recognition accuracy and efficiency of this method are
improved compared with other feature extraction methods. It builds a base for maize leaf diseases diagnosing and recognizing, and improve its research and application in this field.

## 2. Swarm Optimization Algorithm

Particle swarm optimization seeks and traversals the optimal particle in solution space. Here purpose the spatial dimension of situation is D and the particle swarm number is S.so particles i is expressed by the formula:

$$X_i(x_{i1}, x_{i2}, \dots, x_{id}) (i = 1, 2, \dots, S; d = 1, 2, \dots, D)$$

Running speed of i is expressed by Vi in the formula:

$$V_i(v_{i1}, v_{i2}, \dots, v_{id})$$

The optimum point of i is expressed by the formula:

$$P_i(p_{i1}, p_{i2}, \dots, p_{id})$$

Global advantage of the number of particles is expressed by the formula:

$$P_g(p_{g1}, p_{g2}, \dots, p_{gd})$$

Position and speed of all the Particle swarm is shift by using iteration method.the iterative rule is expressed by the formula:

$$v_{id}^{k+1} = \omega_i v_{id}^k + c_1 r_1 (p_{id}^k - x_{id}^k) + c_2 r_2 (p_{gd}^k - x_{id}^k)$$

$$x_{id}^{k+1} = x_{id}^k + v_{id}^{k+1}$$

The value of k is related to the number of iterations and c1, c2 is related to the accelerated factor. Using the alterable parameter r1, r2 to adjust the speed and give expression to the randomicity of movement.The motion inertia is expressed by the parameter ωi. The following factors determine the real-time speed and position:

(1) The last speed and location;

(2) The trend to approach to optimal location;

(3) Members of particle swarm timely adjust the speed and location for information exchange. Traditional neural network has low rate of correct motion pattern recognition, and slow convergence rule of the network [6-9].We introduce pso to improve the algorithm.

## 3. Neural Network Based on Improved PSO

### 3.1Opposition-Based Learning

The principle is as the following [10]:
When searching the optimum solution x, the usual method is to begin from initial point x which is determined randomly or according to the experience and obtains the global solution. To resolve the complex problem such as initialization of the weights of the neural network, the method adopted is determined by random samples. A problem to solve is when the random initial weights is apart from the optimal solution, calculating for optimization and searching is a CPU intensive work and convergence is difficult. So in theory, initial feasible solution can be investigated from at all positions and directions of the random point. Supposes that the comparative direction is beneficial for searching and the definition of point is given below firstly [11-14]:

Definition 1: Suppose $x \in [a,b]$ is a real numbers,and its opposite point $\bar{x}$ is definded as follows:

$$ \chi = a + b - \bar{x} $$

Similarly, opposite point in a multidimensional space is definded as follows:

Definition 2: Suppose that $P(x_1, x_2...x_n)$ is a point in n dimensional space, $x_1, x_2...x_n \in R$ and $x_i \in [a_i, b_i], \forall i \in \{1, 2, ..., n\}$, the opposite point of P is definded as $P(\chi_1, \chi_2...\chi_n)$, in which $\chi_i = a_i + b_i - x_i, i \in \{1, 2, ..., n\}$.

The method of Opposition-Based Learning is provided below:

Suppose the function to be optimized is $f(x)$ and the fitness function is $g(.)$ which is used to evaluate the quality of candidate solution. $x \in [a,b]$ is a random initial point and $\bar{x}$ is the opposite point of $x$. In the courses of iterative optimization, the values of $x$ and $\bar{x}$ are first calculated. Then by comparing the fitness function of the two points to determine the larger one. If $g(f(x)) > g(f(\bar{x}))$, values of $x$ is regarded as the retention value, otherwise, $\bar{x}$.

For example, when optimizing a function of one variable defined on the interval $[a1, b1]$ as shown in fig. 1, the method is: through repeated iteration to evaluate the candidate solution and its opposite solution to find the optimal solution. Initial the $x$ point firstly and obtain its opposite point $x_0$, then calculate the distance of $d$ and $d_0$ with the optimum solution respectively. If $d_0 < d$, binary search the space of $x$, otherwise of $x_0$. Iterate on till the distance with the optimum solution is less than the predefined thresholds.

Opposition-Based Learning is introduced in order to enhance the performance procedure is provided as following:

Step1: By using random generation method, the initial uniformly random distributed population is $X = \{X_i, V_i | i = 1, 2, ..., N\}$.
<figure><img src="image_3.png" /><figcaption>Fig. 1. optimize single variable</figcaption></figure>

<figure><img src="image_4.png" /><figcaption>Fig. 2. Simple definition of expand variation</figcaption></figure>

Step2: for each particle in populationX, constitute the opposite population from the calculation of the opposite particle $OX = \{OX_i, OVi | i = 1, 2, ...N\}$ whose position and velocity are described as $ox_{id} = L_d + U_d - X_{id}$ and $ov_{id} = V_d^{min} + V_d^{max} - v_{id}$.

Step3: according to the fitness, choose n particles as initial population

$$X^0 = \{X_i^0, V_i^0 | i = 1, 2, ...N\} \text{ from X and OX.}$$

In order to search out the global optimal solution in a higher dimensional space, we introduce the mutation model to obtain 2 particles by expansion and contraction. Fitness degree values among the 3 particles are compared and the best is retained for the next iteration.

For example shown as the figure2, a particle expansion is from A (1, 1, 1) to B (2, 2, 2).

Its position changes as the formula:

$$x(i+1) = x(i) + a * x(i)$$

## 3.2 Particle Swarm Optimization

Based on particle swarm optimization algorithm, parameter t is used as the adaptability function. The formula is the expression:

$$t = \frac{1}{N} \sum_{i=1}^{N} \sum_{j=1}^{m} (y_{j,i}^{d} - y_{j,i})^2$$

The sum of example is denoted by N. The meaning of $y_{j,i}^d$ is the predict value from samples i and node j. Let $y_{j,i}$ denote the actual value related to the predict one. The number of the nodes is denoted by m. The normal steps to establish neural network can be summarized as follows:

Step1: To design and train the structure of neural network by the training documents cluster; to determine the initial parameters;

Step2: To determine the particle swarm initial value based on the neural network which is constructed in Step1;
Step3: By initializing a random particle swarm, updating the velocity and position of particles in accordance with the fitness of particles, searches the optimal coordinates through iterative searching.

Step4: The scheme stops iterative computing when the iterative number is correct. The global optimal solution and the network structure are obtained.If scheme condition is not satisfied, go to Step3.

# 4. Experimental Results

## 4.1 Acquisition and Processing

Diseased leaves of leaf blight, gray leaf spot, and brown spot are collected from experimental station of Hebei agricultural university in 2013. The collected images are saved as jpg file.

Image preprocessing schemes include gray processing, histogram equalization and Image segmentation then from the open and close operations, Fig. 3 and Fig. 4 show the preprocessing effects:

<figure><img src="image_5.png" /><figcaption>FIG. 3. Median filtering before(left) and after(right)</figcaption></figure>

<figure><img src="image_6.png" /></figure>

<figure><img src="image_7.png" /></figure>

<figure><img src="image_8.png" /><figcaption>FIG. 4. Image segmentation before (left) and after (right)</figcaption></figure>

## 4.2 Feature Extraction

### Shape Features Extraction

#### (1) Lesion area

After image segmentation, the area parameter is the number of pixels of disease part, which is expressed as $A_0$:

$$A_0 = \sum_{i=1}^{N} f(x, y)$$

#### (2) Geometrical center

The centroid of 2d shape of leaf lesions is regarded as geometrical center, in which R is the diseased spots:

$$\begin{cases} \bar{x} = \frac{1}{A_0} \sum_{(x,y) \in R} x \\ \bar{y} = \frac{1}{A_0} \sum_{(x,y) \in R} y \end{cases}$$
(3) Minimum exterior rectangle

Using the four vertex coordinates of encircle rectangle, this parameters is represented as

$(X_{min}, Y_{min}) (X_{max}, Y_{min}) (X_{max}, Y_{max}) (X_{min}, Y_{max})$, among which $X_{min}, X_{max}, Y_{min}, Y_{max}$ denote respectively maximum and minimum of ordinates and abscissas.

(4) Rectangle degree

Rectangle degree means that the ratio of lesion area and minimum exterior rectangle which is expressed as Rt:

$$Rt = A_0 / A_{cir}$$

The area of lesion is expressed as A0 and the area of minimum exterior rectangle is expressed as Acir. Thus it can be seen that $Rt \in [0, 1]$.

If value of Rt is approaching to 1, the spot shape can be regarded more similar to rectangle, if approaching to $\pi/4$, the shape can be a circular. Other values indicate that the spot is mainly irregular in shape.

(5) Roundness degree

Roundness degree means that the similarity between the circular and the spot shape:

$$C = 4\pi A_0 / L^2$$

In the formula given above, the circumference of disease spot ferred to as L respectively. Thus it can be seen that $C \in [0, 1]$. If value of C is approaching to 1, the spot shape can be regarded more similar to circular.

(6) Figure complexity

This parametric reflects the discreteness of the spot shape which is expressed as S:

$$S = L^2 / A_0$$

L and A0 denote respectively the circumference and area of disease spot. The larger the value of circumference is, the stronger the discreteness and image complexity will be.

## Color Features Extraction

HSI color space is introduced to extract the color feature. Its main advantage is stable structure and less dimensions. So the image is converted from RGB model to HSI one by the formula [15-16]:

$$ 
\begin{aligned}
\theta &= \arccos\left\{\frac{1/2[(R-G)+(R-B)]}{[(R-G)^2+(R-G)(G-B)]^{1/2}}\right\} \\
S &= 1 - \frac{3}{(R+G+B)}[\min(R, G, G)] \\
I &= \frac{1}{3}(R+G+B) \\
H &= \begin{cases} \theta, & G \ge B \\ 360 - \theta, & G < B \end{cases}
\end{aligned}
$$
The results of study show that abundant information of the source image is included in the lower order moments and middle order moments of color moment. The most remarkable characteristic of three components in RGB is the B component about maize leaf diseases.

## Texture Features Extraction

We use a gray-primitive co-matrix to describe the feature more exactly. Let N be the the grey step in leaf diseases image. The gray level cooccurrence matrix is expressed by the formula:

$$M_{(\theta,d)}(i, j) = \frac{\{[(x_1, y_1), (x_2, y_2)] \in S | f(x_1, y_1) = i \land f(x_2, y_2) = j\}}{S}$$

In the formula, denote the gray level cooccurrence matrix by M(θ d), in which θ represents the direction and d represents the spatial distances between pixels. So the meaning is the probability of coexisted pixels in one diseased spots which respectively has the gray level of i and j. Denote the coordinates of a pair of pixel by (x₁, y₁) and (x₂, y₂). Thus, the pixel number is expressed as f(x₁, y₁) and f(x₂, y₂). The total number of coexisted pixels which satisfies the conditions is denoted by S. The following parameters are selected for texture features expression through a number of experiments.

(1)E(θ, d)

It represents the energy of the matrix which can be represented by the formula:

$$E(\theta, d) = \sum_{i}^{n} \sum_{j}^{n} M_{(\theta,d)}(i, j)^2$$

In the formula, M(θ d) represents the gray level cooccurrence matrix, I and j represent the gray value of pixel pair in diseased spots. E(θ, d) has a higher value if there is most energy around the diagonal.

(2)H(θ, d)

It represents the entropy of gray level cooccurrence matrix which can be represented by the formula:

$$H(\theta, d) = -\sum_{i}^{n} \sum_{j}^{n} M_{(\theta,d)}(i, j) \log_{2} M_{(\theta,d)}(i, j)$$

The value of H(θ, d) directly proportional to image information quantum. H(θ, d) has a higher value if image texture distribution is equilibrium.

(3)I(θ, d)

It represents the moment of inertia of gray level cooccurrence matrix which can be represented by the formula:

$$I(\theta, d) = \sum_{i}^{n} \sum_{j}^{n} (i - j)^2 M_{(\theta,d)}(i, j)$$

The value of I(θ, d) is related to the image clarity of texture. I(θ, d) is very small if the center of matrix is near main diagonal which also reflects the image texture is roughness and obscure.

(4)C(θ, d)
It represents the correlation of inertia of gray level cooccurrence matrix which can be represented by the formula:

$$C(\theta, d) = \frac{\sum_{i}^{n} \sum_{j}^{n} i^* j^* M_{(\theta,d)}(i, j) - \mu_x \mu_y}{\sigma_x \sigma_y}$$

The value of I(θ, d) is related to the similarity of row and column elements. In the formula, μx represents the mean of each column sum in gray level cooccurrence matrix. μy represents the mean of each row sum. σx represents the variance of each column sum and σy the each row sum[17].

### 4.3 Recognition of Diseases

The design of a typical three-layer structure neural network is constructed by sigmoid.

The shape features of maize disease spots image consists of 6 attributes as follows: lesion area, geometrical center, minimum exterior rectangle, rectangle degree, roundness degree, figure complexity.

The color features consists of 6 attributes as follows: the first, second and third moment of B and H components.

The texture features consists of 8 attributes as follows: the respective mean value and standard deviation of E(θ, d), H(θ, d), I(θ, d), C(θ, d).

All of these attributes are used as the inputs of artificial neural network. It contains 20 neurons in total. The output neurons are composed of three major leaf disease of maize: leaf blight, maize brow spot and grey speck disease.

The number of the hidden layer nodes is 19 combining kolmogorov algorithms. After training the network based on the method of genetic algorithm the optimized weight and threshold are obtained.

The traditional neural network and the optimization methods are trained respectively and finally the suggestibility is compared.

Choose training samples and confirme learning speed as 0.01. A total of 400 effective samples are collected for neural network training which is composed of 175 grey speck disease images, 105 brown spot and 120 leaf blight. Experimental result show that the neural network model converges at 22 and the optimization neural network at 10. The simulation results show that this algorithm can find the optimal solution more rapidly. A comparison is presented as figure5 and 6 below:

<figure><img src="image_9.png" /><figcaption>FIG. 5. traditional neural network convergence</figcaption></figure>

<figure><img src="image_10.png" /><figcaption>FIG. 6. optimization neural network convergence</figcaption></figure>
Test of the neural network is based on 60 images of maize disease respectively. the recognition result is compared below:

<table><caption>Table I THE MAIZE LEAF DISEASE IMAGE RECOGNITION RESULTS</caption><thead><tr><th>maize leaf diseases</th><th>grey speck<br>disease</th><th>brown<br>spot</th><th>leaf<br>blight</th><th>recognition<br>rate</th></tr></thead><tbody><tr><td>total numbers of images</td><td>60</td><td>60</td><td>60</td><td></td></tr><tr><td>The recognition rate of traditional<br>optimization network %</td><td>86.7</td><td>88.3</td><td>88.3</td><td>87.8</td></tr><tr><td>Optimization of optimization<br>network identification rate %</td><td>91.7</td><td>93.3</td><td>95.0</td><td>93.3</td></tr></tbody></table>

The result shows that the identification rate of optimization network is 93.3%. As contrast, at the same time, the traditional neural network is 87.8%. conclusions were summarized that the recognition rate is more pronouncedly improved.

The predict value of optimization network is represented by the four spots. The predict value is expressed by abscissa and neural network output the ordinate. the actual value is expressed by the dashed line and the the fitting value is the solid line. Comparing the simulation results with the real data, we can find that they are similar whose fitting degree R is 0.997.

## 5. Conclusions

In this section, we propose an improved particle swarm optimization algorithm for neural networks and applied it for the recognition and diagnosis of main maize leaf diseases. The algorithm is based on Opposition-Based Learning and makes the pso high efficiency in searching for the best solution in the global area to improve neural network predictive model.

Research on neural network in image recognition continues at a rapid pace. This survey provides an introduction to the main concepts of an improved particle swarm optimization algorithm for neural networks and applied it to the diagnosis of maize disease. The simulation result shows the effectiveness of the method. However, the new optimal methods of neural network can obtain preferable purpose too, such as simulate anneal algorithm, Genetic algorithm et al. At present, the technique of disease detection based on image processing is still a new field of application. it show great potential and form one of the dominant research directions in both agricultural field and the field of image processing.

## Acknowledgment

Funds for this research was provided by the research and development projects of science and technology of Baoding Technology bureau (13ZN009).
References

1. Wang Z L, Li Y C, Shen R F. Correction of soil parameters in calculation of embankment settlement using a BP network back-analysis model [J]. Engineering Geology, 2013,91(2/3/4): 168-177.

2. Ji X D, Familoni B O. A diagonal recurrent neural network-basedhybrid direct adaptive SPSA control system[J]. IEEE Transactions on Automatic Control, 2012, 44(7):1469-1473.

3. Kenned J, Ebemart R C. Partical swarm optimi-zation [A]. Proceeding of 1995 IEEE International Conference on Neural Networks [C]. New York: IEEE, 2013. 192-194.

4.Cui Yanli, Cheng Pengfei, Dong Xiaozhi, et al. Image processing and extracting color features of greenhouse diseased leaf[J]. Transactions of the CSAE, 2005, 21(Suppl.2): 32-35. (in Chinese with English abstract)

5.Ma Xiaodan, Qi Guangyun. Investigation and recognition on diseased spots of soybean laminae based on neural network[J]. Journal of Heilongjiang August First Land Reclamation University, 2006, 18(2): 84-87. (in Chinese with English abstract)

6. LAMEDICA R, PRUDENZI A, SFORNA M, et al. A Neural Net Work Based Technique for Short-term Forecasting of Anomalous Load Periods[J]. IEEE Trans on Power Systems, 2006, 11(4):1749-1755.

7.ALFUHAID A S, EL-SAYED M A, MAHMOUD M S. Cascaded Artificial Neural Networks for Short-term Load Forecas-ting[J]. IEEE Trans on Power Systems, 2007,12(4):1524-1529.

8.BAKIRTZIS A G, PETRIDLS N, A Neural Network Sort Term Load Forecasting Model for the Greek Power System[J]. IEEE Transaction on Power Systems, 2006, 11(2):638-645.

9.CHOW T W S, LEUNG C T. Neural Network Based Short-term Load Forecasting Using Weather Compensation[J]. IEEE Trans on Power Systems, 2006, 11(4):1736-1742.

10. Kim J, Bentley P. Towards an Artificial Immune System for Network Intrusion Detection: An Investigation of Clonal Selection with a Negative Selection Operator [A]. Proc Congress onEvolutionary Computation[C]. 2001:27-30.

11.Smith D J, Forrest S, Perelson A S. Immunological Memory Is Associative[M]. Artificial Immune Systems and their Applications. Berlin: Springer, 2008:105-112.

12.Endoh S, Toma N, Yamada K. Immune Algorithm for N-TSP[A]. Proc IEEE International Conferenceon Systems, Man, and Cybernetics[C]. 2008:3844-3849

13.L.N.de Castro and F.J.von Zuben.Learning and Optimization Using the Clonal Selection Principle[J]. IEEE Trans. Evolutionary Computation. 2002, 6(3):239-251.

14.F. Varela, A. Coutinho. Second Generation Immune Networks [J]. Immunology today. 2001,12:159-167

15.Xu Y. Wavelet transform domain filters: A spatially selectivenoise filtration technique[J]. IEEE Trans, 2004,IP-3(6):747)7571

16.Donoho D L. De-noising by soft thresholding[J]. IEEE Trans Inform Theory, 2005, 41(3):613)6261

17.Mallat S G. Characterization of signals from multiscales edges[J]. IEE Transaction on Pattern Analysis and Machine Intell-igence, 2002, 14(7):710)7321