# Leaf Image Recognition Based on Bag of Features
## 2 Theory for Plant Recognition  
### Dual-Output Pulse-Coupled Neural Network  
DPCNN was proposed by [PERSON] for geometry-invariant texture retrieval in 2012 [28]. The structure of DPCNN model is shown in Figure 1.  
The mathematical expressions of DPCNN model are as follows:  
\[F_{ij}[n]=fF_{ij}[n-1]+S_{ij}[n](V_{F}{\sum_{k,l}M_{ijkl}Y_{kl}^{Ul}[n-1]+\gamma}) \tag{1}\]  
\[Y_{ij}^{F}[n]=\left\{\begin{array}{l}1,F_{ij}[n]>T_{ij}[n]\\ 0,\text{otherwise}\end{array}\right. \tag{2}\]  
\[U_{ij}[n]=F_{ij}[n]+V_{U}S_{ij}[n]{\sum_{kl}W_{ijkl}Y_{kl}^{F}[n]} \tag{3}\]  
\[Y_{ij}^{U}[n]=\left\{\begin{array}{l}1,U_{ij}[n]>T_{ij}[n]\\ 0,\text{otherwise}\end{array}\right. \tag{4}\]  
\[T_{ij}[n+1]=gT_{ij}[n]+V_{E}Y_{ij}^{Ul}[n] \tag{5}\]  
\[S_{ij}[n+1]=(1-Y_{ij}^{Ul}[n]+Y_{ij}^{F}[n])S_{ij}[n]+(Y_{ij}^{U}[n]-Y_{ij}^{ F}[n])A_{ij} \tag{6}\]  
where \(S\) is the external stimulus, and it changes depending on the current outputs \(Y^{F}\) and \(Y^{U}\). \(V_{E}\), \(V_{U}\), \(V_{F}\), \(f\), and \(g\) are fixed constants between 0 and 1. \(W\) and \(M\) are the connection weights which the current neuron communicates with its neighbors. \(Y^{F}\) is the feeding out and \(Y^{U}\) is the compensating output.  
Each neuron of DPCNN is an active neuron, which can be ignited by the feedback input or internal activity of the neuron to generate output pulse. First, the feedback input (\(F_{ij}\)) changes due to the influence of external stimuli and external compensation output from neighboring neurons. Once the value of the feedback input (\(F_{ij}\)) exceeds the active value, the neuron generates a feedback output pulse. Then, the feedback output, feedback input, and external stimulus from the neighboring neurons work together to change the value of the internal activity (\(U_{ij}\)). Once the value of the neuron's internal activity item exceeds its activity threshold, a compensation output pulse is generated. Finally, the activity threshold (\(E_{ij}\)) and external excitation (\(S_{ij}\)) values are updated.  
The pulse sequence generated by pulse-coupled neural network (PCNN) can represent the image edge and texture information; thus, it can extract effective image features. However, there are still some limitations in feature extraction. For example, there is only one pulse generator in the entire neuron model, and the excitation of neurons lacks a compensation mechanism. DPCNN is improved based on the PCNN model. Compared with PCNN, DPCNN has the following advantages: (1) each neuron of DPCNN has two chances to be excited; (2) DPCNN can adaptively change the size of the external excitation of each neuron; and (3) received local stimuli from peripheral neurons are affected  
Figure 1: Structure of DPCNN.  
by the modulation of the input stimulus. In addition, DPCNN also has translation, rotation, scale invariance, and robustness.  
When DPCNN is used for feature extraction, the input image must be a gray image and the intensity of a pixel should be between 0 and 1. In our tests, the parameters were the same as in Ref. [28], except the iterations. The output of each iteration is a binary image, which is called pulse image. The entropy of the pulse image is used as a feature, and, after \(n\) times-iteration, the feature EnS, which is a vector with lengths of \(n\), is obtained.