X-ray ore image segmentation method, device, equipment and medium
By generating contour sets and distance transform images, combined with multi-neighborhood strength and weakness condition growth, the inaccuracy problem of traditional X-ray ore image segmentation methods in ore sorting scenes is solved, and the accurate segmentation of X-ray ore images is achieved. Improves the accuracy and efficiency of ore sorting.
Patent Information
- Application Number
- CN202411002331.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-25
- Publication Date
- 2024-11-15
- Estimated Expiration
- 2044-07-25
AI Technical Summary
The traditional X-ray ore image segmentation method has inaccuracy in ore sorting scenarios, especially when there is stickiness on the ore detection belt, which may lead to the metal part being misjudged as waste stone, reducing the execution rate of waste stone spraying. , and may misjudge the low-grade ore as waste stone.
An X-ray ore image segmentation method is adopted to obtain the original image, generate the outline set and distance transform image, traverse the distance transform image to find the local maximum value, mark the mask image, and find the local peak position, and draw in the empty picture based on these positions. The circle is filled inside to form the initial growth area and grow through multi-neighborhood strong and weak conditions to finally achieve accurate segmentation of the image.
This method can improve accuracy in X-ray ore image segmentation, reduce misjudgment, ensure the accuracy and efficiency of ore sorting, avoid the metal part being misjudged as waste stone, and improve the execution rate of waste stone spraying.
Smart Images

