Abstract

In this paper, the most common pepper noise in grayscale image noise is investigated in depth in the median filtering algorithm, and the improved median filtering algorithm, adaptive switching median filtering algorithm, and adaptive polar median filtering algorithm are applied to the OTSU algorithm. Two improved OTSU algorithms such as the adaptive switched median filter-based OTSU algorithm and the polar adaptive median filter-based OTSU algorithm are obtained. The experimental results show that the algorithm can better cope with grayscale images contaminated by pretzel noise, and the segmented grayscale images are not only clear but also can better retain the detailed features of grayscale images. A genetic algorithm is a kind of search algorithm with high adaptive, fast operation speed, and good global space finding ability, and it will have a good effect when applied to the threshold finding of the OTSU algorithm. However, the traditional genetic algorithm will fall into the local optimal solution in different degrees when finding the optimal threshold. The advantages of the two interpolation methods proposed in this paper are that one is the edge grayscale image interpolation algorithm using OTSU threshold adaptive segmentation and the other is the edge grayscale image interpolation algorithm using local adaptive threshold segmentation, which can accurately divide the grayscale image region according to the characteristics of different grayscale images and effectively improve the loss of grayscale image edge detail information and jagged blur caused by the classical interpolation algorithm. The visual effect of grayscale images is enhanced by selecting grayscale images from the standard grayscale image test set and interpolating them with bilinear interpolation, bucolic interpolation, NEDI interpolation, and FEOI interpolation for interpolation simulation validation. The subjective evaluation and objective evaluation, as well as the running time, are compared, respectively, showing that the method of this paper can effectively improve the quality of grayscale image interpolation.

1. Introduction

The segmentation algorithm is one of the important steps in grayscale image data analysis. Among many grayscale image segmentation algorithms, the threshold segmentation technique has the advantages of simplicity and efficiency of implementation and therefore is widely used [1]. Segmentation techniques of grayscale images have been developed for decades, and fruitful threshold segmentation algorithms have been proposed continuously. However, the threshold segmentation technique is still a hot research topic in grayscale image segmentation [2]. In the field of grayscale image segmentation, threshold segmentation is one of the most widely used grayscale image segmentation methods. In the practical application, to meet our needs, it is sometimes necessary to use multidimensional threshold segmentation methods or select multiple thresholds at the same time to achieve effective segmentation of the target grayscale image. As the number of grayscale image information dimensions or the number of selected thresholds increased, the computational complexity of the threshold segmentation algorithm increases rapidly [3]. It will take a long time, which to a certain extent limits the use of segmentation algorithms.

However, in the traditional OTSU algorithm, the search process of thresholds is done by exhausting all solutions in the gray space, so as the number of thresholds increases, the search dimension to be performed is also increasing, and the complexity is greatly increased, many unnecessary calculations are performed, the time is exponentially increasing, and the search efficiency is low [4]. Moreover, in general, the images acquired through various channels suffer from many random disturbances and conditions, so the acquired original images contain a lot of noise, which makes the features of things in the acquired original images change greatly, and if such images are analyzed directly, the understanding of the images will be greatly biased [5]. Therefore, the optimization of the OTSU algorithm to improve the computational efficiency and computational effectiveness has become a difficult as well as a hot issue. In this paper, adaptive and fast algorithms are studied for the optimization of the segmentation effect and improvement of segmentation efficiency of the OTSU algorithm.

This paper contains four chapters, and its specific chapter arrangement is as follows. Chapter 1 is the introduction. This chapter introduces the background of the research and the significance of the research, summarizes the current research status of this research content, and explains the research content and arrangement of this paper. Chapter 2 conducts the research related to adaptive and fast algorithms for grayscale image threshold segmentation, analyzes the current research status, optimizes the algorithm according to the current research, improves it in median filtering, and then applies it to the OTSU algorithm. Chapter 3 analyzes the segmentation time and algorithm performance of the improved OTSU algorithm and proves the advantages of the algorithm studied in this paper by comparing it with traditional algorithms and other related algorithms. Chapter 4 provides a summary and outlook. The research work of this paper is summarized, the research shortcomings are analyzed, and the future research development direction has prospected. In this paper, we refer to a variety of algorithms and combine the advantages of each algorithm to remove their disadvantages, so our method is more advanced.

2. Research on Grayscale Image Threshold Segmentation Algorithm

2.1. Related Work

