Bubble Image Segmentation Based on a Novel Watershed Algorithm With an Optimized Mark and Edge Constraint

Bubble size contains important indication information that is closely related to flotation production conditions and process indicators. However, bubble images often have low contrast, noise, and many other shortcomings, making foam segmentation a difficult problem that the existing segmentation methods cannot solve. In this article, an improved watershed algorithm based on optimal labeling and edge constraints is proposed. Three algorithms are designed to obtain different initial tags, and then the extracted content of different tags is fused to obtain the combined foreground tag. To reduce the offset of the segmentation line, the edge operator is applied to extract the bubble boundary, and the boundary priori condition is used as a constraint to correct the segmentation line. Finally, the optimal segmentation line is obtained by fusing foreground markers and external constraints. Industrial experiments show that this method is effective and has a higher accuracy than the other methods. The average value and variance of rand index (RI) are 92.88% and 0.69, respectively.


I. INTRODUCTION
I N THE visual characteristics of the foam surface, the shape of the foam and the size distribution of bubbles are the most easily observed foam morphology characteristics. They have a high correlation with the performance of froth flotation [1], [2]. Therefore, accurate segmentation of flotation froth images is very important for the flotation process. The flotation froth image has the following characteristics, making accurate segmentation face many challenges. First, bubble images do not distinguish between foreground and background. At the same time, foam is a nonrigid object, and bubbles stick together. The foreground and background cannot be separated to obtain foreground information. Second, foam images belong to lowcontrast images. The edges formed between foams are not clear, and multilayer bubbles are stacked together to make bubbles appear as dark blocks, which has a huge impact on edge recognition. Third, because of the emergence of multiple light sources, there will be several central bright spots in each bubble, resulting in the number of bubbles inaccurately judged based on the number of bright dots they have. Even forming bright edges at the bubble boundary results in over-segmentation of the algorithm. Finally, there are many white spot noises on the foam image, where part of the noise comes from the camera, and the other part comes from impurities in the flotation process. The noise of the white spot will also affect the segmentation result of the flotation froth.
Due to the characteristics of bubble images, the watershed algorithm is an effective method to measure the size of bubbles. The disadvantage of the watershed algorithm is oversegmentation. Therefore, many improved methods have been proposed at home and abroad, including hierarchical watershed segmentation [3], [4], watershed segmentation based on merging [5]- [7], and watershed segmentation algorithms based on marking [8]- [25]. Arbelaez et al. [4] simplified the image segmentation problem into a contour detection problem and refined the segmentation results by hierarchical segmentation. Zhang et al. [5] proposed using a region merging algorithm and watershed algorithm to combine and segment images in lab color space. In the same year, Zhang proposed the Luv color space as the regional similarity measure of regional merging and used the watershed algorithm for segmentation. However, both hierarchical watershed segmentation and merge-based watershed segmentation take a long time, and their segmentation efficiency and accuracy are far lower than those of marker-based watershed algorithms. Therefore, the marker-based watershed algorithm has become the mainstream segmentation method for foam images. Xie et al. [8] used a polynomial fitting gray histogram curve and the Ostu algorithm to separate foam images. Zhang et al. [9] optimized the watershed algorithm by identifying adjacent cells, but these methods did not achieve good results. Zhou and Zhou [12] proposed an edge detection method based on the fuzzy ternary mode, which uses a bubble edge membership matrix to realize edge detection. Tian et al. [15] applied the particle swarm optimization algorithm and fuzzy C means (FCM) algorithm to extract foam foreground markers showing a slight increase in accuracy. Jahedsaravani et al. [16] designed a neural network to train a subimage classifier to obtain key parameters to deal with different sizes of foam images and then divided them by a watershed algorithm. However, for adaptive bubbles with a This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/ large amount of noise and bright edges, the adaptive threshold method cannot reduce the interference of nonbubble highlights and cannot obtain good segmentation results. To solve the problem of [16], Zhang et al. [17] proposed a watershed algorithm based on optimal labeling. In this algorithm, the data are fused with three kinds of labeled areas, and the overlapping markers are combined and optimized. The algorithm enhances the segmentation and extraction of overlapping foreground markers, but interference problems, such as noise and bright edges, are still unresolved, resulting in the offset of segmentation lines. Liang et al. [18] adopted FCM algorithm clustering to extract the foam foreground markers and used the bright edge to change the gradient map to correct the offset of the segmentation line. However, morphological extraction will extract some foreground markers as bright edges and cannot achieve good segmentation results on images containing small bubbles.
Due to the above problems, this article considers the following points to improve the algorithm. 1) To extract more promising and robust foreground markers in flotation froth images of different times, we choose three algorithms (the FCM algorithm, the morphological reconstruction method, and the adaptive threshold method) to extract and fuse the foam foreground markers. 2) To reduce the influence of bright edge and white point noise on the segmentation line migration, we use the Gauss Laplace operator and morphological operator to extract the edge of the bubble image and use the edge line to reconstruct the gradient map to form a constraint on the watershed algorithm. 3) By fusing foreground markers and edge line constraints and then applying them to the watershed algorithm, the segmentation results are obtained.
The rest of this article is arranged as follows: Section II introduces the methods used in this article, including the framework of the proposed method, the preprocessing procedure, and the detailed explanation of foreground markers and boundary constraints. Section III presents the experimental results and the discussion. Section IV summarizes the full text.

