Disclosure of Invention
The invention provides a rock-shape-based self-adaptive segmentation method, equipment and medium for a detonation pile image, which are used for solving the technical problem that a watershed algorithm generates wrong segmentation due to redundant seed points in the prior art.
In order to achieve the technical purpose, the invention adopts the following technical scheme:
A detonation pile image self-adaptive segmentation method based on rock mass shape comprises the following steps:
step 1, preprocessing a detonation heap image to obtain a detonation heap binary image;
Step 2, performing distance transformation on the detonation heap binary image to obtain a distance transformation image of the detonation heap image;
Step 3, a seed point marking method based on rock contour firmness is adopted, seed point self-adaptive marking is carried out according to the distance transformation image, and a seed point diagram of the explosion pile image is obtained;
And 4, performing image segmentation on the rock in the explosion stack image according to the seed point diagram by adopting a watershed algorithm.
Further, the specific method for obtaining the seed point diagram in the step 3 is as follows:
Step 3.1, establishing a new canvas according to the size of the distance conversion image, and setting an initial value of a gray threshold;
Step 3.2, carrying out gray threshold processing on the distance conversion image according to the current gray threshold value to obtain a gray threshold value cross-section diagram;
Step 3.3, performing contour detection on the gray threshold cross-sectional views by adopting a contour detection technology to obtain the firmness of each contour in each gray threshold cross-sectional view;
Step 3.4, judging whether the firmness of each contour is larger than a given firmness threshold, if so, drawing the contour into a newly built canvas, and filling the newly built canvas as a seed point;
And 3.5, increasing the gray threshold according to a preset method, judging whether the increased gray threshold is larger than 255, if so, completing drawing of the seed dot diagram, and if not, returning to the step 3.2.
Further, after step 3.4 determines that the firmness of a certain contour is greater than a given firmness threshold, it further determines whether a background point exists in the contour, and only when the background point does not exist in the contour or the contour is irrelevant to the background point, the contour is drawn into a newly built canvas and filled as a seed point.
Further, the solidity of a rock mass profile refers to the ratio of the area of the rock mass to the area of the convex hull of the rock mass profile.
Further, the given solidity threshold is greater than 0.82.
Further, the preprocessing in the step 1 sequentially comprises image graying, bilateral filtering denoising, contrast-limited self-adaptive histogram equalization, image binarization, morphological optimization and area filtering.
Further, binarization processing is carried out on the detonation heap image by adopting a PHANSALKAR method based on local image properties.
An electronic device comprising a memory and a processor, wherein the memory stores a computer program which, when executed by the processor, causes the processor to implement the rock-shape-based detonation mass image adaptive segmentation method of any one of the above.
A computer readable storage medium having stored thereon a computer program which when executed by a processor implements the rock-shape based detonation mass image adaptive segmentation method of any of the above.
Advantageous effects
The invention firstly carries out preprocessing and distance transformation on a detonation heap image to obtain a distance transformation image, then adopts a seed point marking method based on the contour firmness of rock to carry out seed point self-adaptive marking according to the distance transformation image, namely selects a proper gray threshold to divide an adhesion part in the distance transformation image, and determines seed points through calculating the firmness so as to obtain a seed point diagram of the detonation heap image, and finally adopts a watershed algorithm to carry out image division on the rock in the detonation heap image according to the seed point diagram. Therefore, the invention can reduce the phenomenon of over-segmentation and under-segmentation of the rock mass in the prior art and realize the effective segmentation of the adhered rock mass in the explosion stack.
Detailed Description
The following describes in detail the embodiments of the present invention, which are developed based on the technical solution of the present invention, and provide detailed embodiments and specific operation procedures, and further explain the technical solution of the present invention.
Example 1
The invention provides a rock mass shape-based self-adaptive segmentation method for a detonation heap image, which comprises the steps of firstly preprocessing the detonation heap image to obtain a detonation heap binary image, then carrying out distance conversion on the detonation heap binary image to obtain a distance conversion image of the detonation heap image, then carrying out seed point self-adaptive marking according to the distance conversion image by adopting a seed point marking method based on the rock mass contour firmness to obtain a seed point diagram of the detonation heap image, and finally carrying out image segmentation on the rock mass in the detonation heap image according to the seed point diagram by adopting a watershed algorithm. On the basis of dividing images by the conventional distance transformation optimization watershed algorithm, the characteristics of large scale, serious adhesion of rock blocks, irregular shape, large granularity difference, small gray scale difference and the like of the explosion pile are considered, the seed points are marked by adopting the self-adaptive gray scale threshold based on the contour firmness of the rock blocks, the watershed algorithm based on the contour firmness of the rock blocks is formed, over-segmentation and under-segmentation phenomena are reduced, and the effective segmentation of the adhered rock blocks in the explosion pile is realized.
Specifically, the self-adaptive segmentation method for the detonation pile image based on the rock mass shape provided by the embodiment comprises the following steps:
step 1, preprocessing a detonation heap image to obtain a detonation heap binary image.
Because the acquisition environment of the detonation reactor image is complex, the detonation reactor image acquired by the machine vision system has serious noise, and the rock blocks are seriously accumulated and adhered to each other, so that the background difference degree is small and the color information is not obvious. In order to effectively divide the rock burst, preprocessing is needed to be carried out on the image of the burst, and the preprocessing flow is shown in figure 1 and sequentially comprises image graying, bilateral filtering denoising, contrast-limited self-adaptive histogram equalization, image binarization, morphological optimization and area filtering.
According to the embodiment, bilateral filtering is adopted to denoise the detonation pile gray level image, the edge of the rock is more obvious through limiting contrast self-adaptive histogram equalization, binarization processing is carried out on the detonation pile image by using a PHANSALKAR method based on local image properties, morphological optimization is carried out on the detonation pile binarization image, and area filtering is carried out. Fig. 2 is a preprocessed effect diagram, wherein fig. 2 (a) is a detonation pile gray image, fig. 2 (b) is an image after denoising through bilateral filtering, fig. 2 (c) is an effect diagram after histogram equalization, fig. 2 (d) is a detonation pile image binarization effect diagram, a PHANSALKAR method can accurately distinguish a background from ore particles, the effect is ideal, fig. 2 (e) is a detonation pile binary image after morphological optimization, and compared with fig. 2 (d), the morphological optimization can eliminate smaller holes and noise points in the binary image, smooth target edges, but still partial larger holes and larger noise points can not be removed. Fig. 2 (f) shows a binary image of the detonation reactor after the larger "holes" and noise points are eliminated by using area filtering, and a more ideal result is obtained.
And 2, performing distance transformation on the detonation heap binary image to obtain a distance transformation image of the detonation heap image.
The watershed algorithm principle is to visualize an image as a topography map in three dimensions. In this "topography" interpretation, three types of points are considered, as shown in FIG. 3, ① local minima points or minima surfaces, which correspond to the lowest point of one basin, other location points of the ② basin, and edge points of the ③ basin, i.e., the intersection of the basin with the other basins. For a particular regional minimum, the set of points that meet the condition ② is referred to as the minimum's catchment basin or watershed. The points meeting condition ③ form a frontal line at the surface, called a split line or water knockout line. The main objective of segmentation algorithms based on these concepts is to find the cutwater, i.e. the edges of the rock in the image.
The traditional watershed algorithm is usually label-free segmentation, an input object is a gradient image and is based on brightness change, the image only reflects edge information of the image, unreasonable segmentation phenomenon can occur due to the characteristic of sensitivity to noise, and the watershed algorithm has the following defects that segmentation contour offset is caused by noise in ① original images, contour of a target area is easily lost when the watershed is segmented for images with low contrast ratio ②, and the watershed over-segmentation phenomenon is caused by ③ due to a plurality of meaningless local minima of images. Therefore, the most common practice in the prior art is to perform distance transformation on the binary image.
The distance transform refers to the distance of each pixel in the binary image to its nearest zero value pixel. Assuming a binary image, in which there are a target set and a background set, and the distance map is, the definition of the distance transform is as in equation (1):
D(p)=min(disf(p,q))p∈O,q∈B (1)
wherein the distance function generally selects the Euclidean distance.
And 3, performing seed point self-adaptive marking according to the distance transformation image by adopting a seed point marking method based on the rock contour firmness, and obtaining a seed point diagram of the explosion stack image.
Fig. 4 shows an image after distance transformation of a binary image of a detonation heap, wherein (a) the image is a binary image of the detonation heap, and (b) the image is a distance image of the binary image, and it can be seen from the image (b) that the distance image of the binary image is similar to a skeleton of the image, and still retains the general shape of the image.
Fig. 5 shows a detail view of distance transformation and a seed dot diagram of a certain rock in the explosion stack image, wherein (a) is a gray image of the certain rock in the explosion stack image, (b) is a distance transformation view of the certain rock, and (c) is a local maximum point of the distance image, namely a seed point. As can be seen from fig. 5 (c), the existence of multiple maximum points, i.e. redundant seed points, in the center of the rock mass (in the rectangular frame) causes more severe over-segmentation, and there are more extreme points in the two bonded rock mass portions (in the oval frame) as well, which seriously affects the segmentation effect of the bonded rock mass.
For the problem of redundant seed points, the method which is commonly used at present mainly adopts adjacent maximum point combination and maximum point expansion combination, but as shown in fig. 5 (c), the distance between the maximum point inside the rock mass and the maximum point of the adhesion part of the rock mass is larger, and the method is difficult to accurately combine. And for complex ore images, the distribution of the maximum points is irregular, and the effect of the mode of eliminating the maximum points is poor.
In the segmentation process of some special adhesion objects, such as adhered cells, spherical particles and the like, some priori knowledge, such as the color of cell nuclei, the shape of the spherical particles and the like, can be sequentially adopted to correct seed points. However, when the segmentation object is a rock burst pile, the invention has no other available priori knowledge except the shape, and the rock burst pile is irregular in shape, and most of the rock burst is irregular polygonal. In order to explore the shape rule of the rock mass of the explosion stack, the invention carries out manual segmentation on the explosion stack image, and the segmentation effect is shown in fig. 11 (a).
By means of an image contour detection technology, the information of the rock in the explosion stack is counted, wherein the information comprises the area of the rock, a contour convex hull and the contour firmness of the rock, and the contour firmness of the rock is the ratio of the area of the rock to the area of the contour convex hull of the rock. Part of the larger rock mass information is shown, the specific information is shown in table 1, and fig. 6 is a firmness distribution histogram.
TABLE 1 explosion stack image rock mass information
It can be seen from fig. 6 that the profile solidity of the larger rock mass in this figure ranges from 0.82 to 0.97, and is mainly concentrated between 0.87 and 0.95, so that the profile solidity of the rock mass of the explosion stack is high, which can result in the shape of the rock mass of the explosion stack approaching or being equal to a convex polyhedron.
Based on the research, in order to solve the technical problem of redundant seed points, the invention provides a seed point marking method based on rock contour firmness, which is used for carrying out seed point self-adaptive marking according to a distance transformation image to obtain a seed point diagram of a detonation heap image. According to the method, a proper gray threshold is selected to enable a stuck part (namely stuck rock blocks in a detonation pile image) in a distance transformation graph to be separated, and a seed point is determined by calculating contour firmness through contour detection. As shown in fig. 7, (a) is a three-dimensional schematic view of a distance image, wherein the height is a gray value of a corresponding point, (b 1) is a three-dimensional schematic view of a distance image when the gray threshold is 50, (b 2) is a corresponding two-dimensional cross-sectional view thereof, (c 1) is a three-dimensional schematic view of a distance image when the gray threshold is 100, and (c 2) is a corresponding two-dimensional cross-sectional view thereof.
It can be seen from fig. 7 (b 1) and (b 2) that when the gray threshold is too small, although smaller rock pieces can be divided and seed points can be obtained, more large rock pieces still have sticking, and most of them do not satisfy the firmness condition and cannot be used as seed points. It can be seen from fig. 7 (c 1) and (c 2) that when the gray threshold is too large, the large rock mass can be divided, but the small rock mass is ignored. Because the size difference of the rock burst is large, a single gray threshold cannot meet the marking of the seed points of the rock burst, so that the processing is carried out by adopting multiple gray thresholds, the outline in the two-dimensional sectional view after the processing of each gray threshold is judged, and if the outline meets the condition of the seed points, the interior of the outline is filled and marked as the seed points.
The step 3 of the seed point marking method based on the rock contour firmness in the embodiment is integrated with the analysis and arrangement, and comprises the following steps:
Step 3.1, establishing a new canvas according to the size of the distance conversion image, and setting an initial value of a gray threshold, for example, setting the initial gray threshold to be 10;
Step 3.2, carrying out gray threshold processing on the distance conversion image according to the current gray threshold to obtain a gray threshold section view, as shown in two-dimensional section views of fig. 7 (b 2) and (c 2);
Step 3.3, performing contour detection on the gray threshold cross-sectional views by adopting a contour detection technology to obtain the firmness of each contour in each gray threshold cross-sectional view;
Step 3.4, judging whether the firmness of each contour is larger than a given firmness threshold, if so, drawing the contour into a newly built canvas, and filling the newly built canvas as a seed point;
Because the seed point marking method is based on a distance conversion image, when the contour firmness of a certain background area or noise point in a binary image is too high, a concave structure as shown in fig. 8 (a) is formed in the background area after the distance conversion treatment, when the contour is taken by adopting a gray threshold, the contour as shown in fig. 8 (b) is formed, therefore, in a more preferred embodiment, after judging that the firmness of a certain contour is larger than a given firmness threshold in step 3.4, whether a background point exists in the contour (firstly, the position of the contour is determined in the binary image, then, whether a background pixel value 0 exists in the contour is judged, and only when the background point does not exist in the contour (the background pixel value 0 does not exist in the contour) or the contour is irrelevant to the background point (judging that a plurality of background points exist in the contour, 1: number is larger than 1, 2: number is equal to 1, judging whether the centroid of the contour exists in the background point area or not, if not exists, if irrelevant, the contour exists, then, the contour is relevant) is further judged, and the newly created contour is used as a filling point.
And 3.5, increasing the gray threshold according to a preset method, judging whether the increased gray threshold is larger than 255, if so, completing drawing of the seed dot diagram, and if not, returning to the step 3.2. The method for increasing the gray threshold may be equal step increment or increment according to other functions, and the invention is not particularly limited.
The firmness is related to the rock type, so the firmness threshold is given different values specifically according to the rock type. From fig. 6 it can be seen that the contour firmness of the larger rock mass in this figure ranges from 0.82 to 0.97.
And 4, performing image segmentation on the rock in the explosion stack image according to the seed point diagram by adopting a watershed algorithm, and particularly performing segmentation on an image (fig. 2 (c)) obtained by limiting contrast histogram equalization on the explosion stack gray image according to the seed point diagram. The invention is not elaborated on because the watershed algorithm is used to divide the image into the prior art.
The effect of the method on the segmentation of the rock mass in the image of the detonation reactor is demonstrated by experiments.
1. Seed point marking and segmentation results
In order to explore the segmentation effect of the self-adaptive watershed method of the detonation heap images based on the rock mass contour firmness on the detonation heap rock mass, the experiment respectively acquires the detonation heap images of two different rocks of limestone and granite, and the segmentation method is applied to segment the detonation heap images. Wherein the limestone detonation pile image is shown in fig. 2 (a), the binary image is shown in fig. 4 (a), the granite detonation pile image is shown in fig. 9 (a), and the binary image is shown in fig. 9 (b).
And (3) marking seed points on the two rock explosion pile binary images by adopting a seed point marking method based on rock mass contour firmness, wherein a firmness threshold value is 0.85, and dividing according to a seed point diagram by adopting a watershed algorithm. The marking effect and the dividing effect of the seed points are shown in fig. 10, wherein (a) is a superposition graph of a limestone seed point graph and a gray scale graph, (b) is a limestone explosion pile dividing effect graph, (c) is a superposition graph of a granite seed point graph and a gray scale graph, and (d) is a granite explosion pile dividing effect graph.
2. Seed point marking outcome analysis
From fig. 10 (a) and (c), it can be seen that the seed point marking method based on the contour firmness of the rock mass can effectively mark the rock mass, especially the larger rock mass. Comparing fig. 10 (a) and (c) with the preprocessed binary images of the explosion stack respectively, it is found that the seed point marking method of the present invention can avoid the influence of the internal noise of the binary image rock mass on the segmentation, such as the black square frame in fig. 9 (b).
3. Analysis of detonation heap image segmentation result
As can be seen from fig. 10 (b) and (d), the method for adaptively dividing the detonation heap image based on the rock contour firmness can realize more accurate segmentation of the detonation heap image with serious stacking and adhesion, in particular to the limestone detonation heap image with fewer noise points. And the granite explosion pile image is affected by the problems of rock block shadows and the like, so that the segmentation effect is poorer than that of the limestone explosion pile image. In order to evaluate the quantization indexes of the segmentation results, the experiment evaluates the segmentation effect of two detonation pile images by taking a manual segmentation graph as a segmentation standard, wherein the manual segmentation graph of the limestone detonation pile is shown in fig. 11 (a), and the manual segmentation graph of the granite detonation pile is shown in fig. 11 (b).
(1) Analysis of overall segmentation effect of detonation heap image
Fig. 12 and 13 are respectively area cumulative distribution curves of rock masses in images of limestone and granite explosion stacks, and the calculation formula is shown in formula (2).
Where P is the cumulative area ratio of the rock mass, S total is the sum of all the identified rock mass areas of the whole detonation stack image, and S x is the cumulative area of the rock mass at the area classification.
From fig. 12 and 13, it can be seen that the area accumulation distribution curve of the segmentation method is highly similar to that of the manual segmentation result, and in particular, limestone, which shows that the segmentation method can accurately segment the image rock blocks of the explosion pile.
(2) Analysis of single rock segmentation effect of detonation reactor image
To evaluate the segmentation effect of the self-adaptive watershed algorithm of the explosion pile image on a single rock based on the contour firmness of the rock mass, more than 15 rock masses with more than 2000 areas and serious adhesion or shadow on the surface are extracted from the two explosion pile images, the position distribution and the corresponding area of the extracted limestone rock mass are respectively shown in fig. 11 (a) and table 2, and the position distribution and the corresponding area of the granite rock mass are respectively shown in fig. 11 (b) and table 3. It can be seen from table 2 that the maximum relative error of the 15 limestone pieces extracted is 4.26% of the number 4, while the minimum relative error is only 0.27%, and the average relative error is 1.85%. It can be seen from table 3 that the maximum relative error of the extracted 15 granite blocks is 13.30% of the number 3, while the minimum relative error is only 0.91%, and the average relative error is 5.62%.
TABLE 2 limestone mass area
TABLE 3 granite rock mass area
The above embodiments are preferred embodiments of the present application, and various changes or modifications may be made thereto by those skilled in the art, which should be construed as falling within the scope of the present application as claimed herein, without departing from the general inventive concept.