As the dimensionality of the OTSU algorithm increases, the computational effort increases, leading to a significant decrease in computational speed, so many improvement algorithms to the OTSU algorithm have been proposed subsequently [6]. Bhandari improved the two-dimensional OTSU algorithm by dimensionality reduction to obtain a fast algorithm, which decomposes two dimensions into two one-dimension as a way to reduce the computational effort; at the same time, the interclass variance information of grayscale images is considered and a new function is constructed to find the threshold [7]. Aslam et al. proposed a fast-recursive algorithm for the 3D OTSU method to reduce the computation time of the 3D OTSU method [8]. Soeleman et al. investigated the inefficiency of the multithreshold OTSU algorithm in determining the optimal threshold value, and instead of using the exhaustive method, they proposed a fast algorithm based on the multithreshold OTSU algorithm criterion, which substantially improved the segmentation speed [9].

In addition to the improvement of the OTSU algorithm, other image processing methods have also yielded promising results. Li and Li also proposed a fast method for computing OTSU segmentation thresholds, which no longer calculates the interclass variance of grayscale images but rounds the arithmetic mean of the grayscale means of the pixel points in the target and background parts and uses it as the segmentation threshold [10]. The new algorithm effectively solves the problem that the traditional algorithm needs to perform the exhaustive calculation for each pixel point in the grayscale image when finding the OTSU segmentation threshold and improves the computational efficiency. Experiments show that the algorithm is more effective in segmenting small targets in gradient grayscale images. Zhou et al. designed a new nectar source selection method and crossover operation to guide the evolution of the population and introduced a backward learning variation strategy to improve the convergence speed of the algorithm [11]. Hu et al. proposed an improved search equation that better balances the exploration and exploitation capabilities of the algorithm [12].

From the perspective of the practical application of image segmentation, the general direction of image segmentation improvement is mainly toward improving the operational efficiency and enhancing the operation results, to achieve the purpose of combining theory and practice.

2.2. Grayscale Image Threshold Segmentation Selections

A multithreshold segmentation method incorporating fuzzy theory is used to correct for the above artifacts. In the segmentation process of fuzzy shareholding, regions are allowed to partially overlap, and the affiliation function assigns probabilities for pixels to belong to each region. This soft-threshold segmentation method can retain more information about the original grayscale image during the segmentation process, effectively avoiding the miss mentation caused by artifacts and improving the effectiveness of grayscale image segmentation [13].

To segment, the grayscale image G whether the pixel x is classified into region Q is represented by the set of S as shown in the following equation:

There are some differences in the expressions between the fuzzy Kapur entropy and the original Kapur entropy, which are mainly due to the introduction of the affiliation function. The affiliation function is fuzzily the grayscale probabilities [14]. The fuzzy Kapur entropy can be obtained according to the trapezoidal affiliation function, and when j thresholds are used to partition out k regions (k = j + 1), the maximum fuzzy entropy of the objective function is described as shown in the following equation:where Sm is the gray probability of pixel gray value m in the gray histogram G, β1, β2, and βm are the affiliation values of pixel gray value i to each segmented region, ϕ1, ϕ1, and ϕm denote the cumulative fuzzy probability of each region in the case of n segmentation thresholds, and , , and are the fuzzy entropy corresponding to each segmentation region [15]. By comparing with the objective function of multilevel hard shareholding, subtle differences can be found, and the fuzzy entropy contains more information. F (TG) can be expressed as a function ϕ with the fuzzy parameter aj as the variable, which is also the objective function to be optimized. Thus, the problem of solving the maximized fuzzy Kapur entropy is converted into the problem of solving the optimal fuzzy parameter ai as shown in the following equation:

The flow of the algorithm is obtained as shown in Figure 1. First, the original MRI grayscale image is preprocessed, and then the trapezoidal affiliation function is used to assign affiliation values to pixels, followed by the construction of the fuzzy Kapur entropy function from the grayscale histogram of the grayscale image and the affiliation of each pixel. Finally, the fuzzy Kapur entropy function is used as the objective function, and an improved quantum particle swarm algorithm is used for optimization to obtain the optimal trapezoidal affiliation function fuzzy parameters, and the threshold value for segmentation is obtained by taking the mean value of two adjacent parameters [15].

2.3. Adaptive and Fast Algorithm Research

The OTSU algorithm is used to select the segmentation threshold by maximizing the interclass variance of the grayscale image being segmented. The grayscale value variorum constructed by the two-dimensional OTSU algorithm is two-dimensional, built with the grayscale values of the pixel points of the original grayscale image and their grayscale values after the neighbourhood smoothing process, respectively [16]. For a grayscale image (m, n) of size MN whose gray level is L, let the corresponding mean grayscale image of the grayscale image be h (m, n): h (m, n) and h (m, n) and have grayscale values m and n at pixel point (m, n), respectively, then the pixel points in the grayscale images h (m, n) and (m, n) will form a grayscale image consisting of the pixel gray values and their neighbourhood average gray values form a binary group: (x, y). The frequency of occurrence of (x, y) is denoted by Ghj, and the joint probability of (x, y) is denoted by Shj.