A. Framework of the Proposed Method
The method proposed in this article can be summarized by the overall framework diagram shown in Fig. 1. The preprocessing part includes image enhancement using a multiscale retinex algorithm (MSR) and denoising with bilateral filtering to realize the optimal extraction of foreground markers and constraint lines. In the process of foreground marker extraction, the FCM algorithm, morphological reconstruction method, and the adaptive threshold method are used to combine the extracted markers to form an optimization mark, corresponding to the number and size of the bubbles. Second, the Gauss Laplace operator is used to filter the image and is combined with a morphological gradient to form a rough segmentation contour, which is used as the constraint condition of the watershed algorithm. The rough segmentation contour reduces the deviation of the regional segmentation line of the watershed algorithm to a certain extent, and the segmentation accuracy of the watershed algorithm is improved under the optimal marking and constraint conditions.

B. Image Preprocessing
A bubble image is a low-contrast image. Thus, blurred boundaries or even dark blocks can be seen in the bubble image, resulting in the edge shift of foam segmentation. At the same time, because there are multiple light sources in the image, more than one bright spot is on the surface of some bubbles. There is also a high gray value bright edge between the foam, resulting in over-segmentation of the foam image. The bubble image is shown in Fig. 2. The red circle area is the bright edge, which is caused by the illumination of the foam edge. The blue circle area contains many highlights and noise. This is mainly because the foam contains many impurities, which has a very serious impact on the extraction of foam foreground markers. The green block area is a dark block, mainly caused by insufficient illumination. These factors cause serious interference with the extraction of foreground markers. Therefore, the foam images need to be preprocessed before foreground markers are applied.
1) Image Enhancement Based on MSR Algorithm: In the flotation process, the foam generally shows a low gray value. The foam image captured by the camera often has a low contrast and uneven brightness. The foam center is a bright spot, while the edge is very indistinct or even has a dark block, as shown in Fig. 3(a). To solve this problem, this article proposes using an MSR algorithm to preprocess images.
The MSR algorithm divides image I (x, y) into reflected image R(x, y) and incident image L(x, y), as shown in the following equation: R(x, y) represents the internal attribute of the object to be retained, and L(x, y) determines the dynamic range of image pixels and needs to be removed as much as possible. Generally, we assume that the incident image is a spatially smooth image, as shown in the following formula: where r (x, y) is the output image, F(x, y) is the spatial smoothing kernel, and generally the Gaussian smoothing kernel. The importance of the MSR algorithm is to calculate the difference between image pixels and the surrounding areas under the action of weighted averaging, remove L(x, y) from the original image, and retain the original attributes of the object, and the implementation effect is shown in Fig. 3(b).
2) Bilateral Filtering: There are many unsmoothed textures on the surface area of the foam, which lead to many small white dots in the foreground segmentation. Therefore, the bubble image needs to be filtered first. Bilateral filtering is a nonlinear filtering method that can filter the image combined with image space and gray information, maintaining the clarity of the boundary while reducing noise. The formula of bilateral filtering is as follows: Bilateral filtering has two core variables to measure image information, among which G σ S is the spatial domain core, G σ r is the pixel domain core, p and q represent the coordinates of two pixels, and the function I (•) represents the gray value of a certain coordinate. The spatial domain kernel is generally a 2-D Gaussian function, which can be used as a Gaussian filter. The pixel domain kernel represents the severity of pixel change. When it is in the flat area of the image, the weight of the pixel domain kernel decreases, and the spatial domain kernel, the Gaussian kernel, plays a leading role in smoothing the image. When it is at the edge, the pixel domain kernel plays a leading role and retains the edge information. The calculation method of the spatial domain core and pixel domain core is shown in the following formula: where σ S and σ r are known, (i, j ) represents the center value of the window, and (m, n) represents a value in the sliding window. Using bilateral filtering to smooth the bubble image can help the center highlight of the bubble fuse the noise points nearby and achieve a better foreground marker. The filtering effect is shown in Fig. 4.

