Abstract

In order to realize the multithreshold segmentation of images, an improved segmentation algorithm based on graph cut theory using artificial bee colony is proposed. A new weight function based on gray level and the location of pixels is constructed in this paper to calculate the probability that each pixel belongs to the same region. On this basis, a new cost function is reconstructed that can use both square and nonsquare images. Then the optimal threshold of the image is obtained through searching for the minimum value of the cost function using artificial bee colony algorithm. In this paper, public dataset for segmentation and widely used images were measured separately. Experimental results show that the algorithm proposed in this paper can achieve larger Information Entropy (IE), higher Peak Signal to Noise Ratio (PSNR), higher Structural Similarity Index (SSIM), smaller Root Mean Squared Error (RMSE), and shorter time than other image segmentation algorithms.

1. Introduction

Image threshold segmentation refers to dividing an image into two parts: background and foreground under a certain gray value, and target object can be easily recognized by distinguishing between foreground and background [1, 2]. At present, target recognition based on image segmentation is widely used in medical care, military, geology, agriculture, and many other fields [36]. Due to the small difference between the target and the back ground of a complex image, the results of image threshold segmentation are often far from satisfactory. Considering the results of image segmentation are quite different under different thresholds, [79], providing an accurate, reliable, and effective method for identifying objects in complex background has a wide range of practical applications [10, 11]. On the other hand, with the development of computer science and technology, the real-time requirement of image segmentation is improved and finding the exact threshold quickly is also an important part [12, 13]. To sum up, it is important and necessary to find a suitable threshold quickly to complete the segmentation of the target object in an image.

In the last few decades, a number of image segmentation techniques have been devised, and image threshold segmentation is mainly divided into two categories: global threshold segmentation and multithreshold segmentation [14, 15]. Both global and multithreshold segmentation select thresholds by optimizing (maximizing or minimizing) some specific parameters [16]. Actually, constructing the appropriate parameters for image multithreshold segmentation is at the heart of solving this problem [17]. And there are two main methods for constructing parameters: entropy-based algorithm and graph cut algorithm [18]. Entropy-based Threshold Method was first proposed in 1980 by Pun [19] and is to develop extremely rapid in the next few decades. Chowdhury et al. used Shannon's entropy and proposed a new multithreshold image segmentation method based on minimization of bientropy function [20]. Hinojosa et al. used three of the most representative entropies—Kapur, minimum cross entropy, and Tsallis as objective functions [21]. Mishra et al. calculated the optimal threshold values using bat algorithm and maximizing different objective function values based on Kapur's entropy [22]. Pare et al. proposed an efficient multithreshold technique based on rendering minimum cross entropy [23]. Application of the various multithreshold approaches discussed above, which are all based on entropy such as bientropy, Kapur's entropy, and cross entropy, becomes computationally costly when extended to perform multithreshold due to the constructed parameters functions to obtain optimum threshold values. Because of the measurement accuracy in selecting threshold and the simplicity in dealing with the problem of image multithreshold segmentation, the algorithm based on graph cut theory is being developed using a probability theory—that is, different pixels within the same set. The optimal thresholds are gained by minimizing the cut between different pixel sets [24]. Lu et al. proposed an effective approach for particle segmentation based on combing the background difference method and the graph cut based local threshold method [25]. Jimenez et al. presented a specifically designed graph cut methodology that ensures spatial and directional consistency [26]. Zhu et al. developed an optimized parameter based on graph cut to segment liver cysts [27]. Deng et al. obtained the segmentation by optimizing the cost function using graph cuts [28]. Gandhimathi et al. proposed an innovative spatial-spectral method for image segmentation based on graph cut [29]. Guo et al. presented an efficient image segmentation algorithm using neutrosophic graph cut (NGC) [30]. Although the method based on graph cut discussed above can achieve effective image segmentation, the weight function of graph cut, which is used to calculate the possibility that two pixels belong to one class, does not change, and it is inevitable that the segmentation effect will be unsatisfactory due to a slow gradient drop. Additionally, because of the complexity of the weight construction function and the cost function suitable for those algorithms, the computation time of the graph cut based method increases exponentially as the segmentation level increases.