Figure 2(a) is an uncontaminated Cameraman grayscale image of size 256 × 256, Figure 2(b) is a two-dimensional grayscale histogram projection of Figure 2(a), and Figure 2(c) is the segmentation result of executing the two-dimensional OTSU algorithm on Figure 2(a). Figure 2(a) is a Lena grayscale image of size 512 × 512 without noise contamination, Figure 2(b) is a two-dimensional grayscale histogram of Figure 2(d), and Figure 2(f) is the segmentation result of performing the two-dimensional OTSU algorithm on Figure 2(d). By looking at Figure 2, it can be seen that the binary groups of pixel gray values and neighbourhood gray values in Figures 2(b) and 2(e) are all distributed in the diagonal positions of the two-dimensional gray histogram, and they are all distributed in region B and region C in Figure 2, which clearly distinguish the pixel points in Figures 2(a) and 2(e) into the target part and the background part. The segmentation effect of the 2D OTSU algorithm is good.

The following equation can express the idea of median filtering:

If it is judged to be a noisy point after detection, the switch is placed in a state connected to the filter and the pixel is output after median filtering; if it is judged to be a normal pixel after detection, the switch is connected to a port without any processing and the pixel is output directly without processing [17]. The following equation can represent the switch median filtering algorithm:

Adaptive extremum median (AEM) filtering algorithm is an improved algorithm based on adaptive median filtering and polar median filtering, which brings together the advantages of both and determines the filtering window to a suitable size by itself according to the density of grayscale image noise points, and the filtering window is smaller when there are fewer noise points. When there are fewer noise points, the filter window is smaller so that the detailed features in the grayscale image can better restored [18]. The principle of the OTSU algorithm based on adaptive polarization and median filtering can be summarized as follows: the Max and Min operators are used as noise detection operators, and the grayscale image to be processed is scanned line by line from left to right in the adaptive window; at the same time, the pixel points located in the detection window are sorted from the large to the small or from the small to the large according to the size of the grayscale value. The remaining points are judged as uncontaminated pixels. If they are judged as noisy, they are filtered; if they are judged as non-noisy, they are not processed and are directly output as signal points to achieve the purpose of selectively processing grayscale images and retaining details while denoting [1924]. Finally, the two-dimensional OTSU algorithm operation is performed on the grayscale image to complete the segmentation.

2.4. Adaptive and Fast Algorithmic Evaluation

For grayscale image segmentation, grayscale uniformity is an important measure, often also referred to as intraregional consistency. It is since the same target in a grayscale image has a very close range of grayscale values, and the grayscale values of different targets usually have a more pronounced contrast. The effectiveness of the segmentation algorithm is measured by calculating the grayscale uniformity of the grayscale image, as shown in the following equation:

The peak signal-to-noise ratio is one of the most widely used metrics for evaluating the quality of full-reference grayscale images and error-sensitive grayscale image quality based on the idea of the error between pixel points and is described as shown in the following equation:

In this paper, based on the idea of selecting the average constant false alarm rate of large units to select the larger mean and standard deviation of the front and rear reference units, thus the threshold value of the quality factor Mb is calculated by the detector type, and the detection method provided in this paper is the maximum unit average selection detector; therefore, Mb is calculated as shown in the following equation:

When the false alarm probability Sha and the reference window n are different, the values of Mb are shown in Table 1.

3. Results Analysis

3.1. Grayscale Image Segmentation Effect Analyses

Figure 3 lists the segmentation thresholds obtained by the four methods after the segmentation of six grayscale images. In this paper, the segmentation threshold obtained by the exhaustive method is used as a reference. It can be seen from Figure 3 that the ABC algorithm and FA algorithm have poorer searchability and are prone to fall into local optimal solutions in the process of searching for the optimal thresholds, resulting that the segmentation thresholds obtained are not accurate enough. The segmentation threshold obtained by the method in this chapter is the same as that of the exhaustive method, so the global search ability of the method in this chapter is better than those of the ABC algorithm and the FA algorithm. Through the previous comparative analysis, it can be seen that for different types of grayscale images and noisy grayscale images, the method in this chapter can jump out of the local optimal solution and search for more accurate segmentation thresholds, which makes the segmentation effect significantly better than ABC and FA two-dimensional OTSU grayscale image segmentation methods and can obtain the same segmentation effect as that of the two-dimensional OTSU exhaustive segmentation method. The segmentation effect is the same as that of 2D OTSU exhaustive segmentation. Also, when segmenting noisy grayscale images, the effect of noise on the segmentation results is well suppressed. In summary, the method in this chapter can overcome the problems of ABC and FA algorithms in the process of finding local optimum and has better noise immunity and can obtain better quality segmented grayscale images.