C. Foreground Mark Extraction
The extraction of foreground markers can directly determine the location and quantity of foam segmentation regions. Therefore, foreground markers are very important for the implementation of watershed algorithms. A single algorithm has uniqueness for foreground marker extraction of foam images, the effect of foreground extraction depends entirely on the accuracy of a single algorithm, and it cannot adapt to different situations, such as dark blocks and bright edges. The use of a variety of algorithms to extract the bubble center highlights and the combination strategy to remove the interference markers can make the foreground markers more credible and robust. Therefore, this article first morphologically preprocessed the foam image and then combined the foreground markers extracted from the three algorithms to obtain the markup, which greatly improved the segmentation accuracy of the watershed algorithm.
1) Morphological Processing: Foreground markers contain foam center highlights, bright edges, and a large amount of noise. Therefore, before extracting foreground markers, we first consider using morphological operations to process preprocessed pictures. In this article, morphological top-hat operations and morphological bottom-hat operations are used to obtain the bright edge. Then the original image is subtracted from the bright edge, and morphological reconstruction is used to remove the bright edge and noise. The specific steps are shown in Fig. 5. From The closed operation can be expressed as where represents the corrosion operation and ⊕ represents the expansion operation. Therefore, the open operation can be expressed as the structural element b performing a corrosion operation on the image f first and then the expansion operation. The closed operation can be expressed as the structural we use the image f o as the marker image for the reconstruction operation and f oc is obtained. Next, we use the closed operation to obtain the template g oc for the reconstruction operation and to obtain the final processed image f ocr .
2) Optimal Marker Extraction: Due to the low contrast of bubble images and the existence of a large number of white dots and bright edges, this article adopts multimark fusion to extract foreground markers. The initial marking is divided into a first marking area, a second marking area, and a third marking area. The first marker region is obtained by clustering the bubble image by the FCM algorithm. The center spot of most high gray values can be accurately extracted without the influence of bright edges. The second marker region is extracted by the morphological reconstruction method, which can extract the bright spots in the region with low contrast and supplement some foreground markers. The third marked area uses the adaptive threshold method to extract the image, which can extract most of the image highlights and supplement the marks extracted from the first marked area. In this article, we first remove the noise and bright edges in bubble images using morphological processing, analyze the advantages and disadvantages of the foreground markers extracted by the three methods, and combine different markers to achieve the final extraction of the foreground markers.
The first marker area is obtained by the FCM algorithm to extract the bubble images. The first marker region contains bright spots with high gray values in the bubble image. The FCM algorithm is a combination of the K-means algorithm and the fuzzy theory. It can obtain the membership of each sample to all class centers by iteratively optimizing the objective function without relying on a priori conditions to realize the fuzzy clustering of data. In short, the objective loss function needs to be minimized where x i is the i th sample in the input dataset X = {x 1 , x 2 , . . . , x N }, which represents the i th picture to be the input. Each picture needs to be tiled into a row of data during input. The number of clusters to be clustered is C, and c j is the center of cluster J . u m i j indicates the membership degree of sample x i belonging to the Class J cluster, whose value is between 0 and 1. The sum of the membership degrees of a dataset is 1. m is a fuzzy weighted index, which is used to control the incidence of membership degree. * can be any measure of distance, generally using Euclidean distance. λ i is the Lagrange multiplier.
The most important parameter in FCM is the number of clusters C. When the setting of the parameter is too large, it leads to the clustering of the highlight points, resulting in insufficient extraction of the foreground markers. At the same time, the setting of the parameters is too small, which results in the occurrence of many adhesion highlights and cannot correspond to each bubble, causing the failure of foreground marker extraction. In addition to the central highlight of the high gray value and edge, there is a gray area between the two sides of the bubble image where the color gradually changes from white to black. This region is in a low-contrast state with the edge. However, after image preprocessing, the bubble image can be directly divided into three categories: highlight point, gray area, and edge. Therefore, this article sets the number of clusters to 3 and extracts the position covered by the cluster with the smallest region, the highlight with degree value, as the result of the FCM algorithm. After morphological processing and the FCM algorithm, the image segmentation results are shown in Fig. 6.
The second marker region is obtained by the morphological reconstruction method, in which the threshold h needs to be selected. In this article, we use adaptive thresholds to achieve two thresholds: the first one is used to extract most of the center points of the large foam, which may contain adhesion foam bright spots; the second is used to extract most of the foam center highlights and contains less adhesive foam. The threshold value of the second marking area is set as follows: where λ is the scale coefficient set in this article. When different scale coefficients are selected, the foreground marker will also change.
The third labeled region is obtained directly from the Ostu method, which contains almost all bubble bright spots, but the adhesion is serious and will result in under-segmentation.
To make the foreground marker accurate and reliable, this article extracts the above three marker regions, selects the appropriate threshold, combines all kinds of marker regions, and finally forms the combined marker required by the watershed algorithm. The specific steps are as follows. a) Step 1, initialization mark area: The first marker area S1 init , which has no adhesion mark and contains most bubble center highlights, is initialized. We divide the second marker area into two regions, S2 Sinit and S2 Minit , corresponding to the foreground marker area extracted from low-depth and highdepth thresholds. The low-threshold value extraction area does not contain adhesion markers, but only some foam highlights. The high-threshold extraction area contains some adhesive regions with a small number of large bubble markers. The third labeled region is initialized as S3 init , which contains a large number of adhesion regions and contains almost all bubble markers, including a large amount of noise. b) Step 2, Small bubble marker combination: The first marker area contains most of the bubble highlights, including small bubble highlights, while the second marker also contains a large number of central bright spots in the low depth area. Then, we merge the bubble spots in the two regions to obtain the merging area. The third marker area contains a large number of small bubble marker areas. Therefore, the intersection area and the third marker region intersect to obtain the small bubble area combination mark S small . S small is calculated as follows:

