Foreground segmentation and location of coal and gangue under complex similar background

To improve the foreground segmentation and location accuracy of complex coal gangue images with gray histogram distribution close to the unimodal shape, a contour detection algorithm of the grayscale fluctuation matrix is proposed. The contour and non-contour pixels of coal and gangue images are investigated, and the result indicates that the gray values of the pixels around the contour exhibit the non-uniform distribution, and the gray value changes in different directions are significantly different. Accordingly, a grayscale fluctuation matrix is built by calculating the change amplitude of pixels in different directions, and multiple features are extracted from the grayscale fluctuation matrix to realize the target contour segmentation. Furthermore, the contour is optimized using the historical and future information of the contour image, thus effectively removing numerous false contours, reproducing some hidden contours and increasing segmentation accuracy. This method has high accuracy, and the maximum error rates of the pixel area and center coordinate of contour detection are 4.404% and 3.18% respectively. This study provides a feasible solution to the edge detection and segmentation of images with similar and complex backgrounds.