The computation time required for segmenting six grayscale images of the above four methods is shown in Figure 4. From Figure 4, it is known that the method in this paper is 33.29 times, 1.22 times, and 1.49 times faster than the exhaustive search method, ABC algorithm, and FA algorithm, respectively, in terms of segmentation speed. With the longest operation time of the four segmentation methods, the 2D OTSU exhaustive segmentation method is mainly used because the method has to traverse all possible thresholds in the process of searching for the optimal threshold, and a total of 65536 2D OTSU functions have to be calculated, which is a large amount of computation and cannot meet the real-time segmentation. The computation is heavy and the running time is long, which cannot meet the need for real-time segmentation. The other three segmentation methods adopt the ABC algorithm, FA algorithm, and improved ABC algorithm to search for the optimal threshold, which only needs to calculate 3050 or 1500 (the maximum number of population size iterations) times of 2D OTSU function at most, so the computation of these three segmentation methods is more than that of 2D OTSU. The OTSU exhaustive segmentation method is smaller, but the running time and accuracy of the methods in this chapter are better than those of the ABC algorithm and FA algorithm. This is mainly because the method in this paper introduces the global optimal solution to guide the search direction and adopts different search equations for different types of bees, which improves the search efficiency and global search ability of the algorithm; also, it uses the simulated annealing mechanism to update the nectar source position, which effectively avoids individuals from falling into local optimum during the search process, and has the fastest segmentation speed and the highest segmentation accuracy compared with the ABC algorithm and FA algorithm.

3.2. Grayscale Image Segmentation Performance Analyses

Figure 5 shows the performance evaluation results of the algorithm for corrosion damage. From the objective evaluation index comparison, it can be observed that the segmentation of corrosion damage by the algorithm in this paper has a great improvement over the traditional OTSU, with about 31.2% improvement in area consistency, about 25.4% improvement in interval contrast, about 43.1% reduction in relative final measurement accuracy, and about 57.8% reduction in error rate. According to Figure 5, the segmentation results of this paper’s algorithm and the traditional random walk algorithm are as follows: the region consistency is improved by about 3.3%, the interval contrast is improved by about 3.2%, the relative final measurement accuracy is reduced by about 6%, and the error rate is reduced by about 2.1%. The segmentation results of this algorithm and the active contour extraction are as follows: the regional consistency is improved by about 5.4%, the interval contrast is improved by about 10%, the relative final measurement accuracy is reduced by about 11.9%, and the error rate is reduced by about 10%. From the analysis of the above results, the active contour extraction method is better than the traditional OTSU, and the algorithm in this paper has better segmentation performance than the traditional OTSU algorithm and the active contour model, with little improvement on the traditional RM algorithm.

The convergence performance of the optimization algorithm is an important index to evaluate the merit of the algorithm. To test the convergence speed of each segmentation algorithm, this paper uses the ABC algorithm, FA algorithm, and the method in this chapter to search for the optimal threshold and record the change of the global optimal solution after each iteration of the search. To ensure the objectivity of the experimental results, the number of iterations of the three algorithms is set to 100 and the population size is set to 20. The convergence curves of the three algorithms are shown in Figure 6 for the segmentation of the test grayscale images.

From Figure 6, the ABC algorithm searches up to the 62nd generation to converge; the FA algorithm needs 60 iterations to converge; the method in this chapter only needs 23 iterations to converge to the global optimal solution. It can be seen that the convergence speed of the ABC algorithm is the slowest, which is due to the problems of lack of clear search direction, single search equation, and rapid loss of population diversity in the process of searching for the optimum which makes the search efficiency of the whole population low and the convergence speed of the algorithm is slow; although the convergence speed of the FA algorithm is faster than that of the ABC algorithm, its global search ability is poor and it is easy to converge to the local optimum in the process of iteration. The FA algorithm converges faster than the ABC algorithm, but its global search ability is poor, and it is easy to converge to the local optimum during iteration. This paper improves the search equation of the basic ABC algorithm and introduces the simulated annealing mechanism to update the nectar source. In the process of grayscale image segmentation, the improved ABC algorithm converges significantly faster than ABC and FA algorithms and can quickly search for more accurate optimal thresholds.

3.3. Practical Analyses of Grayscale Image Segmentation