c) Step 3, large bubble mark extraction:
The third marker area contains a large number of foam high-bright areas, but most of the labeled areas are adhesive regions, while the second labeled high-depth regions contain a large number of large bubble markers. The regions with areas larger than the area threshold S thre in the third region are extracted and intersect with second labeled high-depth regions. A large bubble combination marker S big is obtained. S big is calculated as follows: The function QS() is the area calculation function of the connected region in the marked graph. d) Step 4, combinatorial marker merging: Finally, we merge the small bubble combination mark and the large bubble combination mark to obtain the final optimization mark S opt . S opt is calculated as follows: The extraction of combined markers improves the accuracy of the watershed algorithm and reduces the over-segmentation of the algorithm. Compared with the foreground markers extracted by one method, the extraction of multiple combined markers realized in this article is more reasonable and robust, which makes a further improvement for implementing the watershed algorithm.

D. External Constraint Line Extraction and the Watershed Algorithm
After obtaining the foreground marker, it is necessary to reverse the image to obtain the gradient map and then set the foreground marker to the lowest gray value of the image, which is equivalent to the catchment basin in the watershed algorithm. At this time, the gradient image can be segmented based on the marker watershed algorithm. The algorithm implementation process occurs when the water rises from the position with the lowest gradient to the position with the highest gradient. When the water in two different basins make contact, the watershed ridge is formed until all of the catchment basins are covered, and finally, the watershed ridge is the segmentation result. In the gradient graph, the part of the original image with a low gray value will become a split line. However, because the bubble image has low contrast, even after image enhancement, there are still many dark blocks in the bubble image, and these dark blocks tend to aggregate from the edge of the foam line to the bright spot of the foam center, causing the ridge line to be shifted to the foam center bright spot during the segmentation process. Thus, the segmentation line of the algorithm is offset from the actual edge.
In this article, a watershed algorithm based on edge constraints is proposed to solve the above problems. By combining the Gauss Laplace operator and morphological operator, the edge line is extracted, and the effective edge is extracted by a threshold. The effective edge is set to the maximum gradient on the gradient graph. Thus, the watershed algorithm can be constrained by the effective edges when forming the watershed ridge, which will correct the offset of the split line.
The Gaussian Laplace operator is an anisotropic filter obtained by the combination of Gaussian blur and the Laplace operator, which has strong anti-interference to noise. The morphological gradient is the different image obtained from the expanded image minus the corroded image, which can extract the texture and edge of the foam surface.
The Gaussian Laplace operator is obtained by adding the second-order derivative of the Gaussian convolution function. The gray value of the image pixel is I (x, y), and the corresponding Laplace operator L(x, y) is shown as The 2-D Gaussian smooth convolution kernel G σ (x, y) is as follows: The Gaussian Laplace kernel G σ (x, y) can be obtained by adding the second-order partial derivatives of the Gaussian function in the X-and Y -directions. The formula is Due to the complexity of the bubble image, other edge operators, such as Sobel and Prewitt, not only extract edges at the bubble boundary, but also the edge extracted from the unstable texture of the foam surface. Then, the effect of extraction is far less than that of the Gauss Laplace operator. The comparison of edge extraction of each edge operator is shown in Fig. 7. It can be seen from the comparison figure that the edge extracted by the Sobel, Roberts, and Prewitt operators is  discontinuous. The Canny operator extracts a large amount of texture information rather than edge information, while the Gaussian Laplace operator extracts clear edges and a small amount of texture information. The texture information can be removed by threshold processing, and the required edges can be retained. The reasons why the method proposed in this article is better than other methods are as follows.
1) The foam surface has uneven texture, which causes great interference to the first derivative, such as Sobel and Roberts, resulting in a large number of edge lines inside the foam. 2) The low contrast of foam images leads to the unclear boundary of bubbles, and a large amount of white dot noise affects the continuity of the first derivative.
The Gaussian Laplace operator is a second derivative operator that can highlight the region where the intensity changes rapidly in the image and is not sensitive to the change in the smooth transition region; thus, the extracted edge is the clearest. The morphological gradient can also extract clear and continuous edges, but it can extract a large amount of texture information. The effect diagram of the combination of the two methods and final extraction is shown in Fig. 8. After the threshold is extracted, the edge is set to the highest gradient on the gradient map. From the above picture, we can see that the edge of the bubble center also contains the edge because the foam center bright spot and the gray area also have obvious boundaries. Therefore, the edge will be left for the realization of edge extraction by the Gauss Laplace operator. The solution in this article is to set the highest edge gradient on the gradient map first, then expand the extracted foreground markers through morphological processing, and set it as the minimum gradient on the gradient map to cover the edges of the foam interior, finally achieving a watershed algorithm.