Obviously, because traditional methods based on mathematical models are difficult to achieve ideal results, some new methods are incorporating bionic algorithms, such as Dragonfly algorithm [31], Artificial Bee Colony algorithm [3234], Bat Algorithm [35], and Grey Wolf Algorithm [36]. Moreover, Gao et al. demonstrated the superiority of the ABC algorithm in finding an optimal value [34]. Inspired by the above algorithms, we propose an image multithreshold segmentation method based on graph cuts with artificial bee colony algorithm. Through constructing a new weight function, which is based on the location and gray value of pixels, the relationship between pixels is obtained. On this basis a new cost function is reconstructed, which can use both regular and irregular images. Then the artificial bee colony algorithm is used to search the optimal multithreshold segmentation values of an image. By comparing the information entropy (IE), Peak Signal to Noise Ratio (PSNR), and Structural Similarity Index (SSIM) of images as well as the time complexity of algorithm with the existing image segmentation methods, the proposed algorithm based on graph cuts in this paper can achieve better segmentation results with the shortest time.

The main work of this paper is given as follows. Section 2 introduces the advantages of the artificial bee colony algorithm briefly and the general process of the algorithm. Section 3 introduces the method to construct the new undirected graph. Based on this new undirected graph, the cost function of multithreshold segmentation is constructed. Section 4 demonstrates the effectiveness of the method through experiments. At the same time, qualitative and quantitative methods are used to evaluate this method. Section 5 concludes this paper.

2. Artificial Bee Colony Algorithm

Artificial bee colony algorithm is a global optimization algorithm by simulating bee foraging behavior. Since Karaboga and Basturk first proposed this algorithm in 2008, the artificial bee colony algorithm (ABC) has developed rapidly [3234, 37]. The artificial bee colony algorithm contains three kinds of bees: employed bees, onlookers, and scouts. Employed bees bring nectar source back to the hive and share the information in the dancing area. By observing the information brought back by employed bees and calculating the number of food sources, the onlookers can determine the probability of selecting different nectar sources and make a decision on selection. Scouts make random searches near the sources. If the food source is not selected, the employed bee which carries the information of the food source becomes a scout bee and immediately searches near the original food source. As soon as a new food source is found, the scout bee becomes an employed bee again. In summary, every search cycle of artificial bee colony algorithm includes three steps: (1) employed bees are sent to find food sources while calculating the amounts of nectar; (2) employed bees share the information and onlooker bees select the optimal source by calculating the amount of different nectar sources; (3) the scout bees are then chosen and sent out to find the new food sources.

In ABC algorithm, the location of food source represents a possible optimal solution, and the nectar amount of a food source corresponds to the quality (fitness) of the associated solution, calculated by

where represents the quality (fitness) of the solution which is inversely proportional to and is the cost function which needs to be built for each specific problem. In this paper is the cost function construct based on the undirected weight map in Section 3.1.

In the algorithm, the number of employed and onlooker is equal to the number of optimal solutions. Initially, the artificial bee colony algorithm randomly generates P of SN as the initial result, where SN denotes the size of population and each solution is a vector of D dimensions of which elements are represented as (). Here, D is the number of product of input size and cluster size for each data set. After initialization, the population of the positions (solutions) is subjected to repeated cycles, C = 1, 2, …, MCN, of the search processes of the employed bees, the onlooker bees, and scout bees. An employed bee produces a modification on the position (solution) in her memory depending on the local information (visual information) and tests the nectar amount (fitness value) of the new source (new solution). If more nectar is found at the new food source than from the previous source, the employed bees will remember the location of the new source; otherwise, they will choose to remember the location of the original source. As soon as all employed bees have completed the search, they share the nectar source information and location with the onlooker bees, which will select the most possible food source as the optimal solution through calculating the number of nectar. The probability of choosing a nectar source is calculated by

where is the probability of choosing nectar source, SN is the number of food sources which is equal to the number of employed bees, and is the fitness of the solution given in (1).

In order to produce a candidate food position from the old one in memory, the new source is obtained by

where represents the candidate food position, is the original resource location, and is a generated resource location through choosing the indexes   () and () randomly. Although is determined randomly, it has to be different from and is randomly generated in .

If the location of the nectar source cannot be updated by the previous ‘limit’ of bees, the location of the nectar source is discarded and the employed bees are turned into scout bees. It is assumed that the location of the abandoned nectar source is and , and then the scouts found a new food source of food to replace . The above steps can be expressed by

