Splitting ore from X-ray image based on improved robust concave-point algorithm

Image segmentation is a key part of ore separation process based on X-ray images, and its segmentation result directly affects the accuracy of ore classification. In the field of ore production, the conventional segmentation method is difficult to meet the requirements of real-time, robustness and accuracy during ore segmentation process. In order to solve the above problems, this article proposes an ore segmentation method dealing with pseudo-dual-energy X-ray image which is composed of contour extraction module, concave point detection module and concave point matching module. In the contour extraction module, the image is firstly cut into two parts with high and low energy, then the adaptive threshold is used to obtain the ore binary image. After filtering and morphological operation, the image contour is obtained from the binary image. Concave point detection module uses vector to detect concave points on contour. As the main contribution of this article, the concave point matching module can remove the influence of boundary interference concave points by drawing the auxiliary line and judging the relative position of auxiliary line and ore contour. With the matching concave points connected, the whole ore segmentation is completed. In order to verify the effectiveness of this method, a comparative experiment was conducted between the proposed method and conventional segmentation method using X-ray images of antimony ore as data samples. The result of industrial experiment shows that the proposed intelligent segmentation method can remove the interference of pseudo concave points on the contour, achieve accuracy segmentation result, and satisfy the requirements of processing X-ray image of ore.


INTRODUCTION
In the process of ore production, separation is an indispensable procedure, the effect of ore separation directly determines whether the raw ore can be fully utilized. At present, the main beneficiation methods are hand separation, gravity separation, floating separation, and so on (Qin et al., 2017). Among them, hand selection is based on the difference in color, luster and shape between target minerals and gangue in raw ore. Although laborious, this method can often obtain a higher grade concentrate. Gravity separation makes use of the density difference of ore and gangue. Floating separation is the main method for mineral extraction, but it is not suitable for all minerals. Taking antimony ore as an example, while antimony sulfide is a floating minera, antimony oxide belongs to refractory ore. Above methods have very significant problems, such as low identification accuracy, requiring of large space and higher investment costs, etc.
With the development of computer science and image processing technology, machine vision has been applied in the field of mineral separation (Jung & Choi, 2021) in recent years. Separation method based on dual-energy X-ray has attracted more and more attention. Scholars have carried out a lot of research on mineral separation. While most of the research focuses on how to conduct the separation according to the physical characteristics of ore itself (Von Ketelhodt & Bergmann, 2010), there are few researches on the separation of adherent ores.
The traditional image segmentation process mainly uses the methods based on threshold, edge, region and clustering. The essence of image segmentation method based on threshold (Otsu, 1979) is to classify image gray histogram by setting different gray threshold values (Huang, Zheng & Liang, 2020). Edge detection (Rosenfeld, 1981) consists of serial edge detection and parallel edge detection (Khan, Bhuiyan & Adhami, 2011). The serial edge detection method first detects the starting point of the edge, from which the adjacent edge points are searched and connected by the similarity criterion to complete the image edge detection; The parallel edge detection method is segmented by using the spatial calculus algorithm and convolving its template with the image in parallel. In practice, the parallel edge detection method can complete the segmentation by convolution directly with differential operators such as Robers (Rosenfeld, 1981), Sober (Gao et al., 2010) and Canny (Er-sen et al., 2009). The region based image segmentation method uses the spatial information of the image for classification, and there are many methods (Pham, Xu & Prince, 2000), among which the region growing algorithms, spliting and merging algorithm (Tremeau & Borel, 1997) and watershed algorithm (Chandra, Supraja & Bhavana, 2017) are the most commonly used methods. The region growing algorithms collects pixels with similar properties to form independent regions to get segmentation results. The essence of the spliting and merging algorithm is to get each sub-region of the image by constantly splitting and merging. The watershed algorithm (Liu, 2019;Chien, Huang & Chen, 2003) treats the image it operates as a topographic map, in which the brightness value of each pixel represents its height. The image segmentation method based on clustering (Huang, Zheng & Liang, 2020, Rosenfeld, 1981 gathers pixels with similar features into the same area, iterates and converges the clustering results repeatedly, and finally divides all pixels into several different categories to get the segmentation results. With the development of deep learning, convolutional neural network has been introduced into the field of image segmentation as an important means of image processing. It can make full use of the semantic information of the image to realize the segmentation of the image. A series of image semantic segmentation methods based on deep learning, such as FCN (Long, Shelhamer & Darrell, 2015), PSPNet (Zhao et al., 2017), DeepLab (Chen et al., 2016 and Mask R-CNN (He et al., 2017), have been proposed. However, although the deep learning method has strong adaptability, it still has some shortcomings, such as requiring a large number of datasets for training and hard to obtain real-time segmentation results.
For specific segmentation scenarios, some of the algorithms can achieve good segmentation result. However, the result of ore adhesion is varied, thus the method mentioned cannot be directly applied to ore segmentation. The method based on concave point detection is a very effective method to segment circular adhesion objects. It can be observed that there must be multiple concave points existing in the outline when circular objects adhere to each other, and we can use this priori knowledge to segment such adhesive objects. For example, Yao et al. (2017) uses the concave point detection algorithm to segment rice, and Song, Zhao & Liu (2014) proposes a method combining the concave point detection and watershed algorithm to segment the adhesion cells. The segmentation method based on concave point detection is not only fast enough to meet the needs of tasks requiring high real-time performance, but also can achieve good results for objects with smooth surface such as cells. However, although the ore is also a kind of circular object, its physical characteristics determine that there are many small interference concave points on its surface. If the conventional concave point detection method is used directly, these interference concave points will not be filtered out, which will inevitably lead to a large amount of over-segmentation phenomena.
To solve the above problems, inspired by the traditional concave point detection algorithm, a new concave point matching algorithm is proposed in this article to filter the small concave points on the edge caused by the ore's own characteristics, and the proposed method can greatly improve the accuracy of concave point matching. The proposed algorithm includes three parts: contour extraction module using adaptive threshold segmentation and image binarization and Suzuki's contour extration algorithm (Suzuki & Abe, 1985), concave point detection module based on vector angle and concave point matching module based on concave point auxiliary line. In order to validate the proposed method, industrial experiment have been carried out on the antimony ore dataset and compared with other methods. The experiment show that the proposed concave matching method based on the auxiliary line of the concave point can well remove the small interference concave points, and meet the requirements of ore X-ray image segmentation.

Industrial background
The typical structure of ore sorting device based on X-ray is shown in Fig. 1. The sorting process is as follows: first, raw ore is crushed into small stones of uniform size, which are sent to the pseudo-dual-energy X-ray identification equipment through the belt conveyor. Then, the industrial computer needs to determine the grade of ore from the high and low energy images obtained from the X-ray device and pass the coordinate of ore to the valve controller, which uses the coordinates to adjust the direction of the air flow to blow the ore into the correct separator box. In this process, the image segmentation algorithm must be able to get the correct position of the ore from the X-ray image, otherwise the subsequent valve controller will not work correctly.
The pseudo-dual-energy X-ray processing subsystem used in the system is shown in Fig. 2. It contains an X-ray source and a pseudo-dual-energy X-ray detector. The X-ray source emits X-ray beam with a continuous spectrum, and the dual-energy detector is a two-layer structure, the upper layer collects low-energy signals, the middle layer uses a copper sheet to filter out the low-energy part of the ray, and the lower layer collects highenergy signals. The pseudo-dual-energy X-ray system is widely used in industrial inspection due to its simple structure, high precision and cost performance.
At present, the mainstream sorting method based on pseudo-dual-energy X-ray relies on the fact that different grades of ore have different physical characteristics and thus have different absorption ability for X-ray, so that the gray level of the picture obtained from the X-ray detector is different (one example is shown in Fig. 3). When the ore is separated from the original image, through these gray features, combined with the classification algorithm, different grades of ore and gangue can be separated.
The difficulty of ore image segmentation based on x-ray

Real time performance
Industrial computers must segment, classify ore from image and send ore locations and categories to subsequent controller in limited time. If the algorithm takes too long time, the antimony will not be blown into the corresponding box by the air valve in time, which will lead to the failure of sorting.

Accuracy
The classification algorithm uses each pixel of the segmented ore to classify the mineral. If over-segmentation occurs, the number of pixels available for ore classification will be reduced, resulting in errors in classification results. Accordingly, if undersegmentation occurs, the classification results will be inaccurate because the samples to be tested are mixed with different kinds of ores.

Robustness
In the actual production process, there will be a lot of small stones and other debris on the belt, and eventually these debris will appear on the X-ray gray image in the form of noise. If these noises are not processed, over-segmentation will occur and the accuracy of recognition will be reduced.

ROBUST ORE IMAGE SEGMENTATION ALGORITHM
The ore image segmentation algorithm proposed in this article is implemented on the system shown in Fig. 1. It consists of three modules: contour extraction module, concave point detection module and concave point matching module. The contour extraction module consists of image cutting, image binarization, noise processing and contour extraction. The concave point detection module determines whether the point on the contour is concave by calculating the angle between three consecutive points. As the main contribution of this article, the concave point matching module filters out the interference concave points on the boundary by drawing parallel lines of connecting lines of concave points and judging the relative position of parallel lines and ore contours, so as to reduce the probability of over-segmentation. Image cutting As shown in Fig. 4, the output image of the X-ray processing subsystem consists of two parts: high-energy part and low-energy part, so it needs to be cut apart through the slicing operation of the matrix. The image obtained after cutting is shown in Fig. 5.

Image binarization
In order to find the ore contour using Suzuki's method (Suzuki & Abe, 1985), the image obtained in the Image cutting section needs to be binarized. Fixed threshold segmentation, Otsu threshold segmentation, and adaptive threshold segmentation are the most commonly used methods. It is found in practice that for the samples obtained from actual production process, fixed threshold and Otsu threshold segmentation, as a global threshold segmentation method, cannot effectively binarize ore image under the condition of dark background, much noise and interference caused by stone powder, while as a method using local threshold, adaptive threshold segmentation can better adapt to complex situations in different scenes. Therefore, this article adopts adaptive threshold segmentation algorithm to segment non-adhesive images, and carries out preliminary segmentation of adhesive images. By selecting the low energy image or high energy image in Fig. 5, the binary image can be obtained after being processed with the adaptive threshold segmentation algorithm, and the result is shown in Fig. 6. Noise filtering In the actual production process, the binary image of ore has a lot of noise. If the noise is not filtered, the program will treat the noise as tiny ores, which not only increases the computing load of the computer, but also interferes with the process of recognizing normal ores. We use morphological operation (Comer & Delp, 1999) to remove noise from the image. Firstly, the noise inside the stones were removed by dilation operation, as shown in Fig. 7. Similarly, in order to remove noise outside the ore, erosion operation is used, and the effect is shown in Fig. 8.

Contour extraction
In this article, the method proposed by Suzuki (Ren, Zhang & Zhang, 2019, Suzuki & Abe, 1985 is used to extract contour from binary image, and the extracted contour is shown in Fig. 9.

Concave point detection
It can be observed that the concave point is a class of points with the maximum local curvature on the contour formed by two or more circular objects stacked. For a single smooth elliptic object, the contour curve will not have a large curvature mutation, nor will it form a concave region caused by overlapping of different objects. On the contrary, there must be points whose curvature change suddenly on the contour of the cohesive ores, which is the basis for determining concave points. As shown in Fig. 10, two vectors named u and v are formed by three consecutive points on the contour (the length of the u and v are greater than the hyperparameter d), then the angle between the two vectors is calculated to obtain the concavity corresponding to the point.
For points on the contour ½p 1 ; p 2 ; …; p k ; …; p n , in order to find the concavity corresponding to point p k on the contour, by using Eq. (1), m ¼ i and m ¼ j can be solved separately (in Eq. (1), i . k; j , k, and in this article, d is set to 6). arg min m jk À mj s:t: jp k À p m j . d To calculate the angle between the vectors u and v, the function hðx; yÞ defined in Eq. (4) is used to calculate the angle between the x-axis and the vector u, and the same is true for v, so that we can obtain the values of hðu x ; u y Þ and hðv x ; v y Þ. Let h 1 be the difference between hðu x ; u y Þ and hðv x ; v y Þ. Note that hðx; yÞ in Eq. (4) is 0 in the positive direction of the x-axis, and gradually increases in the counterclockwise direction, with a max value of 2p.
As h 1 2 ½À2p; 2p, the result obtained in the previous step need to be processed by using Eq. (6) to obtain the angle a.
We can obviously judge the convexity and angle of the local contour from the value of a, that is, if a 2 ½0; p, it is concave, otherwise it is convex. In practical use, in order to reduce interference, relatively flat local contours will be excluded, that is, point on the contour can be regarded as a concave point only if a 2 ½0; h t , where h t , p. After repeated experiments, it is found that selecting h t ¼ 3p 4 as threshold in this article can achieve better detection effect. By using the concave detection algorithm described above, the concave points can be detected in the extracted contour (b) in Fig. 9, and these concave points are annotated in red in Fig. 11 (the contour drawn in the Contour extraction section is hidden to highlight the concave points).

Concave point matching
The physical characteristics of the ore often lead to the existence of a large number of concave points on its edge in the absence of adhesion with other ores. For example, because some antimonite exists in the form of crystal, many concave points will be detected when the concave detection algorithm is performed. For this kind of ore, it will lead to oversegmentation if the concave line is used as the dividing line directly. This problem can be solved perfectly by using three-line method proposed in this article. The schematic diagram of this method is shown in Fig. 12.
As can be seen from the Fig. 12, due to the characteristics of the ore itself, concave points can be detected even from the outline of a single ore. Obviously, in such case, the connecting line of the concave points cannot be directly used as the dividing line (marked in green). In order to eliminate the false segmentation caused by such points, auxiliary lines are drawn in the figure (marked in black). The connecting line of its concave points can be used as a dividing line if the auxiliary lines are all inside the contour. The detailed steps of the method are as follows:

Finding the auxiliary line
As shown in the Fig. 12, the auxiliary line is actually the parallel line of the connecting line of the two concave points, and it has the same length as the connecting line of the concave points. Therefore, the auxiliary line can be obtained by combining the slope k of the connecting line between the concave points and the given distance d.
Let E 0 ¼ ðr 0 ; c 0 Þ and E 1 ¼ ðr 1 ; c 1 Þ be the endpoints of the connecting line. First, calculate its slope k by using Eq. (7). k ¼ c 1 À c 0 r 1 À r 0 (7) The distance difference (D x and D y ) between the concave point and the end point of the auxiliary line is obtained by using slope k and distance d.
The endpoints of the concave points ðr 0 ; c 0 Þ and ðr 1 ; c 1 Þ are translated by distance D x and D y in the horizontal and vertical directions to obtain the endpoints of the auxiliary line: P 0 , P 1 , N 0 and N 1 .
Wire P 0 and P 1 to get the auxiliary line L P . Similarly, the auxiliary line L N can be obtained by connecting N 0 and N 1 .

Judging the position relation between auxiliary line and contour
In order to judge the position relationship between the auxiliary line and the contour, it is necessary to judge the position relationship between each point of the auxiliary line and the contour. In this article, the PNPoly algorithm (Haines, 1994;Zhang & Zhou, 2022) proposed by W. Randolph Franklin is used to solve the position relationship between the point and the contour (the point to be measured can be on the contour, inside the contour or outside the contour). The idea of the algorithm is shown in Fig. 13.
As can be seen from the figure, the position relationship between the point and the contour can be judged by drawing the horizontal line and finding the number of times that the line crosses the contour.

Finding the true dividing line
As shown in Algorithm 1, by repeatedly applying the method described in the Concave point detection section and the Concave point matching section for each candidate concave point splitting line, the true splitting line of the adhered ore can be found.

Complete segmentation process
The overall segmentation process is shown in the Algorithm 2, one of the segmentation examples is shown in Fig. 14.

EXPERIMENTS
LNPC12-80, a pseudo-dual-energy X-ray sorting device produced by Longi company, was selected for the experiment, the equipment shown in Fig. 15. In order to verify the performance of the proposed algorithm, the antimony ore dataset made by ourselves is selected for the experiment. The relevant parameters of the sample are shown in Table 1. In this experiment, the memory of the host used in the experiment is 16G, the CPU model is 28375CX2, and the windows 10 operating system is used. C++ and Opencv library are used to implement the proposed algorithm, and 134 single-channel 512 Â 5; 632 gray scale images are tested.

Analysis of results
In order to better demonstrate the superiority of the algorithm in this article, the algorithm proposed in this article is compared with simple concave point matching algorithm and the watershed algorithm based on distance transform using exactly the same dataset. Several typical images are selected from the results of experiment to illustrate the performance of each algorithm. As shown in Fig. 16, if the overlapping area of two ores is large, they cannot be separated by the watershed algorithm (as shown in the first row). Even if the watershed algorithm can be used to divide the cohesive ore, the dividing line in the segmentation result is not very accurate (as shown in the second row). Due to the physical characteristics of the ore, even a single ore may have a large number of concave points on its contour, in this case, the use of simple concave matching will inevitably lead to over-segmentation (as shown in the third row). In the above cases, the algorithm proposed in this article can work well. In this article, P u (under-segmentation rate), P o (over-segmentation rate) and P a (accuracy rate) are used as performance indicator to reflect the performance of algorithms when applied in practical industrial applications and they are defined as: In this formula, N u is the number of under-segmentation ore, N o is the number of oversegmentation ore, N a is the number of ores correctly divided and M is the total number of ores tested (M ¼ 134).
As can be seen from the Table 2, compared with other algorithms, the proposed algorithm can significantly reduce the probability of under-segmentation and oversegmentation and improve the accuracy of segmentation.

CONCLUSION
This article presents a strategy of ore segmentation based on concave point detection. This strategy contains two main innovation. Firstly, an ore segmentation framework for pseudo-dual-energy X-ray images is proposed, which is mainly composed of contour extraction module, concave point detection module and concave point matching module. Secondly, in order to reduce the influence of the concave points caused by the physical characteristics of ore on segmentation process, this article proposes a concave point matching algorithm which uses the position relationship between the auxiliary line and the contour to judge whether the candidate segmentation scheme is available. By comparing the result of experiment, it is found that the proposed algorithm can obtain a satisfactory segmentation effect, and it can be applied to the actual industrial ore separation process, and also pave the way for the ore classification.