III. QUALITATIVE AND QUANTITATIVE EVALUATIONS OF SEGMENTATION EXPERIMENTS
All of the experimental data are from videos of the lead and zinc flotation plants in Shaoguan, Guangdong, China. The video duration was 10 s, and the flotation process was photographed every 20 min. In this article, seven videos are randomly selected from the database and then two images are intercepted in the video with an image resolution of 692 pixels × 518 pixels. The image basically contains the foam from the early stages to the late stages of flotation. With the amount of mineral in the foam support, the foam image of the pre-and late stages is characterized by a gradual decrease in the foam size and a gradual increase in the color with the flotation process. The experimental part of this article is divided into qualitative and quantitative evaluations of segmentation experiments.

A. Qualitative Evaluation of Segmentation
In this part of the experiment, three different sizes of foam images are selected to qualitatively evaluate the segmentation method, as shown in Fig. 9. In the small froth image, there are many white dots and dark blocks. The boundary between bubbles is not obvious, while bright edges are easily mistaken for center bubble highlights. In the middle-sized froth image, bubbles contain considerable texture noise and impurities, which easily cause over-segmentation. The large size froth image contains a small amount of noise and impurities.
Three methods were used in the experiment: the method of [17], the method of [18], and the method of this article. These methods were used for edge segmentation of three standard bubble images. Zhang et al. [17] used optimized markers to realize the watershed algorithm, and [18] used the FCM algorithm to extract foreground markers and morphology to extract bright edges to correct the segmentation line. Both articles have achieved good results in the current mainstream watershed algorithm.
In small-sized froth images, we can see that the number of bubbles separated by the methods of [17] and [18] is similar to the method proposed in this article. However, the division line offset is much more serious than that of the method proposed in this article, as shown in Fig. 10. Compared with the division line at the white circle in the figure, the method used in [17] and [18] has an edge offset when dividing the edge with a bright edge, as shown in Fig. 10(a) and (b). This is because when there are only foreground markers, the bright edge and dark block on the gradient map will lead to a low gradient basin and a continuous high gradient area in the gradient map, which results in the offset of the division line. The method proposed in this article corrects the edge of the segmentation line through the edge constraint line, which is much better than the other two methods, as shown in Fig. 10(c).
Observing the middle-sized froth image, we can see that the bubble segmentation line extracted by the method of [18] is not as smooth as the method of [17] or of the method proposed in this article. In addition, many bright edges are wrongly judged to be the highlight of the bubble center, resulting in segmentation errors, as shown in Fig. 11. It can be seen from the white circle in Fig. 11(b) that when [18] deals with the bright edges of the two bubbles, the bright edge is also used as part of the foreground marker, resulting in double dividing lines. The results of [17] and this article are shown in Fig. 11(b) and (c), which further illustrate the uniqueness and instability of the single algorithm for foreground marker extraction. Therefore, in this article, we use combination markers to adapt to different shapes of foam center highlights, reduce the extraction of error marks, and reduce the jitter and offset of the segmentation line, which is more reasonable than using a single algorithm.
The large froth image is the bubble image in the early stage of flotation. The size of the bubble is larger, and the noise of impurities and white spots is relatively small. Therefore, the effect diagrams of the three algorithms are not very different.

