An improved image segmentation algorithm based on the maximum class variance method

. Image segmentation is an important part of image processing. The result of image segmentation directly affects the effect of subsequent image processing. However the efficiency of the traditional maximum class variance method is low. This paper uses the cuckoo algorithm to optimize the traditional maximum class variance method to achieve a better segmentation effect. This image segmentation method combined with optimization theory can achieve the purpose of finding the optimal segmentation.


Introduction
With the rapid development of machine vision and other fields in recent years, the technology of digital image processing is becoming more and more important. Nowadays, image processing technology is used in medical image field, military image field, agriculture and industry field and so on.
Image segmentation is the basis of subsequent image processing technology such as image recognition. The quality of image segmentation results directly affects the subsequent processing results. Image segmentation technology is to divide the image into non-overlapping parts according to different characteristics. Because the traditional maximum inter-class variance method is essentially exhaustive. The inter-class variance corresponding to all gray values needs to be calculated. In order to find out the best threshold to maximize the variance between classes, the search efficiency is low. In this paper, we hope to use cuckoo optimization algorithm to optimize the optimization process of traditional inter-class variance method.

Maximum inter-class variance method
Image segmentation methods [3] include threshold-based image segmentation, region-based image segmentation, image segmentation based on edge detection, clustering-based image segmentation and neural network-based image segmentation. Threshold-based image segmentation is one of the simplest and most practical segmentation methods.
The basic principle of image segmentation based on threshold is that there will be great differences according to the gray values between different regions. If one or more threshold values are determined, the image can be divided into different regions. The specific steps are as follows: (1) to determine the threshold of image grayscale; (2) to compare the gray value of the target pixel with the threshold; (3) to classify the pixels and segment the image.
Therefore, the method of image segmentation based on threshold is very important to determine the threshold. How to determine the threshold directly affects the effect of segmentation.
The maximum inter-class variance method [2] was proposed by Japanese scholar OTSU in 1979. it is an adaptive threshold segmentation method, also known as OTSU method, abbreviated as OTSU. The basic idea is that the larger the inter-class variance of the gray value between the background and the target, the greater the difference between the background and the target. The fault of segmentation is less likely to occur. However, the smaller the variance between classes, the smaller the difference between background and target. Hence,the possibility of segmentation fault will increase. Therefore, it is possible to achieve a better segmentation effect as long as it is found that the inter-class variance of the background and the target can reach the maximum threshold value. The threshold at this moment is the best threshold.
The size of an image is M*N (the total number of pixels is M*N), and a threshold is set to divide the image into two parts: background and target. The average gray value of the image is  .N1 is the number of pixels in the background and N2 is the number of pixels targeted. Background pixel percentage w1=N1/ (M*N), and the target pixel ratio w2=N2/ (M*N).
The background average gray value: The average gray value of the target: Inter-class variance of background and target:

The improvement of maximum inter-class variance method
Because the traditional maximum class variance method is essentially exhaustive. It is necessary to calculate the inter-class variance corresponding to 256 gray values in order to find the optimal threshold that can make the inter-class variance reach the maximum. Therefore, the search efficiency of this method is relatively low. We can use cuckoo algorithm to optimize the search threshold process.
In nature, Cuckoos do not make nests, hatch eggs and raise their own children.In late spring and early summer, they often sneak their eggs into other birds' nests while other birds are out foraging. Allow the host bird to hatch its own eggs without being detected by other host birds. But during the incubation process, once the cuckoo's egg is found by another host bird, the host bird pushes the cuckoo's egg out of its nest. The cuckoo can only abandon this nest and look for other suitable nest.
In 2009, Xin-She Yang [4] and other scholars proposed the cuckoo search algorithm based on the bionic characteristics of cuckoo bird searching for the nest of host bird. Assuming that a nest of the host bird is a solution, and the process of searching for the nest of the host bird is the process of searching for the optimal solution. The cuckoo's first known path for laying eggs in the nest of a host bird is typically in the form of Levy flight. In fact, Levy flight is a very effective and practical way to find. Levy flight is also followed by many birds in nature [6]. Levy's flight is characterized by alternating long and short steps [1]. By adding Levy flight's optimization search algorithm and using the long-step search solution in the early stage of the search, the search scope can be expanded and local optimization can be avoided. In the later stage of the search, the short step length was used to search for the optimal solution [7].
In 1937 Levy proposed the integral form of symmetric Levy stable distribution. In 1992, Mantegna proposed a step size s method to obtain Levy distribution by normal distribution, referred to as Mantegna method [8]. Figure 1 is the simulation of Levy's flight trajectory using the Mantegna method.   When the host bird can find cuckoo's eggs with probability p, the cuckoo needs to choose a new nest of the host bird. The search path follows a random pattern. The fitness of the undiscovered nest is compared with that of the transferred nest. After iteration, the solution with the maximum fitness is selected as the optimal solution. Figure 3 is the segmentation effect of the most large class variance method optimized by cuckoo algorithm.

Summary
Because the efficiency of the traditional maximum class variance method is low, the optimization algorithm can be used to optimize the threshold search process. However, because many optimization algorithms are trapped in local optimal search, cuckoo optimization algorithm is considered to optimize the threshold search of the maximum inter-class variance method. Because of the characteristics of Levy's flight mode, it can reduce the occurrence of local optimum in the search process.