# An Image Edge Detection Algorithm Based on an Artificial Plant Community
## 4 Algorithm Design
### Growing of the APC  
The growing operation is the second fitness comparison. The population size decreases to \(p_{g}\times S\), while the rest of the population \((1-p_{g})\times S\) dies. The natural plant communities are selected according to the surrounding water sources and nutrients. The artificial plant community is supposed to use the evaluation function as a fitness evaluation to judge the growing probability of the individuals. The growing operation is aimed at selecting the best artificial plant individuals from the seeding population and giving them a growing probability of \(p_{g}\) to grow into individuals. Through the growing operation, the artificial plant individual is selected as a feasible solution by the evaluation function, and a new edge image \(I(i,j)\) is obtained. If the artificial plant individuals score highly on the evaluation function of the living area, their growing probability is greater, and if the opposite occurs, their growing probability is smaller. The scoring process of the growing operation can help the artificial plant community to converge to a feasible solution. The evaluation function for APC growth includes several indexes, including the accuracy, information entropy, standard deviation, peak signal-to-noise ratio, and degree of distortion. Accuracy is used to describe the precision of image edge detection, as shown in Formula (11). The greater the accuracy is, the more accurate the image edge detection is. On the contrary, the lower the accuracy is, the more inaccurate the edge detection is  
\[ACC=\frac{TP+TN}{TP+TN+FP+FN} \tag{11}\]  
where \(TP\)is the number of true positives, showing the total number of correctly detected edge pixels; \(TN\) is the number of true negatives, showing the total number of correctly detected nonedge pixels; \(FP\) is the number of false positives, showing the number of the wrongly detected edge pixels which are actually nonedge pixels; and \(FN\) is the number of false negatives, showing the number of the wrongly detected nonedge pixels which are actually edge pixels. The accuracy matrix defining the terms \(TP\), \(TN\), \(FP\), and \(FN\) is shown in Table 3.  
Information entropy is an important indicator that is used to measure the richness of image information. For a grayscale image \(I_{\text{gray}}(i,j)\) with a gray level of \(L\), \(P_{i}\) represents the probability that the pixel gray value in the image is \(i\), so the information entropy can be defined as  
\[ENT=-\sum_{i=0}^{L-1}\left[P_{i}\times\log P_{i}\right] \tag{12}\]  
where \(ENT\) represents the entropy of the image: the greater the entropy of the image, the more information the image has. \begin{table}
\begin{tabular}{c c c} \hline \hline \multirow{2}{*}{**Original Image**} & \multicolumn{2}{c}{**Edge Image**} \\ \cline{2-3}  & **Edge Pixel** & **Non-Edge Pixel** \\ \hline Edge pixel & \(TP\) & \(FP\) \\ Non-edge pixel & \(FN\) & \(TN\) \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Accuracy Matrix Definition. The standard deviation \(STD\) is one of the most commonly used quantization forms to reflect the degree of dispersion in the grayscale data from two images. For two images \(I(i,j)\) and \(I^{\prime}(i,j)\) with the same size \(w\times h\), the standard deviation is defined as  
\[STD=\frac{1}{w\times h}\sum_{i=1}^{w}\sum_{j=1}^{h}\left[I(i,j)-I(i,j)\right]^{2} \tag{13}\]  
The higher the \(STD\) is, the more discrete the data set of the image is, and the less clear the image is. On the contrary, the lower the \(STD\) is, the clearer the image is. The peak signal-to-noise ratio \(PSNR\) of an image is an important indicator of the quality of the edge image. It is the ratio of the effective signal to the noise signal in the image, that is, the ratio of the edges to the nondeges. For two images \(I(i,j)\) and \(I^{\prime}(i,j)\) with the same size \(w\times h\), the mean square deviation is defined as \(PSNR\).