B. Quantitative Evaluation of Segmentation
In this article, the rand index (RI) is used to quantitatively estimate image segmentation. The RI is a better segmentation function, and its value is between [0, 1]. When the clustering result is closer to 1, the segmentation result is closer to the real result. Suppose U is the external evaluation standard, that is, the real segmentation result, and the clustering result is V . Four statistics are set: a is the logarithm of data points of the same class U and belongs to the same class in V ; b is the logarithm of data points of the same class U , but the different classes in V , c is the logarithm of data points that are not of the same class U , though belong to the same class in V ; and d is the logarithm of data points that are of different classes U and the different classes in V .
At this time, the RI can be expressed as In the experiment, 14 bubble images were collected from the database. In this article, bubble images are manually tagged by experienced experts and because the edges of bubbles can be easily detected by human eyes, manually annotated images are set to the ground-truth segmentation results. The segmentation result of the algorithm will be directly compared with the manually segmented image. Comparing the image segmented by the method shown in [17], the method shown in [18] and the method in this article with the ground-truth calculate the RI according to (17), and the RI calculation results are shown in Fig. 12.
The following situations can be found from the figure.
1) The overall segmentation effect of the method implemented in this article is higher than that of the other two methods, and the segmentation result is closer to the ground truth.
2) The method implemented in this article is more volatile than the method shown in [18]. 3) For some bubble images (such as the eighth and tenth pictures), the RI of the three methods is approximate because the bubbles in these pictures are large foams with fewer impurities and noise and no obvious dark edges or bright edges on the edges. Therefore, the foreground markers extracted by the three methods are similar, and the segmentation results are also similar. 4) In most cases, the method proposed in this article and the method used in [17] are better than the methods used in [18], but there is a different situation in the seventh picture.
We observed seven graphs and found that there were more small bubbles in the graph. Such small bubbles often cause over-segmentation of the images. Therefore, in the method proposed in this article, for such small bubbles, morphological processing reduces the extraction of foreground markers, but it causes subsegmentation. In [18], the method relies on the FCM algorithm to extract the center bright spot. Then, the segmentation effect is slightly better in the small foam than that of the method proposed by this article and the method shown in [17]. Therefore, it is also clear that the extraction of foreground markers has a very important impact on the results of the watershed algorithm.
In this article, the average valueR and varianceσ of the RI results are calculated, as well as the sum of the difference ratio SR and Sσ between the proposed method and the other two methods, which more directly explains the segmentation comparison results. The statistical results are shown in Table I.
It can be seen from the table that the method used in this article has the highest average value on RI, which can achieve better segmentation results compared with the other two methods. The variance is lower than the method shown in [17] because the volatility of a single algorithm is larger and higher than the method shown in [18], meaning that the method proposed in this article can achieve a better segmentation effect in the segmentation of foam images with bright edges or dark blocks, which verifies the effectiveness of the proposed method.