Figure CN118552570B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of machine vision technology, and in particular to an X-ray ore image segmentation method, device, equipment and medium. Background Art
[0002] Target segmentation is a very important step in the field of machine vision. The accuracy of segmentation is related to the final recognition accuracy. Traditional segmentation methods include threshold-based segmentation, edge detection-based segmentation, region growing, watershed segmentation, etc. Each method has its own advantages and disadvantages. Threshold-based and edge-based segmentation cannot solve the problem of target adhesion. Region growing and watershed have high requirements on target homogeneity and are prone to over-segmentation and out-of-bounds segmentation.
[0003] In the field of X-ray ore sorting, the accuracy of target segmentation is related to the accuracy of single ore identification. The target metal substance exists in the original ore in the form of veins, cracks, and infection types. In order to separate the metal from the gangue, the original ore needs to be crushed to a certain particle size. The crushed original ore can be divided into high grade, medium grade, low grade, waste rock, etc. according to the grade. Ore sorting is the process of removing waste rock or waste rock and low-grade ore. The crushed original ore is spread flat on the detection belt through the feeder, and then scanned by X-ray to form two sets of X-ray images with different spectral characteristics, commonly known as dual-energy images. This technology of qualitative and semi-quantitative analysis of ore through dual-energy images is called XRT technology.
[0004] Although the above traditional segmentation methods can achieve basic image segmentation functions, they are inaccurate when segmenting X-ray ore images. In the ore sorting scenario, the ore is usually sticky when the detection belt is detected. If the segmentation is inaccurate, the metal-containing part may be included in the waste rock, which will reduce the waste rock identified and reduce the execution rate of waste rock injection. At the same time, it is possible to mistakenly execute low- and medium-grade ore as waste rock. Summary of the invention
[0005] Based on this, it is necessary to provide an accurate X-ray ore image segmentation method, device, equipment and medium to address the above technical problems.
[0006] In a first aspect, the present application provides an X-ray ore image segmentation method. The method comprises:
[0007] Acquire an original image of the ore, and generate a contour set and a distance transformation image corresponding to the original image;
[0008] Traversing the distance transformation image to find the local maximum value within a preset search distance radius, and marking it in the mask image, traversing the marked mask image, finding the maximum pixel value position within a preset minimum confidence distance between local peaks, and putting the maximum pixel value position into a position container;
[0009] Based on the position container, drawing mutually non-intersecting inner filled circles in an empty image of the same size as the distance transformation image according to the distance value corresponding to the current coordinates;
[0010] The connected domains in the empty graph with circles marked with different values are used as the initial growth region of each target, and the point sets in the connected domain with the neighborhood as the background are placed in the growth point container;
[0011] According to the contour set, a growth condition termination point is obtained, and the growth condition termination point is placed in a termination point container;
[0012] A first round of strong conditional growth and a second round of weak conditional growth based on multiple neighborhoods are performed based on the growing point container and the ending point container to obtain a segmentation result of the original image.
[0013] In one embodiment, the step of acquiring an original image of the ore and generating a contour set and a distance transformation image corresponding to the original image comprises:
[0014] Acquire an original image of the ore, and downsample the original image to obtain a downsampled image;
[0015] Adopting an adaptive binarization method to binarize the downsampled image to obtain an initial binarized image;
[0016] Performing an opening operation on the initial binary image to obtain a new binary image;
[0017] Performing contour search on the new binary image to obtain a contour set, and performing distance transformation on the new binary image to obtain a distance transformed image.
[0018] In one embodiment, performing distance transformation on the binary image to obtain the distance transformed image includes:
[0019] Get the preset mask size;
[0020] Based on the Euclidean distance method with the preset mask size, distance transformation is performed on the binary image to obtain a distance transformed image.
[0021] In one embodiment, traversing the distance transformation image to find the local maximum value within a preset search distance radius and marking it in the mask image, traversing the marked mask image to find the maximum pixel value position within a preset minimum confidence distance between local peaks, and placing the maximum pixel value position into a position container comprises:
[0022] Obtaining a preset search distance radius and a minimum confidence distance between local peaks;
[0023] Traversing the distance transformation image, comparing the pixel value of the current position with all pixel values within the preset search distance radius from the current position;
[0024] Find the local maximum position corresponding to the maximum pixel value;
[0025] marking the local maximum position in the mask image;
[0026] Traversing the distance transformation image based on the marked position in the marked mask image, taking the minimum confidence distance as a radius, searching for the maximum pixel value position;
[0027] The maximum pixel value position is placed in a position container, and the elements in the container are arranged in descending order according to the corresponding position distance values.
[0028] In one of the embodiments, based on the position container, drawing mutually non-intersecting inner filling circles in an empty image of the same size as the distance transformation image according to the distance value corresponding to the current coordinates, marking the circles in the empty image as connected domains with different values as the initial growth area of each target, and placing the point set with the neighborhood as the background in the connected domain into the growth point container includes:
[0029] Generate an empty image of the same size as the distance transform image;
[0030] Traversing the elements in the position container, taking the current coordinate point as the center and the distance value of the current coordinate point in the distance transformation image as the radius, drawing non-intersecting inner filling circles in the empty image, and if the circle drawn first contains other elements, the contained elements are removed from the position container;
[0031] Mark the inner filled circles in the empty graph as connected domains with different values, and obtain the point set in the connected domain;
[0032] The connected domain is used as the initial growth region of each target, and the point set with the neighborhood as the background in the connected domain is placed into the growth point container.
[0033] In one embodiment, acquiring the growth condition termination point according to the contour set and placing the growth condition termination point into a termination point container comprises:
[0034] According to the contour set, an outer contour set and an inner contour set are generated respectively;
[0035] Calculating concave points based on the outer contour set, and calculating convex points based on the inner contour set;
[0036] According to the concave point and the convex point, a growth condition termination point is obtained;
[0037] The growth condition stop point is placed into a stop point container.
[0038] In one embodiment, performing a first round of strong conditional growth and a second round of weak conditional growth based on multiple neighborhoods based on the growing point container and the ending point container to obtain a segmentation result of the original image includes:
[0039] Initialize the non-zero value area outside the connected domain mark area in the distance transform image as the foreground, and the zero value area as the background;
[0040] For each point in the growing point container, check whether its multi-neighborhood contains background points;
[0041] Based on the end point container, the current point value and the corresponding neighborhood distance value, a first round of strong conditional growth is performed in a gradient decreasing manner, the grown points are removed from the growing point container, the grown points are included in the growing point container, and the growing points are updated in the empty graph;
[0042] The point set with the connected domain corresponding to the first round of strong conditional growth as the background is re-placed into the growth point container to obtain an updated growth point container;
[0043] A second round of weak condition growth is performed based on the updated growth point container. When the updated growth point container is empty, the growth is completed, and the growth point is updated for the second time in the empty graph. The weak condition growth only needs to have a background in the neighborhood to grow, and the points that have grown are removed from the updated growth point container and included in the points to be grown.
[0044] The segmentation result of the original image is obtained according to the empty image after the second update.
[0045] In one embodiment, the multi-neighborhood is an 8-neighborhood or a 4-neighborhood;
[0046] The first round of strong conditional growth is performed in a gradient decreasing manner based on the end point container, the current point value and the corresponding neighborhood distance value, the grown points are removed from the growing point container, the grown points are included in the growing point container, and the growing points are updated in the empty graph, including:
[0047] Get the comparison result between the current point value and the corresponding neighborhood distance value;
[0048] If the current point value is not less than the corresponding neighborhood distance value, assign the current point value to the corresponding neighborhood in the empty graph, remove the current point coordinates from the growth point container, and place the corresponding neighborhood coordinates into the growth point container;
[0049] If the current point value is less than the corresponding neighborhood distance value, the current point coordinates are removed from the growth point container and the growth of the current point is stopped;
[0050] If there is a 0 value in the neighborhood, the current point coordinates are removed from the growth point container;
[0051] If there is a mark value other than the current connected domain in the neighborhood of the point in the current connected domain, the coordinates of the current point are removed from the growth point container, and the strong conditional growth is exited;
[0052] If there is a point in the neighborhood that belongs to the end point container, the coordinates of the current point are removed from the growth point container, and the strong conditional growth of the connected domain is exited;
[0053] If there is a mark value that is not a mark value of the connected domain in the current neighborhood, the coordinates of the current point are removed from the growth point container, and the strong conditional growth of the connected domain is exited;
[0054] When all coordinate points in the growth point container are updated, the growth points are updated in the empty map.
[0055] In one embodiment, the second round of weak condition growth is performed based on the updated growth point container, and the growth is completed when the updated growth point container is empty, and the second updating of the growth point in the empty graph includes:
[0056] Based on the updated growth point container, the non-zero region outside the connected domain mark removed from the binary image is used as the foreground, and the zero-value region is used as the background;
[0057] For each point in the updated growing point container, checking the corresponding neighborhood value;
[0058] If the neighborhood value is a non-zero foreground area, it is directly grown, the neighborhood value is assigned the current position value in the original image, the current point coordinates are removed from the updated growth point container, and the neighborhood coordinates are placed in the updated growth point container;
[0059] If there is a 0 value in the neighborhood value, the coordinates of the current point are removed from the updated growth point container, and the growth of the current point is stopped;
[0060] If there is a non-connected domain mark value in the neighborhood value, the coordinates of the current point are removed from the updated growth point container and the growth of the current point is stopped;
[0061] When the updated growth point container is empty, the growth is completed, and the growth point is updated a second time in the empty graph.
[0062] In a second aspect, the present application also provides an X-ray ore image segmentation device. The device comprises:
[0063] An image transformation module is used to obtain an original image of the ore and generate a contour set and a distance transformation image corresponding to the original image;
[0064] A first processing module is used to traverse the distance transformation image to find the local maximum value within a preset search distance radius and mark it in the mask image, traverse the marked mask image, find the maximum pixel value position within a preset minimum confidence distance between local peaks, and put the maximum pixel value position into a position container;
[0065] A second processing module is used to draw non-intersecting inner filling circles in an empty image of the same size as the distance transformation image according to the distance value corresponding to the current coordinates based on the position container;
[0066] The third processing module is used to mark the connected domain with different values in the circle in the empty graph as the initial growth area of each target, and put the point set with the neighborhood as the background in the connected domain into the growth point container;
[0067] A fourth processing module, configured to obtain a growth condition termination point according to the contour set, and place the growth condition termination point into a termination point container;
[0068] The segmentation module is used to perform a first round of strong conditional growth and a second round of weak conditional growth based on multiple neighborhoods based on the growth point container and the end point container to obtain a segmentation result of the original image.
[0069] In a third aspect, the present application further provides a computer device. The computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the following steps when executing the computer program:
[0070] Acquire an original image of the ore, and generate a contour set and a distance transformation image corresponding to the original image;
[0071] Traversing the distance transformation image to find the local maximum value within a preset search distance radius, and marking it in the mask image, traversing the marked mask image, finding the maximum pixel value position within a preset minimum confidence distance between local peaks, and putting the maximum pixel value position into a position container;
[0072] Based on the position container, drawing mutually non-intersecting inner filled circles in an empty image of the same size as the distance transformation image according to the distance value corresponding to the current coordinates;
[0073] The connected domains in the empty graph with circles marked with different values are used as the initial growth region of each target, and the point sets in the connected domain with the neighborhood as the background are placed in the growth point container;
[0074] According to the contour set, a growth condition termination point is obtained, and the growth condition termination point is placed in a termination point container;
[0075] A first round of strong conditional growth and a second round of weak conditional growth based on multiple neighborhoods are performed based on the growing point container and the ending point container to obtain a segmentation result of the original image.
[0076] In a fourth aspect, the present application further provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the following steps are implemented:
[0077] Acquire an original image of the ore, and generate a contour set and a distance transformation image corresponding to the original image;
[0078] Traversing the distance transformation image to find the local maximum value within a preset search distance radius, and marking it in the mask image, traversing the marked mask image, finding the maximum pixel value position within a preset minimum confidence distance between local peaks, and putting the maximum pixel value position into a position container;
[0079] Based on the position container, drawing mutually non-intersecting inner filled circles in an empty image of the same size as the distance transformation image according to the distance value corresponding to the current coordinates;
[0080] The connected domains in the empty graph with circles marked with different values are used as the initial growth region of each target, and the point sets in the connected domain with the neighborhood as the background are placed in the growth point container;
[0081] According to the contour set, a growth condition termination point is obtained, and the growth condition termination point is placed in a termination point container;
[0082] A first round of strong conditional growth and a second round of weak conditional growth based on multiple neighborhoods are performed based on the growing point container and the ending point container to obtain a segmentation result of the original image.
[0083] In a fifth aspect, the present application further provides a computer program product. The computer program product includes a computer program, and when the computer program is executed by a processor, the following steps are implemented:
[0084] Acquire an original image of the ore, and generate a contour set and a distance transformation image corresponding to the original image;
[0085] Traversing the distance transformation image to find the local maximum value within a preset search distance radius, and marking it in the mask image, traversing the marked mask image, finding the maximum pixel value position within a preset minimum confidence distance between local peaks, and putting the maximum pixel value position into a position container;
[0086] Based on the position container, drawing mutually non-intersecting inner filled circles in an empty image of the same size as the distance transformation image according to the distance value corresponding to the current coordinates;
[0087] The connected domains in the empty graph with circles marked with different values are used as the initial growth region of each target, and the point sets in the connected domain with the neighborhood as the background are placed in the growth point container;
[0088] According to the contour set, a growth condition termination point is obtained, and the growth condition termination point is placed in a termination point container;
[0089] A first round of strong conditional growth and a second round of weak conditional growth based on multiple neighborhoods are performed based on the growing point container and the ending point container to obtain a segmentation result of the original image.
[0090] The X-ray ore image segmentation method, device, computer equipment, storage medium and computer program product obtain an original image of the ore, generate a contour set and a distance transformation image corresponding to the original image; traverse the distance transformation image to find the local maximum value within a preset search distance radius and mark it in the mask image, traverse the marked mask image, find the maximum pixel value position within a preset minimum confidence distance between local peaks, and put the maximum pixel value position into a position container; based on the position container, draw non-intersecting inner filled circles according to the distance value corresponding to the current coordinates in an empty image of the same size as the distance transformation image; mark the connected domain of the circles in the empty image with different values as the initial growth area of each target, and put the point set in the connected domain with the neighborhood as the background into the growth point container; according to the contour set, obtain the growth condition termination point, and put the growth condition termination point into the termination point container; based on the growth point container and the termination point container, perform the first round of strong conditional growth and the second round of weak conditional growth based on multiple neighborhoods to obtain the segmentation result of the original image. During the whole process, the initial growth area, growth point container and termination point container are determined through image processing, and then the first round of strong conditional growth and the second round of weak conditional growth based on multi-neighborhood are carried out to achieve accurate segmentation of the original image, and finally an accurate X-ray ore image segmentation result can be obtained. BRIEF DESCRIPTION OF THE DRAWINGS
[0091] Figure 1 A diagram showing an application environment of an X-ray ore image segmentation method in an embodiment;
[0092] Figure 2 A schematic diagram of a flow chart of an X-ray ore image segmentation method in one embodiment;
[0093] Figure 3 A schematic diagram of a flow chart of an X-ray ore image segmentation method in another embodiment;
[0094] Figure 4 It is a flowchart of an X-ray ore image segmentation method in a specific application example;
[0095] Figure 5 It is a schematic diagram of the original image Img;
[0096] Figure 6 It is a schematic diagram of the binary image thrPyrDownImg;
[0097] Figure 7 is a schematic diagram of a distance transformation image distanceImg;
[0098] Figure 8 It is a schematic diagram of an empty graph diantanceU;
[0099] Fig. 9 It is a schematic diagram of the final growth effect of the connected domain;
[0100] Fig.10 is a structural block diagram of an X-ray ore image segmentation device in one embodiment;
[0101] Fig.11 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0102] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0103] The X-ray ore image segmentation method provided in the embodiment of the present application can be applied to Figure 1In the application environment shown, the terminal 102 communicates with the server 104 through a network. The data storage system can store data that the server 104 needs to process. The data storage system can be integrated on the server 104, or placed on the cloud or other network servers. The terminal 102 sends a segmentation request to the server 104, in which the original image of the ore is carried. The server 104 responds to the request, obtains the original image of the ore, generates a contour set and a distance transformation image corresponding to the original image; traverses the distance transformation image to find the local maximum value within a preset search distance radius, and marks it in the mask image, traverses the marked mask image, finds the maximum pixel value position within the preset minimum confidence distance between local peaks, and puts the maximum pixel value position into a position container; based on the position container, in an empty image with the same size as the distance transformation image, draws non-intersecting inner filled circles according to the distance value corresponding to the current coordinates; marks the connected domain of the circle in the empty image with different values as the initial growth area of each target, and puts the point set with the neighborhood as the background in the connected domain into the growth point container; according to the contour set, obtains the growth condition termination point, and puts the growth condition termination point into the termination point container; based on the growth point container and the termination point container, performs the first round of strong conditional growth and the second round of weak conditional growth based on multiple neighborhoods to obtain the segmentation result of the original image. The terminal 102 may be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, IoT devices, and portable wearable devices. The IoT devices may be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, etc. The portable wearable devices may be smart watches, smart bracelets, head-mounted devices, etc. The server 104 may be implemented as an independent server or a server cluster consisting of multiple servers.
[0104] In one embodiment, Figure 2 As shown, a method for segmenting X-ray ore images is provided, and the method is applied to Figure 1 Taking the server 104 in the example as an example, the following steps are included:
[0105] S100: Acquire an original image of the ore, and generate a contour set and a distance transformation image corresponding to the original image.
[0106] Specifically, the original image of the ore here can be an X-ray ore image. The image can be scanned by an X-ray imaging device to obtain the internal structure and mineral distribution information. After scanning, the original X-ray ore images are obtained, which may contain various characteristics of the ore, such as mineral type, distribution, density, etc. After obtaining the original image of the ore, the original image can be preprocessed to improve the image quality and reduce noise interference. The preprocessing steps may include image denoising, enhancement, binarization, etc., so as to better highlight the characteristics of the ore. Contour extraction is one of the important prerequisites for realizing intelligent sorting, which can help determine the distribution, size and morphology of minerals in the ore. Distance transformation is an image processing technology used to calculate the distance from each pixel in the image to the nearest non-zero pixel. In ore detection, the distance distribution image between different mineral components inside the ore can be generated by distance transformation. This distance transformation image helps to further analyze the spatial distribution and relationship between mineral components in the ore.
[0107] S200: traverse the distance transformation image to find the local maximum value within a preset search distance radius, and mark it in the mask image, traverse the marked mask image, find the maximum pixel value position within a preset minimum confidence distance between local peaks, and put the maximum pixel value position into a position container.
[0108] In image processing, distance transforms are often used to measure the distance from each non-zero pixel in an image to its nearest zero pixel. After traversing the distance transform image to find local maxima and marking these locations in the mask image, further analyze these marked points, in particular, to ensure that the distance between them is greater than a certain minimum confidence distance. Traverse each pixel in the distance transform image. For each pixel, check whether it is a local maximum within a preset search distance radius (that is, its value is greater than or equal to all other pixels in its neighborhood). Traverse the marked mask image. For each marked pixel, search the area around it (for example, the area within a preset minimum confidence distance). Within this area, find the location with the largest pixel value. Add the found location of the maximum pixel value to the location container.
[0109] S300: Based on the position container, draw non-intersecting inner filled circles in an empty image of the same size as the distance transformation image according to the distance value corresponding to the current coordinates.
[0110] Initialize an empty image: This image should have the same size and type as the distance transform image (usually an 8-bit unsigned integer). Iterate over the position container: For each position in the position container (i.e. the coordinates of the local peak), check its corresponding distance value. You can use a specific function to draw a circle on the empty image. The center of the circle is the coordinate of the local peak, and the radius is its corresponding distance value (some adjustments may be required to ensure that the circles do not intersect). If the distance between the centers of two circles is less than the sum of their radii, they will intersect, and you need to adjust the position or radius of the circle to avoid this.
[0111] S400: Marking the connected domains with different values in the empty graph as the initial growth region of each target, and placing the point set with the neighborhood as the background in the connected domain into the growth point container.
[0112] To mark the circles in the empty image as connected domains with different values, and place the point sets in each connected domain with the background as the neighborhood into the growing point container, you can use the image segmentation or connected component marking algorithm. You can first find the contours (i.e., connected domains) in the binary image, then determine the point sets in the connected domain based on these contours, and then place the point sets in the connected domain with the background as the neighborhood into the growing point container.
[0113] S500: Acquire a growth condition termination point according to a contour set, and place the growth condition termination point into a termination point container.
[0114] In image processing, determining the growth condition end point usually depends on the specific application requirements. Here, the end point can be determined based on the boundary points of the contour, or the growth end point can be screened according to a threshold or condition, and then these growth condition end points are placed in the end point container for the next step of processing.
[0115] S600: performing a first round of strong conditional growth and a second round of weak conditional growth based on multiple neighborhoods based on the growing point container and the ending point container to obtain a segmentation result of the original image.
[0116] The multi-neighborhood here can specifically be a 4-neighborhood, an 8-neighborhood, etc.
[0117] The first round of strong conditional growing. Initialization: For each growing point container (each connected domain), start growing from the growing point. Strong condition: Define a strong condition, such as only considering pixels whose color or brightness difference with the current growing point is less than a certain threshold as new growing points. At the same time, these new growing points must be adjacent to the current growing point (for example, 4 neighborhoods or 8 neighborhoods). Growth process: Starting from each growing point, check the pixels in its neighborhood. If they meet the strong condition, add them to the growing point container and continue growing from these new growing points. Termination condition: Stop growing when no new pixels meet the strong condition.
[0118] The second round of weak conditional growing. Initialization: Use the result after the first round of growing as the new growing point container. Weak condition: Define a weak condition that is more relaxed than the strong condition. For example, pixels with slightly larger differences in color or brightness are allowed, or non-adjacent but close pixels are allowed to be included. Growth process: Similar to the first round of growth, starting from each growing point, check the pixels in its neighborhood. If they meet the weak condition, add them to the growing point container, and continue growing from these new growing points. Termination condition: Similarly, when no new pixels meet the weak condition, stop growing.
[0119] The above X-ray ore image segmentation method obtains the original image of the ore, generates a contour set and a distance transformation image corresponding to the original image; traverses the distance transformation image to find the local maximum value within a preset search distance radius and marks it in the mask image, traverses the marked mask image, finds the maximum pixel value position within the preset minimum confidence distance between local peaks, and puts the maximum pixel value position into a position container; based on the position container, draws non-intersecting inner filled circles according to the distance value corresponding to the current coordinates in an empty image of the same size as the distance transformation image; marks the connected domain of different values as the initial growth area of each target in the circle in the empty image, and puts the point set with the neighborhood as the background in the connected domain into the growth point container; according to the contour set, obtains the growth condition termination point, and puts the growth condition termination point into the termination point container; based on the growth point container and the termination point container, performs the first round of strong conditional growth and the second round of weak conditional growth based on multiple neighborhoods to obtain the segmentation result of the original image. During the whole process, the initial growth area, growth point container and termination point container are determined through image processing, and then the first round of strong conditional growth and the second round of weak conditional growth based on multi-neighborhood are carried out to achieve accurate segmentation of the original image, and finally an accurate X-ray ore image segmentation result can be obtained.
[0120] like Figure 3 As shown, in one embodiment, S100 includes:
[0121] S110: Acquire an original image of the ore, and downsample the original image to obtain a downsampled image.
[0122] The original image Img of the ore is downsampled by 1 / 2, and the data is compressed to meet the real-time processing requirements. The sampled image is recorded as pyrDownImg (pyramid downsampled image).
[0123] S120: Binarize the downsampled image using an adaptive binarization method to obtain an initial binarized image.
[0124] The adaptive binarization method is used to binarize pyrDownImg, denoted as thrPyrDownImg, with the target (foreground) area value being 255 and the background area being 0.
[0125] S130: performing an opening operation on the initial binary image to obtain a new binary image.
[0126] Define a 5×5 ellipse morphological structure element elementEllipse55, and perform an opening operation on the pyramid downsampled image of the binary image thrPyrDownImg that has been processed by adaptive binarization to obtain a new binary image thrPyrDownImg2. The purpose of this step is to blunt the sharp edges of the target contour, which is conducive to more accurate search for the target center of gravity in subsequent steps.
[0127] S140: performing contour search on the new binary image to obtain a contour set, and performing distance transformation on the new binary image to obtain a distance transformed image.
[0128] Find the contour of thrPyrDownImg2 and obtain the contour set contour[n], where n represents the index of the contour. Perform distance transformation on the binary image thrPyrDownImg2. Obtain the distance transformation image distanceImg, which is a floating point data type.
[0129] In one embodiment, performing distance transformation on the binary image to obtain the distance transformed image includes:
[0130] A preset mask size is obtained; and a distance transform is performed on the binary image based on a Euclidean distance method of the preset mask size to obtain a distance transformed image.
[0131] The preset mask size is a preset mask size, which can be specifically set based on actual conditions. For example, the Euclidean distance method with a mask size of 3 can be used to perform distance transformation on the binary image thrPyrDownImg2.
[0132] In one embodiment, traversing the distance transformation image to find the local maximum value within a preset search distance radius and marking it in the mask image, traversing the marked mask image to find the maximum pixel value position within a preset minimum confidence distance between local peaks, and placing the maximum pixel value position into a position container includes:
[0133] Step 1: Get the preset search distance radius and the minimum confidence distance between local peaks. Define the local distance radius kernelSize, define the minimum confidence distance between local peaks minPeakDistance, kernelSize
[0134] Step 2: Traverse the distance transformation image, compare the pixel value of the current position with the pixel values of all pixels within the preset search distance radius from the current position. Traverse diantanceImg, compare the pixel value of the current position current with the pixel values of all pixels within the radius of kernelSize from the current position.
[0135] Step 3: Find the local maximum position corresponding to the maximum pixel value. When current is the maximum, the current position is the local maximum position.
[0136] Step 4: Mark the local maximum position in the mask image. Mark the local peak position in the new mask image diantanceMask.
[0137] Step 5: Traverse the distance transformation image based on the marked position in the marked mask image, and search for the maximum pixel value position with the minimum confidence distance as the radius. Traverse diantanceImg according to the diantanceMask marked position, with minPeakDistance as the radius. When current is the largest, it is the peak position with high reliability, which is represented as the center point of the initial raw area of the target to be segmented.
[0138] Step 6: Place the maximum pixel value position into the position container, and sort the elements in the final position container in descending order according to the corresponding position distance value. Place the coordinate position into the container vectorPosition. Further, the coordinates in vectorPosition can be sorted in descending order, and the sorting rule is: the larger the corresponding position distance value in diantanceImg, the closer it is.
[0139] In one embodiment, based on the position container, in an empty image of the same size as the distance transformation image, non-intersecting inner filling circles are drawn according to the distance value corresponding to the current coordinates, the circles in the empty image are marked as connected domains with different values as the initial growth area of each target, and the point set with the neighborhood as the background in the connected domain is placed in the growth point container, including:
[0140] Step 1: Generate an empty image of the same size as the distance transform image. Generate an empty image diantanceU of the same size as diantanceImg.
[0141] Step 2: Traverse the elements in the position container. With the current coordinate point as the center and the distance value at the current coordinate point in the distance transformation image as the radius, draw non-intersecting filled circles in the empty image. If the previously drawn circle contains other elements, the contained elements will be removed from the position container. Traverse the elements in vectorPosition. With the current coordinate point as the center and the distance value at the current coordinate point in diantanceImg as the radius, draw filled circles in diantanceU. The rule for drawing circles is as follows: If the current circle does not intersect with all other circles, it forms a separate connected component; if it intersects, the intersecting connected components will be merged. If the previously drawn circle contains other elements, the contained elements need to be removed from the container. Thus, the connected components of the initial seed growth region are formed.
[0142] Step 3: Mark the filled circles in the empty image as connected components with different values, and obtain the point sets within the connected components. Mark the filled circles in the image diantanceU as connected components with different values. The values within the connected components are value[i] (value[i] > 100, the initial value is 100, i is the connected component index value, 0 < i < N is the total number of connected components).
[0143] Step 4: Use the connected components as the initial growth regions for each target, and place the point sets within the connected components that have a neighborhood of the background into the growth point container. Define multiple containers GrowPt[N] (growth point containers), and place the boundary coordinates of the i-th connected component into the i-th container GrowPt[i], 0 < i < N.
[0144] In one embodiment, obtaining the growth condition termination points according to the contour set and placing the growth condition termination points into the termination point container includes:
[0145] According to the contour set, generate an outer contour set and an inner contour set respectively; calculate concave points based on the outer contour set and convex points based on the inner contour set; obtain the growth condition termination points according to the concave points and the convex points; place the growth condition termination points into the termination point container.
[0146] Process the contour set contour[n] to obtain the outer contour set contourOutSide[n] and the inner contour set contourInSide[n]. Use the convex hull detection method to obtain the concave points of contourOutSide[n] and the convex points of contourInSide[n] (the concave points of the outer contour and the convex points of the inner contour are actually the starting points of the target segmentation line). The concave points and convex points here will be used as the growth condition termination points for subsequent region growth and placed into the container stopPoints.
[0147] In one embodiment, a first round of strong conditional growth and a second round of weak conditional growth based on multiple neighborhoods are performed based on the growing point container and the ending point container, and the segmentation result of the original image is obtained, including:
[0148] In the initialized distance transformation image, the non-zero value area outside the connected domain marked area is removed as the foreground, and the zero value area is the background; for each point in the growing point container, check whether its multi-neighborhood contains background points; based on the end point container, the current point value and the corresponding neighborhood distance value, the first round of strong conditional growth is performed in a gradient decreasing manner, the grown points are removed from the growing point container, the grown points are included in the growing point container, and the growing points are updated in the empty map; the point set with the connected domain corresponding to the first round of strong conditional growth as the background is re-placed into the growing point container to obtain an updated growing point container; based on the updated growing point container, the second round of weak conditional growth is performed, and the growth is completed when the updated growing point container is empty, and the growing points are updated twice in the empty map; wherein, the weak conditional growth only needs to have a background in the neighborhood to grow, the grown points are removed from the updated growing point container, and the grown points are included; according to the empty map after the second update, the segmentation result of the original image is obtained.
[0149] The non-zero area outside the connected domain marked area removed from diantanceImg is used as the foreground, and the zero-value area is used as the background. For each point in the growth point container GrowPt[N], its corresponding multi-neighborhood is checked, and the first round of strong conditional growth is performed based on the current point value and the corresponding neighborhood distance value, and the growth point is updated in the empty graph diantanceU, and the connected domain points corresponding to the first round of strong conditional growth are re-placed into the growth point container GrowPt[N], and then the second round of weak conditional growth is started. When the updated growth point container GrowPt[N] is empty, it indicates that the growth is completed. At this time, the growth point is updated twice in the empty graph diantanceU; according to the empty graph diantanceU after the second update, the segmentation result of the original image is obtained.
[0150] In one embodiment, the multi-neighborhood is an 8-neighborhood or a 4-neighborhood; the first round of strong conditional growth is performed in a gradient decreasing manner based on the end point container, the current point value and the corresponding neighborhood distance value, the grown points are removed from the growing point container, the grown points are included in the growing point container, and the growing points are updated in the empty graph, including:
[0151] Obtain the comparison result of the current point value and the corresponding neighborhood distance value; if the current point value is not less than the corresponding neighborhood distance value, assign the current point value to the corresponding neighborhood in the empty graph, remove the current point coordinate from the growth point container, and place the corresponding neighborhood coordinate into the growth point container; if the current point value is less than the corresponding neighborhood distance value, remove the current point coordinate from the growth point container and stop the current growth; if there is a 0 value in the neighborhood, remove the current point coordinate from the growth point container; if there is a point belonging to the termination point container in the neighborhood, remove the current point coordinate from the growth point container and exit the strong conditional growth of this connected domain; if there is a non - this - connected - domain marker value in the current neighborhood, remove the current point coordinate from the growth point container and exit the strong conditional growth of this connected domain; when all the coordinate points in the growth point container are updated, update the growth points in the empty graph.
[0152] The rules for the first - round strong conditional growth are as follows:
[0153] 1. Compare the current point with the 8 - neighborhood distance values respectively. If it is greater than or equal to (gradient descent), assign the current position value value[i] to the neighborhood in diantanceU, remove the current point coordinate from GrowPt[i], and at the same time place the neighborhood coordinate into GrowPt[i]; if it is less, directly remove the current point coordinate from GrowPt[i] and stop the growth of the current point.
[0154] 2. If there is a 0 value in the 8 - neighborhood, remove the current point coordinate and stop the growth of the current point.
[0155] 3. If there is a non - this - connected - domain marker value value[j] (0 < j < N, j is not equal to i) in the 8 - neighborhood, remove the current point coordinate from GrowPt[i] and exit the strong conditional growth of the current connected domain.
[0156] 4. If there is a point belonging to the growth termination point set stopPoints in the 8 - neighborhood coordinates, remove the current point coordinate from GrowPt[i] and exit the strong conditional growth of the current connected domain.
[0157] 5. Each update of the coordinate points in each container GrowPt[i] is one growth iteration. When GrowPt[i] is empty, the first - round growth iteration is completed.
[0158] 6. Update the growth points in the graph diantanceU.
[0159] In one of the embodiments, based on the updated growth point container, perform the second - round weak conditional growth. When the updated growth point container is empty, the growth is completed. The secondary update of the growth points in the empty graph includes:
[0160] Based on the updated growing point container, the non-zero area outside the connected domain mark removed in the binary image is used as the foreground, and the zero-value area is used as the background; for each point in the updated growing point container, the corresponding neighborhood value is checked; if the neighborhood value is a foreground area with a non-zero value, it is directly grown, and the neighborhood value is assigned the current position value in the original image, the current point coordinates are removed from the updated growing point container, and the neighborhood coordinates are placed in the updated growing point container; if there is a zero value in the neighborhood value, the current point coordinates are removed from the updated growing point container, and the growth of the current point is stopped; if there is a value other than the connected domain mark in the neighborhood value, the current point coordinates are removed from the updated growing point container, and the growth of the current point is stopped; when the updated growing point container is empty, the growth is completed, and the growth point is updated twice in the empty image.
[0161] The second round of weak conditional growth iteration: the updated connected domain boundary coordinates are placed into the container GrowPt again, and the non-zero area outside the connected domain marked area is removed by thrPyrDownImg as the foreground, and the zero value area is the background.
[0162] The growth rules are as follows:
[0163] 1.8 The foreground area with a non-zero neighborhood grows directly, assigns the current position value[i] to the neighborhood in diantanceU, removes the current point coordinates from GrowPt[i], and places the neighborhood coordinates into GrowPt[i].
[0164] 2. If there is a 0 value in the 8-neighborhood, the coordinates of the current point are removed and the growth of the current point is stopped.
[0165] 3. Each time the coordinate point of the container GrowPt[i] is updated, it is considered a growth iteration. When GrowPt[i] is empty, the second round of growth iteration is completed.
[0166] 4. Update the growth points in the empty graph diantanceU.
[0167] Finally, the empty image diantanceU is resized to the same size as the original image Img, and the interpolation method adopts the nearest neighbor interpolation. At this time, each connected domain represents the true contour of the target.
[0168] In order to explain the technical solution of the X-ray ore image segmentation method of the present application in detail, a specific application example will be used below, and combined with Figure 4 Expand the description. In the whole data processing process, the original image Img is obtained as follows Figure 5 As shown, the binary image thrPyrDownImg is as follows Figure 6 As shown, the distance transformation image distanceImg is as follows Figure 7 As shown, the empty map diantanceU in the growth area is as follows Figure 8 As shown in the figure, the final growth effect of the connected domain is as follows Fig. 9 The entire processing flow is as follows:
[0169] 1. Get the original image Img of the ore;
[0170] 2. 1 / 2 downsampled image pyrDownImg;
[0171] 3. Open the operation image pyrDownImg2; and proceed to step 4 and step 11 based on the open operation image pyrDownImg2;
[0172] 4. Based on the open operation image pyrDownImg2, the distance transformation image distanceImg is obtained;
[0173] 5. Traverse distanceImg to find the local maximum value within the radius kernelSize and mark it in diantanceMask;
[0174] 6. Traverse diantanceMask to find the maximum value within the radius ninPeakDistance and put the maximum value coordinates into the container vectorPosition;
[0175] 7. Traverse vectorPosition and rearrange in descending order according to value size;
[0176] 8. Traverse vectorPosition and draw non-intersecting inner filled circles in the empty map diantanceU according to the distance value corresponding to the current coordinates. If the circle drawn first contains other elements, the contained elements need to be removed from the container.
[0177] 9. The circles in diantanceU are marked as connected domains with different values as the initial growth area for each target.
[0178] 10. In the first round of strong conditional growth, the point set with the neighborhood as the background in the connected domain is placed in the container GrowPt[N]; wait to enter step 16;
[0179] 11. Based on the open operation image pyrDownImg2, obtain the contour set contour[n];
[0180] 12. The set of outer contours contour0utSide[n] is used to calculate the concave points; the set of inner contours contourInSide[n] is used to calculate the convex points;
[0181] 13. Merge the growth condition stop points into the container stopPoints;
[0182] 14. In the first round of strong condition growth, the growth stops when the termination point is reached, and the growth point is updated at diantanceU;
[0183] 15. The connected domain point set is re-placed into GrowPt[N] for the second round of weak condition growth. When GrowPt[N] is empty, the growth is completed and the growth point is updated in diantanceU;
[0184] 16. After the growth is completed, scale diantanceU to its original size.
[0185] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0186] Based on the same inventive concept, the embodiment of the present application also provides an X-ray ore image segmentation device for implementing the above-mentioned X-ray ore image segmentation method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above-mentioned method, so the specific limitations in one or more X-ray ore image segmentation device embodiments provided below can refer to the limitations of the X-ray ore image segmentation method above, and will not be repeated here.
[0187] In one embodiment, Fig.10 As shown, an X-ray ore image segmentation device is provided, comprising:
[0188] The image transformation module 100 is used to obtain the original image of the ore and generate a contour set and a distance transformation image corresponding to the original image;
[0189] The first processing module 200 is used to traverse the distance transformation image to find the local maximum value within a preset search distance radius and mark it in the mask image, traverse the marked mask image, find the maximum pixel value position within a preset minimum confidence distance between local peaks, and put the maximum pixel value position into a position container;
[0190] The second processing module 300 is used to draw non-intersecting inner filling circles in an empty image of the same size as the distance transformation image according to the distance value corresponding to the current coordinates based on the position container;
[0191] The third processing module 400 is used to mark the connected domain with different values in the empty graph as the initial growth area of each target, and put the point set with the neighborhood as the background in the connected domain into the growth point container;
[0192] The fourth processing module 500 is used to obtain a growth condition termination point according to the contour set, and place the growth condition termination point into a termination point container;
[0193] The segmentation module 600 is used to perform a first round of strong conditional growth and a second round of weak conditional growth based on multiple neighborhoods based on the growing point container and the ending point container to obtain a segmentation result of the original image.
[0194] In one embodiment, the image transformation module 100 is also used to obtain an original image of the ore, downsample the original image to obtain a downsampled image; binarize the downsampled image using an adaptive binarization method to obtain an initial binarized image; perform an opening operation on the initial binarized image to obtain a binarized image; perform contour search on the binarized image to obtain a contour set, and perform distance transformation on the binarized image to obtain a distance transformed image.
[0195] In one embodiment, the image transformation module 100 is further used to obtain a preset mask size; and perform distance transformation on the binary image based on the Euclidean distance method of the preset mask size to obtain a distance transformed image.
[0196] In one embodiment, the first processing module 200 is also used to obtain a preset search distance radius and a minimum confidence distance between local peaks; traverse the distance transformation image, compare the pixel value of the current position with the size of all pixel values within the preset search distance radius from the current position; find the local maximum value position corresponding to the maximum pixel value; mark the local maximum value position in the mask image; traverse the distance transformation image based on the marked position in the marked mask image, and search for the maximum pixel value position with the minimum confidence distance as the radius; put the maximum pixel value position into a position container, and sort the elements in the final container in descending order according to the corresponding position distance value.
[0197] In one embodiment, the second processing module 300 is also used to generate an empty image of the same size as the distance transformation image; traverse the elements in the position container, take the current coordinate point as the center of the circle and the distance value of the current coordinate point in the distance transformation image as the radius, draw non-intersecting inner filled circles in the empty image, and if the circle drawn first contains other elements, the contained elements will be removed from the position container; mark the inner filled circles in the empty image as connected domains with different values, and obtain the point set in the connected domain; use the connected domain as the initial growth area for each target, and place the point set with the neighborhood as the background in the connected domain into the growth point container.
[0198] In one embodiment, the fourth processing module 500 is also used to generate an outer contour set and an inner contour set respectively according to the contour set; calculate concave points based on the outer contour set, and calculate convex points based on the inner contour set; obtain growth condition termination points according to the concave points and convex points; and place the growth condition termination points into a termination point container.
[0199] In one embodiment, the segmentation module 600 is also used to check whether the multi-neighborhood of each point in the growth point container contains background points; based on the end point container, the current point value and the corresponding neighborhood distance value, the first round of strong conditional growth is performed in a gradient decreasing manner, the points that have grown are removed from the growth point container, the points to be grown are included in the growth point container, and the growing points are updated in the empty map; the point set whose connected domain corresponding to the first round of strong conditional growth has a neighborhood as the background is re-placed into the growth point container to obtain an updated growth point container; based on the updated growth point container, a second round of weak conditional growth is performed, and the growth is completed when the updated growth point container is empty, and the growth points are updated twice in the empty map; wherein, weak conditional growth only needs to have a neighborhood with a background to grow, the points that have grown are removed from the updated growth point container, and the points to be grown are included; according to the empty map after the second update, the segmentation result of the original image is obtained.
[0200] In one embodiment, the multi-neighborhood is an 8-neighborhood or a 4-neighborhood;
[0201] The segmentation module 600 is also used to obtain the comparison result between the current point value and the corresponding neighborhood distance value; if the current point value is not less than the corresponding neighborhood distance value, the current point value is assigned to the corresponding neighborhood in the empty graph, the current point coordinates are removed from the growth point container, and the corresponding neighborhood coordinates are placed in the growth point container; if the current point value is less than the corresponding neighborhood distance value, the current point coordinates are removed from the growth point container and the current growth is stopped; if there is a 0 value in the neighborhood, the current point coordinates are removed from the growth point container; if there is a point in the neighborhood that belongs to the termination point container, the current point coordinates are removed from the growth point container and the strong conditional growth of the connected domain is exited; if there is a non-connected domain mark value in the current neighborhood, the current point coordinates are removed from the growth point container and the strong conditional growth of the connected domain is exited; when all the coordinate points in the growth point container are updated, the growth point is updated in the empty graph.
[0202] In one embodiment, the segmentation module 600 is also used to remove the non-zero area outside the connected domain mark in the binary image as the foreground and the 0 value area as the background based on the updated growth point container; for each point in the updated growth point container, check the corresponding neighborhood value; if the neighborhood value is a foreground area with a non-zero value, it will grow directly, assign the current position value to the neighborhood value in the original image, remove the current point coordinates from the updated growth point container, and place the neighborhood coordinates into the updated growth point container; if there is a 0 value in the neighborhood value, remove the current point coordinates from the updated growth point container and stop the growth of the current point; if there is a value other than the connected domain mark in the neighborhood value, remove the current point coordinates from the updated growth point container and stop the growth of the current point; when the updated growth point container is empty, the growth is completed, and the growth point is updated twice in the empty image.
[0203] Each module in the above X-ray ore image segmentation device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0204] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Fig.11 As shown. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store preset data. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, an X-ray ore image segmentation method is implemented.
[0205] Those skilled in the art will understand that Fig.11 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0206] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the above-mentioned X-ray ore image segmentation method when executing the computer program.
[0207] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned X-ray ore image segmentation method is implemented.
[0208] In one embodiment, a computer program product is provided, comprising a computer program, which implements the above-mentioned X-ray ore image segmentation method when executed by a processor.
[0209] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program. The above-mentioned computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0210] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0211] The above embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A method for segmenting an X-ray ore image, characterized in that: The method comprises: Acquire an original image of the ore, and generate a contour set and a distance transformation image corresponding to the original image; Traversing the distance transformation image to find the local maximum value within a preset search distance radius, and marking it in the mask image, traversing the marked mask image, analyzing the marked points, ensuring that the distance between the marked points is greater than a preset minimum confidence distance, finding the maximum pixel value position within the preset minimum confidence distance between the local maximum values, and placing the maximum pixel value position into a position container; Based on the position container, drawing mutually non-intersecting inner filled circles in an empty image of the same size as the distance transformation image according to the distance value corresponding to the current coordinates; The connected domains in the empty graph with circles marked with different values are used as the initial growth region of each target, and the point sets in the connected domain with the neighborhood as the background are placed in the growth point container; According to the contour set, a growth condition termination point is obtained, and the growth condition termination point is placed in a termination point container; Performing a first round of strong conditional growth and a second round of weak conditional growth based on multiple neighborhoods based on the growing point container and the ending point container to obtain a segmentation result of the original image; Based on the position container, in an empty image of the same size as the distance transformation image, non-intersecting inner filling circles are drawn according to the distance value corresponding to the current coordinates, the circles in the empty image are marked as connected domains with different values as the initial growth area of each target, and the point set with the neighborhood as the background in the connected domain is placed in the growth point container, including: generating an empty image of the same size as the distance transformation image; traversing the elements in the position container, taking the current coordinate point as the center of the circle and the distance value of the current coordinate point in the distance transformation image as the radius, drawing non-intersecting inner filling circles in the empty image, and if the circle drawn first contains other elements, the contained elements are removed from the position container; marking the inner filling circles in the empty image as connected domains with different values, and obtaining the point set in the connected domain; taking the connected domain as the initial growth area of each target, and placing the point set with the neighborhood as the background in the connected domain into the growth point container; The step of obtaining the growth condition termination point according to the contour set and placing the growth condition termination point into the termination point container comprises: generating an outer contour set and an inner contour set respectively according to the contour set; calculating concave points based on the outer contour set and convex points based on the inner contour set; obtaining the growth condition termination point according to the concave points and the convex points; and placing the growth condition termination point into the termination point container; The first round of strong conditional growth and the second round of weak conditional growth based on multiple neighborhoods are performed based on the growing point container and the ending point container to obtain the segmentation result of the original image, including: initializing the non-zero value area outside the connected domain marked area removed from the distance transformation image as the foreground, and the zero value area as the background; for each point in the growing point container, checking whether its multiple neighborhoods contain background points; performing the first round of strong conditional growth in a gradient decreasing manner based on the ending point container, the current point value and the corresponding neighborhood distance value, removing the grown points from the growing point container, including the grown points in the growing point container, and updating the growing points in the empty image; re-inserting the point set with the connected domain corresponding to the first round of strong conditional growth as the background into the growing point container to obtain an updated growing point container; based on the more The new growth point container performs a second round of weak condition growth, and the growth is completed when the updated growth point container is empty, and the growth point is updated twice in the empty image; wherein, the weak condition growth only needs to have a neighborhood with a background to grow, and the points that have grown are removed from the updated growth point container and included in the points to be grown; according to the empty image after the second update, the segmentation result of the original image is obtained, and the strong condition growth defines a strong condition, which includes considering pixels whose color or brightness difference with the current growth point is less than a certain threshold as new growth points, and the new growth point is adjacent to the current growth point; starting from each growth point, check the pixels in its neighborhood, if they meet the strong condition, add them to the growth point container, and continue to grow from these new growth points, and stop growing when no new pixels meet the strong condition.
2. The method according to claim 1, characterized in that The step of acquiring an original image of the ore and generating a contour set and a distance transformation image corresponding to the original image comprises: Acquire an original image of the ore, and downsample the original image to obtain a downsampled image; Adopting an adaptive binarization method to binarize the downsampled image to obtain an initial binarized image; Performing an opening operation on the initial binary image to obtain a new binary image; Performing contour search on the new binary image to obtain a contour set, and performing distance transformation on the new binary image to obtain a distance transformed image.
3. The method according to claim 2, characterized in that Performing distance transformation on the binary image to obtain a distance transformed image includes: Get the preset mask size; Based on the Euclidean distance method with the preset mask size, distance transformation is performed on the binary image to obtain a distance transformed image.
4. The method according to claim 1, characterized in that The traversing of the distance transformation image to find the local maximum value within the preset search distance radius and marking it in the mask image, traversing the marked mask image to find the maximum pixel value position within the preset minimum confidence distance between the local maximum values, and placing the maximum pixel value position into the position container includes: Obtain a preset search distance radius and a minimum confidence distance between local maxima; Traversing the distance transformation image, comparing the pixel value of the current position with all pixel values within the preset search distance radius from the current position; Find the local maximum position corresponding to the maximum pixel value; marking the local maximum position in the mask image; Traversing the distance transformation image based on the marked position in the marked mask image, taking the minimum confidence distance as a radius, searching for the maximum pixel value position; The maximum pixel value position is placed in a position container, and the elements in the position container are finally arranged in descending order according to the corresponding position distance values.
5. The method according to claim 2, characterized in that: The multi-neighborhood is an 8-neighborhood or a 4-neighborhood; The first round of strong conditional growth is performed in a gradient decreasing manner based on the end point container, the current point value and the corresponding neighborhood distance value, the grown points are removed from the growing point container, the grown points are included in the growing point container, and the growing points are updated in the empty graph, including: Get the comparison result between the current point value and the corresponding neighborhood distance value; If the current point value is not less than the corresponding neighborhood distance value, assign the current point value to the corresponding neighborhood in the empty graph, remove the current point coordinates from the growth point container, and place the corresponding neighborhood coordinates into the growth point container; If the current point value is less than the corresponding neighborhood distance value, the current point coordinates are removed from the growth point container and the growth of the current point is stopped; If there is a 0 value in the neighborhood, the current point coordinates are removed from the growth point container; If there is a point in the neighborhood that belongs to the end point container, the coordinates of the current point are removed from the growth point container, and the strong conditional growth of the connected domain is exited; If there is a mark value that is not a mark value of the connected domain in the current neighborhood, the coordinates of the current point are removed from the growth point container, and the strong conditional growth of the connected domain is exited; When all coordinate points in the growth point container are updated, the growth points are updated in the empty map.
6. The method according to claim 5, characterized in that The second round of weak condition growth is performed based on the updated growth point container, and the growth is completed when the updated growth point container is empty. The second updating of the growth point in the empty graph includes: Based on the updated growth point container, the non-zero region outside the connected domain mark removed from the binary image is used as the foreground, and the zero-value region is used as the background; For each point in the updated growing point container, checking the corresponding neighborhood value; If the neighborhood value is a non-zero foreground area, it is directly grown, the neighborhood value is assigned the current position value in the original image, the current point coordinates are removed from the updated growth point container, and the neighborhood coordinates are placed in the updated growth point container; If there is a 0 value in the neighborhood value, the coordinates of the current point are removed from the updated growth point container, and the growth of the current point is stopped; If there is a non-connected domain mark value in the neighborhood value, the coordinates of the current point are removed from the updated growth point container and the growth of the current point is stopped; When the updated growth point container is empty, the growth is completed, and the growth point is updated a second time in the empty graph.
7. An X-ray ore image segmentation device, characterized in that: The device comprises: An image transformation module is used to obtain an original image of the ore and generate a contour set and a distance transformation image corresponding to the original image; A first processing module is used to traverse the distance transformation image to find the local maximum value within a preset search distance radius and mark it in the mask image, traverse the marked mask image, analyze the marked points, ensure that the distance between the marked points is greater than a preset minimum confidence distance, find the maximum pixel value position within the preset minimum confidence distance between the local maximum values, and put the maximum pixel value position into a position container, wherein the preset minimum confidence distance is used to characterize the radius of the search surrounding area; A second processing module is used to draw non-intersecting inner filling circles in an empty image of the same size as the distance transformation image according to the distance value corresponding to the current coordinates based on the position container; The third processing module is used to mark the connected domain with different values in the circle in the empty graph as the initial growth area of each target, and put the point set with the neighborhood as the background in the connected domain into the growth point container; A fourth processing module, configured to obtain a growth condition termination point according to the contour set, and place the growth condition termination point into a termination point container; A segmentation module, used for performing a first round of strong conditional growth and a second round of weak conditional growth based on multiple neighborhoods based on the growth point container and the end point container to obtain a segmentation result of the original image; Based on the position container, in an empty image of the same size as the distance transformation image, non-intersecting inner filling circles are drawn according to the distance value corresponding to the current coordinates, the circles in the empty image are marked as connected domains with different values as the initial growth area of each target, and the point set with the neighborhood as the background in the connected domain is placed in the growth point container, including: generating an empty image of the same size as the distance transformation image; traversing the elements in the position container, taking the current coordinate point as the center of the circle and the distance value of the current coordinate point in the distance transformation image as the radius, drawing non-intersecting inner filling circles in the empty image, and if the circle drawn first contains other elements, the contained elements are removed from the position container; marking the inner filling circles in the empty image as connected domains with different values, and obtaining the point set in the connected domain; taking the connected domain as the initial growth area of each target, and placing the point set with the neighborhood as the background in the connected domain into the growth point container; The step of obtaining the growth condition termination point according to the contour set and placing the growth condition termination point into the termination point container comprises: generating an outer contour set and an inner contour set respectively according to the contour set; calculating concave points based on the outer contour set and convex points based on the inner contour set; obtaining the growth condition termination point according to the concave points and the convex points; and placing the growth condition termination point into the termination point container; The first round of strong conditional growth and the second round of weak conditional growth based on multiple neighborhoods are performed based on the growing point container and the ending point container to obtain the segmentation result of the original image, including: initializing the non-zero value area outside the connected domain marked area removed from the distance transformation image as the foreground, and the zero value area as the background; for each point in the growing point container, checking whether its multiple neighborhoods contain background points; performing the first round of strong conditional growth in a gradient decreasing manner based on the ending point container, the current point value and the corresponding neighborhood distance value, removing the grown points from the growing point container, including the grown points in the growing point container, and updating the growing points in the empty image; re-inserting the point set with the connected domain corresponding to the first round of strong conditional growth as the background into the growing point container to obtain an updated growing point container; based on the more The new growth point container performs a second round of weak condition growth, and the growth is completed when the updated growth point container is empty, and the growth point is updated twice in the empty image; wherein, the weak condition growth only needs to have a neighborhood with a background to grow, and the points that have grown are removed from the updated growth point container and included in the points to be grown; according to the empty image after the second update, the segmentation result of the original image is obtained, and the strong condition growth defines a strong condition, which includes considering pixels whose color or brightness difference with the current growth point is less than a certain threshold as new growth points, and the new growth point is adjacent to the current growth point; starting from each growth point, check the pixels in its neighborhood, if they meet the strong condition, add them to the growth point container, and continue to grow from these new growth points, and stop growing when no new pixels meet the strong condition.
8. A computer device, characterized in that: It comprises a memory and a processor; the memory stores a computer program for executing the X-ray ore image segmentation method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: A computer program is stored thereon for executing the X-ray ore image segmentation method according to any one of claims 1 to 6.