where and are the upper and lower limits of the jth component of all solutions. If the new solution is better than the original, the scout bee will become an employed bee again. All employed bees, onlooker bees, and scout bees repeat the above steps until the termination criteria are met. The flow of the artificial bee colony algorithm is shown in Figure 1 and the search result of ABC algorithm is shown in Figure 2. At last, the fake code is given in Algorithm 1.

Input: MCN Number of iterations for optimization,
   SN Number of food sources equal to the number of employed bees.
(1) Initialize parameters and generate initial position.
(2) Find the initial source of nectar
(3) While Stopping criteria not met do
(4)  calculate the number of food sources by the onlookers
(5)  if the food sources is selected
(6)    the employed bees remember the location of the food sources
(7)  else
(8)   the employed bees become scout bees and search near the original food sources
(9)  end if
(10)  end while
Output: The location of the food sources.

3. Threshold Segmentation Model Construction

According to the analysis above, the artificial bee colony algorithm can obtain the optimal solution of a certain problem by searching the location of the optimal nectar source. In this section, we first converted an image undirected weight map based on graph spectra theory. On this basis, we constructed a cost function suitable for multithreshold segmentation. Finally, the artificial bee colony algorithm is used to search the minimum cut of undirected weight map to achieve threshold segmentation of the image.

3.1. Construction of Undirected Weight Map Based on Gray Value

According to undirected graph theory, the point sets of any feature space can be represented by , where V represents the set of points and E represents the set of connecting edges between points. In undirected weighted map, there is only one connecting edge between two points. Weight w (u, v) is given to the edge, which indicates the similarity between points u and v. In summary, the smaller the value, the less likely points u and v belong to the same set.

When constructing an undirected weighted map of an image, considering that the larger the distance between pixels, the less likely they belong to the same set, the weight function constructed is required to have a fast descent gradient, which means when the denominator of the weight function increases, the weight value decreases rapidly, implying the possibility that two pixel points belong to the same set quickly decreases. At the same time, the weight value w represents the probability, which is nonnegative. To sum up, the edge weight between pixel point u and pixel point v is as follows:

where is the gray value of pixel points, is the spatial position of pixel points, is the two norm, and are positive scale factors, and is positive integer, representing the range of pixel points involved in calculating the weight. The weight function is visualized for several values of in Figure 3.

In this paper, , , and is taken as an example to test the effectiveness of the algorithm. Meanwhile, the weight function constructed in this paper is lower than the original function in time complexity, and its analysis is put in Section 4.

3.2. The Cost Function Construct Based on the Undirected Weight Map

For any threshold , where is dynamic which depends on the bits per pixel occupied (T=255 if 8 bits per pixel while T=65535 if 16 bits per pixel). We can get a multithreshold partition of the corresponding undirected weighted map of the image, which can be expressed aswhere represents the collection of pixels, represents the collection of edges between pixels, and represents a pixel collection belonging to class. According to the graph cuts theory, when the image is segmented by multithresholds, the difference between pixels belonging to different divisions is the largest while the difference between pixels belonging to the same division is the smallest. The cut between and is defined as

Similarly, the cut between and is defined as

In the same way

For image multithreshold segmentation, it is to find making the value of minimum while the value of maximum.

In order to facilitate further analysis, we define

Then (7) can be transformed into

Similarly,

Therefor (13) is established:

By parity of reasoning, (14) also holds.Similarly, in order to overcome the problem of isolated points in segmentation, Normalized Cuts (Ncut) is adopted to describe the degree of separation between the two classes [38], which is defined as follows:

Equation (16) can be obtained by transforming (15).

After normalization, (17) can be obtained from (14).

Therefore, the key of image segmentation is to find a set of N thresholds, so that (18) can achieve the smallest value, which is mentioned in (1).

The flowchart of image segmentation algorithm proposed in this paper is shown in Figure 4 and the fake code is given in Algorithm 2.

Input: An image with gray value,
    Segmented threshold level.
(1) Calculate the edge weight between pixels with the new constructed function
(2) Generate segmentation threshold randomly
(3) Calculate the value of under the threshold
(4) Calculate the value of new cost function () based on
(5) While Stopping criteria not met do
(6)   Search new threshold near the original threshold using artificial bee colony algorithm
(7)   Recalculate the value of under the new threshold
(8)   Recalculate he value of new cost function () based on
(9)   if the cost function becomes smaller
(10)     Continue searching new threshold near the original threshold
(11)   else
(12)    Break
(13)   end if
(14) end while
Output: Multi-level image segmentation threshold

