# Using an Artificial _Physarum polycephalum_ Colony for Threshold Image Segmentation
## 3 Methodology
### A Fitness Function for Entropy Threshold  
This subsection provides the fitness function for the artificial _Physarum polycephalum_ colony to implement threshold image segmentation. To explore the average information content of different pixels in image segmentation, the fitness of the proposed threshold image segmentation is based on the maximum entropy model proposed by [PERSON] [13; 40] and maximizes the total entropy of the segmented target and background. The Kapur's entropy can help us obtain the largest amount of segmentation information on an original image.  
In different threshold models, the 1-D segmentation method is the fastest in segmentation speed since it does not consider the gray values of different pixels on an original image. The 3-D segmentation is the lowest in segmentation speed since it considers 3-D gray information. The 2-D segmentation method is between 1-D and 3-D in image segmentation speed since it considers the gray information of each pixel and its neighborhood but not the 3-D gray information. Here, 2-D segmentation is employed since it can obtain balanced performance, as shown in Figure 1. A set of thresholds \(t=\{t_{1},t_{2},t_{3},\ldots,t_{n}\}\) segments the target and background into several regions, and the other regions are mainly image noise.  
The fitness function should instruct the artificial _Physarum polycephalum_ colony to be efficient and accurate in searching for the best threshold \((t_{1},t_{2},t_{3},\ldots,t_{n})\) to obtain the best segmentation quality. A good fitness function should make full use of the gray information of the original image and suppress the noise from target and background areas.  
Here, the [PERSON]'s entropy \(K(t_{1},t_{2},t_{3},\ldots,t_{n})\) can be calculated for the set of thresholds \((t_{1},t_{2},t_{3},\ldots,t_{n})\) as follows [13; 40]:  
\[K(t_{1},t_{2},t_{3},\ldots,t_{n})=\sum_{i=0}^{n}K_{i}, \tag{1}\]  
where \(K(t_{1},t_{2},t_{3},\ldots,t_{n})\) indicates Kapur's entropy in all areas. Hence, Kapur's entropy in each area can be computed as  
\[K_{0}=-\sum_{i=0}^{t_{1}-1}\frac{p_{i}}{w_{0}}\ln(\frac{p_{i}}{w_{0}});w_{0}= \sum_{i=0}^{t_{1}-1}p_{i} \tag{2}\]\[K_{1}=-\sum_{i=t_{1}}^{t_{2}-1}\frac{p_{i}}{w_{1}}\ln\left(\frac{p_{i}}{w_{1}} \right);w_{1}=\sum_{i=t_{1}}^{t_{2}-1}p_{i} \tag{3}\]  
\[K_{n}=-\sum_{i=t_{n}}^{t_{1}-1}\frac{p_{i}}{w_{n}}\ln\left(\frac{p_{i}}{w_{n}} \right);w_{n}=\sum_{i=t_{n}}^{t_{1}-1}p_{i}, \tag{4}\]  
where the parameters \(w_{0}\), \(w_{1}\), \(\ldots\), \(w_{n}\) indicate the possibility for each segmentation cluster, and \(p_{i}\) indicates the possibility of the occurrence of pixels with a gray value \(i\). Now, [PERSON]'s entropy can be obtained for each cluster and instruct the artificial _Physarum polycephalum_ colony to evaluate the characteristics of clusters. There is  
\[fit=argmax\{K(t_{1},t_{2},t_{3},\ldots,t_{n})\}. \tag{5}\]  
The combination maximization function _fit_ is the optimal threshold group. The artificial _Physarum polycephalum_ colony uses the fitness function to select the optimal solution. The higher the fitness function, the better the quality is achieved.