IV. CONCLUSION
The marker-based watershed algorithm is a commonly used algorithm for foam segmentation. In the algorithm, the extraction of marks is very important. However, image segmentation based on markers often causes the offset of the segmentation line in the foam image. In this article, we propose a watershed algorithm for extracting combination markers and edge constraints. There are two main contributions. 1) We propose extracting foreground markers by using multiple markup combinations. Due to the bubble images in complex situations, we use the FCM algorithm, morphological reconstruction method, and the adaptive threshold method to extract and fuse the foam foreground markers. Additionally, the integrity of the foreground markers is improved. 2) Due to the migration of the segmentation line on the foam image, we propose to use the edge constraint to correct the segmentation line. In this article, we use the Gauss Laplace operator and morphological operator to extract the edge line and reestablish the gradient constraint for the gradient graph to reduce the offset line shift caused by the bright edge and the dark block. Through experimental comparison, the segmentation line extracted by the method used in this article is closer to the ground truth, and the average value and variance of RI are 92.88% and 0.69, respectively. At the same time, there are also some problems that cannot be solved well.
1) One problem that was not resolved was reducing oversegmentation. In the foam images containing a large number of small bubbles, the algorithm will reduce the foreground marker extraction, resulting in some small bubbles lacking segmentation. 2) In edge extraction, the effect of using the Gauss Laplace operator and morphological operator cannot achieve the best effect. The edge will also appear in the center of the bubble and the gray area, which will have an impact on the constraint effect. In the future, we will continue to study bubble images and recover dark patches under different conditions to enhance the efficiency and accuracy of foam segmentation.