4. Experiments

In this section, we will evaluate the performance of the algorithm proposed in this paper comprehensively. Firstly, public dataset for segmentation and widely used images are evaluated separately using the proposed algorithm in this paper to segment each image into two, three, four, and five levels of threshold. And at the same time, quantitative methods are used to demonstrate the advantages of the proposed algorithm through comparing the Information Entropy (IE), Root Mean Squared Error (RMSE), Peak Signal to Noise Ratio (PSNR), and Structural Similarity Index (SSIM) of images with other widely used algorithms such as BA (Bat Algorithm) [35], IBA (Improved Bat Algorithm) [39], MMSA (Meta-heuristic Moth Swarm Algorithm) [40], and OTUS [41] algorithms. Finally, the time advantage of the algorithm is confirmed via analyzing the time complexity of the algorithm.

4.1. Qualitative Comparison and Analysis of Different Algorithms

In this part, we will compare the performance of our algorithm using the new weight and cost function with other algorithms. Firstly, we selected five images commonly used in the image field to verify the effectiveness of the algorithm proposed in this paper. Figures 5, 6, 7, and 8 are the segmentation results obtained by different algorithms. Figure 5 shows the two-level segmentation results, Figure 6 shows the three-level segmentation results, Figure 7 shows the four-level segmentation results, and Figure 8 shows the five-level segmentation results.

The specific segmentation thresholds of different algorithms are given in Table 1. As can be seen from Table 1, the segmentation results given by our method are slightly different from those of other methods.

Further, we selected ten images from the data set [42] to justify the superiority of proposed method. Figures 9, 10, 11, and 12 are the segmentation results obtained by different algorithms. Figure 9 shows the two-level segmentation results, Figure 10 shows the three-level segmentation results, Figure 11 shows the four-level segmentation results, and Figure 12 shows the five-level segmentation results.

The specific segmentation thresholds of different algorithms are given in Table 2, and qualitative analysis of the advantages and disadvantages of those algorithms is put in Section 4.2.

4.2. Quantitative Comparison and Analysis of Different Algorithms

In this part, we will evaluate the performance of the algorithm quantitatively by calculating Information Entropy (IE), Root Mean Squared Error (RMSE), Peak Signal to Noise Ratio (PSNR), and Structural Similarity Index (SSIM) of images. Generally speaking, the entropy of an image represents the information contained in the image. According to the theory of Information Entropy (IE), the better segmentation results are, the greater the value of information entropy is. The entropy of an image can be calculated as follows:

where is the probability density of pixel value k and M is largest pixel value. For the convenience of reading, we put the results of the two data sets in one table. The Information Entropy (IE) of different segmented images using various algorithms is given in Table 3.

As shown in Table 3, the image segmented by the algorithm proposed in this paper can obtain a larger information entropy (IE), which means the algorithm proposed in this paper has the best segmentation effect compared with other algorithms mentioned above. What is more the value of information entropy (IE) of multithreshold segmented image is greater than that of two-level threshold segmentation, meaning the more threading levels there are, the less information lost is.

Root Mean Squared Error (RMSE) is a mathematical model established based on the visual system of human eyes, which determines the degree of distortion of the image by calculating the mean square value of the pixel difference between the original image and the processed image. The entropy of an image can be calculated as follows:

where M and N represents the length and width of the image, represents the gray value of the point in the original image, and represents the pixel value of the point in the image after segmentation. We put the results of the two datasets in one table. The Root Mean Squared Error (RMSE) of different segmented images using various algorithms is given in Table 4.

As shown in Table 4, the image segmented by the algorithm proposed in this paper can obtain smaller Root Mean Squared Error (RMSE), which means the proposed algorithm has the least degree of distortion compared with other algorithms. The value of The Root Mean Squared Error (RMSE) of the multithreshold segmentation image is greater than that of two-threshold segmentation, meaning that the more threading level there are, the less degree of distortion is.

Peak Signal to Noise Ratio (PSNR) is another important indicator to measure image quality. It is based on communication theory which represents the ratio of maximum semaphore to noise intensity. Since digital images represent image pixels in discrete numbers, the maximum pixel value of the image is used instead of the maximum semaphore. The specific formula is as follows:

where L is the maximum gray value of the pixels in the image, generally 255, and MSE is the square of RMSE. We also only used one table to present the results. The Peak Signal to Noise Ratio (PSNR) of different segmented images using various algorithms is given in Table 5.