Figure 7 shows the segmentation thresholds obtained by the conventional OTSU algorithm and the present algorithm for Lena grayscale image, Cameraman grayscale image, and Peppers grayscale image, respectively. By comparing the thresholds obtained under the conventional algorithm and this algorithm, it is found that the thresholds of this algorithm are very little and the fluctuations are not much different from the optimal thresholds obtained under the conventional algorithm, which proves that the algorithm has good stability and is effective in improving the OTSU algorithm.

The segmentation result of the traditional OTSU algorithm on the noise-contaminated image is not ideal. When the pepper noise with the intensity of 0.25 is added to the image, the segmentation results of the two algorithms show an obvious difference. When the pepper noise strength of 0.55 is added to the image, the segmentation results of the two algorithms appear with more obvious differences, the image segmented by the traditional OTSU algorithm has been seriously contaminated by noise, and the image becomes very blurred, while the effect of segmentation by the algorithm of this paper is still very good, the picture is clear and maintains the detail characteristics of the original image. The experimental results show that the algorithm of this paper can cope with the image contaminated by noise very well, and the more noise intensity can reflect the superiority of this algorithm. Figure 8 shows the time comparison between the traditional OTSU algorithm and this algorithm to find the optimal threshold for different grayscale images. The experimental results prove that this algorithm has better stability and faster operation speed while maintaining better stability.

To objectively evaluate the advantages of the algorithm in this paper, the peak signal-to-noise ratio (PSNR) of the grayscale images processed by different interpolation algorithms is calculated separately, and the PSNR reflects the difference between the interpolated grayscale image and the original grayscale image. Figure 9 shows that the interpolation algorithm in this paper has the highest PSNR. It shows that the algorithm in this paper can better maintain the edge detail information of the grayscale image. To objectively evaluate the advantages and disadvantages of different interpolation methods, the peak signal-to-noise ratio (PSNR) of the grayscale images processed by different interpolation algorithms is calculated separately, and the PSNR reflects the difference between the interpolated grayscale image and the original grayscale image. The closer the interpolated grayscale image is to the original grayscale image, the better the grayscale image quality is. Figure 9 shows that the interpolation method in this paper has the highest PSNR value, and compared with other interpolation methods, the peak signal-to-noise ratio of this paper is higher than 0.45 dB on average. The experimental results show that the interpolation algorithm proposed in this section can better maintain the texture detail information at the edges of grayscale images.

4. Conclusion

This thesis firstly introduces the research significance, research progress, and basic algorithmic knowledge of grayscale image segmentation, focuses on the two-dimensional OTSU algorithm, then applies the good features of other algorithms to the OTSU algorithm for the shortcomings of the traditional OTSU algorithm to complement each other’s strengths and weaknesses, proposes its improvement scheme, and verifies the effectiveness of this paper’s algorithm through experiments. The two-dimensional OTSU algorithm has poor noise immunity for grayscale images contaminated by high-intensity noise, and the results are often not very satisfactory if the images are segmented directly by it. In the face of the problem that the traditional OTSU algorithm cannot cope with the strong noise, the excellent performance of median filtering to remove noise is applied to the OTSU algorithm. In this paper, we firstly improve the median filtering, then apply the improved algorithm to OTSU, and propose the OTSU algorithm based on adaptive switching median filtering and the OTSU algorithm based on adaptive polar median filtering. Through experimental comparison and analysis, the algorithms in this paper still have good grayscale image segmentation results in the face of high-intensity noise, and the grayscale image segmentation effect is much better than the performance of the traditional OTSU algorithm. In the face of the time-consuming problem of the traditional OTSU algorithm in finding the optimal threshold, the excellent performance of the genetic algorithm for finding the optimal solution very efficiently is applied to the OTSU algorithm. In this paper, we firstly discuss the problem that the traditional genetic algorithm tends to fall into local optimum when finding the optimal solution and then apply the improved genetic algorithm to OTSU and propose the OTSU algorithm based on the improved genetic algorithm. Through experimental comparison and analysis, the algorithm in this paper does a better job in preserving the detail features of grayscale images, and the segmentation effect is significantly better than that of the traditional OTSU algorithm, and the operation speed is faster, which shortens the time to find the optimal solution of the algorithm. This paper, as well as most of the current methods, is only applicable to static, grayscale images, but not to color, dynamic grayscale images. With the rise of artificial intelligence and other fields, the segmentation of color, as well as dynamic grayscale images will become increasingly demanding, so future grayscale image segmentation in response to color grayscale images and dynamic grayscale images needs further research and exploration.

Data Availability

The data used to support the findings of this study are available from the corresponding author upon request.

Conflicts of Interest

The author declares that there are no conflicts of interest or personal relationships that could have appeared to influence the work reported in this paper.