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.