As shown in Table 5, the image segmented by the algorithm proposed in this paper can obtain a higher Peak Signal to Noise Ratio (PSNR), which means the algorithm proposed in this paper has the best background noise filtering compared with other algorithms whether it is in two-level threshold segmentation or multithreshold segmentation

Structural Similarity Index (SSIM) is an indicator that measures the similarity of two images. The method was first proposed by the University of Texas at Austin's Laboratory for Image and Video Engineering. If the two images are one after segmentation and the other before segmentation, SSIM algorithm can be used to evaluate the segmentation effect. The calculation formula is as follows:

where represents the original image and represents the segmented image. and , respectively, represent the mean values of images and , and represent the standard deviations of images and , respectively, and and are the square of and . and represent the variance of the images and , and and are constants to maintain stability in order to avoid the denominator being zero. Normally, and , where and . is the dynamic range of pixel values, generally taken as 255. We put the results of two datasets together, and the Structural Similarity Index (SSIM) of different segmented images using various algorithms is given in Table 6.

As shown in Table 6, the image segmented by the algorithm proposed in this paper can obtain a higher Structural Similarity Index (SSIM), which means the algorithm proposed in this paper has the highest similarity to the original image compared with other algorithms. The value of Structural Similarity Index (SSIM) of multithreshold segmented image is higher than that of two-threshold segmentation, meaning the more the threading levels there are, the higher the similarity is.

4.3. Time Complexity Analysis of Different Algorithm

In this part, we show the time advantage of the algorithm by analyzing the time complexity of the algorithm.

The computing of the algorithm proposed in this paper can be divided into two parts: the first part is the computational time T1 needed to construct the undirected weight map based on gray level, and the second part is the time needed to search the optimal solution using artificial bee colony algorithm according to the undirected weight map. The analysis of the time complexity of the second part has been given in literature [29]; therefore it will not be involved in the essay. For the first part, the computation of structuring the undirected weight map depends on the parameter r. With the increase of r, there are more edges connecting the points in weight map G, and the corresponding calculation increases as well. Obviously, in (4), r=1 is meaningless while r=2 means, for every pixel, we must calculate the weight value between this pixel and every other pixel in its 33 neighborhood. The total amount of calculation frequency needed to calculate all pixels in undirected weight map G is (8 N)/2=4 N, where N represents the total number of pixels. Division by ‘2’ is because the weight between pixel point v and pixel point u is repeatedly calculated twice when pixel point v and pixel point u are, respectively, centered.

Generally speaking, when r>1, every pixel has neighborhood pixels except the pixels on the boundary of an image. Therefore, the number of weights needed to calculate in the undirected weight map is

The time complexity of t1 is O (r2 N), and the time cost of various algorithm compared with our method is given in Table 7.

As shown in Table 7, the image segmented by the algorithm proposed in this paper can reduce the computation load, which means the algorithm proposed in this paper has the shortest computation time compared with other algorithms.

5. Conclusion

In this paper, we have proposed an improved segmentation algorithm based on graph cut theory using artificial bee colony. This approach uses a new weight function based on gray level and the location of pixels to calculate the probability that each pixel belongs to the same region. Then the optimal threshold of the image is obtained through searching for the minimum value of the cost function which is constructed based on the weight function using artificial bee colony algorithm. Experiment results show that the algorithm proposed in this paper can achieve larger Information Entropy (IE), higher Peak Signal to Noise Ratio (PSNR), higher Structural Similarity Index (SSIM), smaller Root Mean Squared Error (RMSE), and shorter time than other image segmentation algorithms.

Data Availability

The data used to support the research findings of this study have been deposited in “https://pan.baidu.com/s/1UhHjhFnvfqS2Po0QUPIxzA” and “https://www2.eecs.berkeley.edu/Research/Projects/CS/vision/bsds/BSDS300/html/dataset/images.html”.

Conflicts of Interest

The authors declare that they have no conflicts of interest.

Acknowledgments

This work is supported by Subproject of Key Project of Beijing, China (Nos. Z181100000618006 and D161100004916002), Beijing Natural Science Foundation (No. 4192042), and National Natural Science Foundation of China (No. 61627816).

Supplementary Materials

Test all the 100 pictures in the test dataset of Berkeley Segmentation Dataset to justify the superiority of the proposed approach. (Supplementary Materials)