Stone edge image segmentation method for stone image
By using the Roberts differential operator and the local adaptive threshold segmentation method to complete the edge lines of the stone, the problem of unclear edge lines in stone image segmentation is solved, and the accuracy of stone gradation detection is improved.
Patent Information
- Application Number
- CN202211627347.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-16
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2042-12-16
AI Technical Summary
Existing technologies cannot accurately segment the edges of stones in stone images, resulting in large errors in stone gradation detection.
The Roberts differential operator is used for edge detection, combined with endpoint detection and local adaptive threshold segmentation to complete the edge lines of the stones and ensure the integrity of the outline of each stone.
It improves the accuracy of stone gradation testing, ensures the accuracy and completeness of stone edge line detection, and reduces errors.
Smart Images

Figure CN116029989B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of image processing, in particular to a stone edge image segmentation method for stone images. BACKGROUND
[0002] In the field of water conservancy and civil engineering, the gradation characteristics of soil and stone materials are one of the main factors affecting the mechanical properties of soil and stone materials after compaction. For example, in the process of filling a soil and stone dam, a large amount of soil and stone samples need to be tested for gradation to ensure the quality of the project.
[0003] The existing soil and stone material gradation detection mainly uses the traditional screening method to calculate the gradation data by combining random sampling and manual screening. Although this method is mature in technology, it is time-consuming, labor-intensive, and not representative. With the development of computer technology, image recognition technology has been widely applied in various fields. In the field of water conservancy and civil engineering, image recognition technology has achieved fruitful results in the research of soil and stone material gradation detection.
[0004] However, due to the characteristics of most stone detection samples, such as large volume, wide range of particle size distribution, varied color and shade, and overall darkness, the existing soil and stone material gradation detection methods based on image recognition technology cannot be directly used for stone gradation detection. One of the reasons is that the stone particles have similar extensions and shapes, and the outline of the stone block is similar to the outline of the stone particle, which cannot accurately extract the single stone particle outline and independently segment it in the image recognition process. This leads to the detection of multiple stone block objects as the same stone block object or the segmentation of the same stone block object into multiple scattered stone block objects, resulting in a large detection error. SUMMARY
[0005] The present application provides a stone edge image segmentation method for stone images to solve the problem of being unable to segment stone images along the stone edge line in the prior art. The stone edge image segmentation method for stone images is used to segment the stone image based on the complete stone edge line, thereby preserving the complete outline of each stone block in the stone, and improving the detection accuracy in the subsequent stone gradation detection process.
[0006] The present application provides a stone edge image segmentation method for stone images, which comprises the following steps:
[0007] Step S1: performing gray-scale processing on a color stone image to obtain a gray-scale image f(x, y), and converting it into a two-dimensional discrete matrix f(x, y);
[0008] Step S2: performing edge detection on the gray-scale image f(x, y) using a Roberts differential operator to obtain an edge detection result E(x, y);
[0009] Step S3: endpoint detection is performed on each edge line detection result E(x, y) to extract the endpoint of each edge line to obtain an endpoint detection result C(x, y);
[0010] Step S4: the extension direction D of each endpoint in the endpoint detection result C(x, y) is calculated, a pairing result P is calculated according to the extension direction D of each endpoint and the geometric distance between each endpoint, and the missing part of the edge line is connected and completed according to the pairing result P to obtain a complete edge line E'(x, y);
[0011] Step S5: a local adaptive threshold segmentation method is used to perform binaryzation on the gray-scale image f(x, y) to obtain a binary image f 0-1 (x, y), the complete edge line E'(x, y) is used to segment the obtained binary image f 0-1 (x, y) to obtain a target image f' 0-1 (x, y).
[0012] Preferably, the two-dimensional discrete matrix in step S1 is calculated according to the following formula:
[0013] f(x, y) = 0.2989 * f R + 0.5870 * f G + 0.1140 * f B
[0014] In the formula, f R , f G , and f B represent the red component, the green component, and the blue component of the color stone image f(R, G, B), respectively.
[0015] Preferably, the Roberts differential operator method in step S2 includes the following steps:
[0016] Step S21: the discrete gray-scale image is f(x, y), where (x i , y j ) represents the coordinates of the i-th row and j-th column pixel point in the discrete gray-scale image matrix, and f(x i , y j ) represents the gray-scale value of the corresponding pixel point. When performing edge detection on the image, the vertical difference and the horizontal difference of the image are used to approximate the gradient operator, that is:
[0017] Δf = (f(x, y) - f(x-1, y), f(x, y) - f(x, y-1))
[0018] When calculating Δf, the Roberts differential operator calculates the gradient Δf(x i , y j ) of each pixel point according to the following formula, and then takes the absolute value of the obtained result:
[0019]
[0020] Step S22: Roberts differential operator is composed of the following two templates:
[0021]
[0022] The threshold operation of each pixel point gradient Δf(x i ,y j ) obtains the edge detection result E(x,y), and the threshold value is V, then the edge detection result E(x i ,y i ) can be calculated as follows:
[0023]
[0024] Wherein, the edge detection result E(x,y) is a binary image, the value 1 in the image matrix represents an edge line, and the value 0 represents a non-edge line, and V is a threshold scalar artificially set.
[0025] Preferably, the endpoint detection in step S3 comprises the following steps:
[0026] Step S31: the value 1 in the edge detection result E(x,y) represents an edge line, and the value 0 represents a non-edge line, and now all the pixel points with the value 1 in E(x,y) are divided into three categories, namely isolated points, edge line endpoints and edge line internal points;
[0027] Step S32: the pixel points in the color image are divided into corner pixel points located at the four corners of the image, edge pixel points located on the four edge lines of the image and internal pixel points located in the internal of the image according to their spatial positions, wherein the corner pixel points are adjacent to 3 pixel points, the edge pixel points are adjacent to 5 pixel points, and the internal pixel points are adjacent to 8 pixel points;
[0028] Step S33: all the pixel points with the value 1 in the edge detection result E(x,y) are judged as follows: if the values of the pixel points adjacent to the target pixel point are all 0, then the point is an isolated point;
[0029] if only one of the pixel points adjacent to the target pixel point has the value 1, then the point is an edge line endpoint;
[0030] if the number of pixel points with the value 1 among the pixel points adjacent to the target pixel point is greater than or equal to 2, then the point is an edge line internal point, and the judgment results of the pixel points are outputted;
[0031] Step S34: if the edge pixel point is an isolated point, set the pixel value as 1; if the edge pixel point is an end point, set the pixel value as 2; otherwise, set the pixel value as 3, which is represented as follows:
[0032]
[0033] In the above formula, C(x, y) is the pixel point type label result, e(x i ,y j ) is the adjacent pixel point of the pixel point (x i ,y j ), and the value of the pixel point number m is 3 or 5 or 8.
[0034] Preferably, the edge direction measurement in step S4 includes the following steps:
[0035] For the pixel point with the value of 2 in the end point detection result C(x, y) (such points are edge line end points), set the edge pixel point connected with a certain end point (x l ,y l ) as (x l-nect ,y l-nect ), and calculate the extension direction of the edge line at the point (x l ,y l ) according to the following formula:
[0036] D l = (x l ,y l ) - (x l-nect ,y l-nect ), 1≤l≤N
[0037] wherein D l represents the extension direction of the edge line at the end point (x l ,y l ), l is the end point number, and N is the number of end points.
[0038] Preferably, the obtaining of the complete edge line in step S4 includes the following steps:
[0039] Step S42: find out each pair of end points that should be connected together in the actual edge line of the stone, and then connect the obtained end points, which specifically includes the following steps:
[0040] Given the extension direction of the edge line at the point (x l ,y l ) as D l , take (x l ,y l ) as the center and a set value r as the radius, find all the end points C l,r,n(x,y), n is the number of end points falling in the circle, and the specific calculation formula is as follows:
[0041]
[0042] Then, from C l,r,n (x,y) select the paired end points (x l ,y l ) of the end points (x l-p ,y l-p ), when pairing the end points (x l ,y l ), the point with the smallest distance between the paired two points is selected according to the distance between the paired two points and the measuring direction; the two end points with opposite measuring directions are selected for pairing, as shown in the following formula:
[0043] P l =min{w1||(x1,y1)-(x l ,y l )||+w2[|(x1+x l )|+|(y1+y l )|],w1||(x2,y2)-(x l ,y l )||+w2[|(x2+x l )|+|(y2+y l )|],…,w1||(x k ,y k )-(x l ,y l )||+w2[|(x k +x l )|+|(y k +y l )|],…,w1||(x n ,y n )-(x l ,y l )||+w2[|(x n +x l )|+|(y n +y l )|]},C l,r,k (x,y)=1,1≤k≤n
[0044] wherein P l is the paired end point of the end point (x l ,y l ), and the coordinate value is (x l-p ,y l-p ), w1 and w2 are weight coefficients, and satisfy the condition w1+w2=1;
[0045] Step S43: connecting the paired pixel points (x l ,y l ) and (x l-p ,y l-p ), to obtain the complete edge line E'(x,y).
[0046] Preferably, the gray-scale image f(x,y) is locally self-adaptively threshold segmented in step S5 to obtain a binary image f 0-1 (x,y) according to the following formula:
[0047]
[0048] In the formula, f' 0-1 (x,y) is the target binary image after segmentation.
[0049] Another aspect of the present application also provides a stone edge image segmentation device for stone images as described above, comprising:
[0050] a conversion module, configured to perform gray-scale processing on a color stone image to obtain a gray-scale image f(x,y), and convert the gray-scale image f(x,y) into a two-dimensional discrete matrix f(x,y);
[0051] an edge detection module, configured to perform edge detection on the gray-scale image f(x,y) by using a Roberts differential operator to obtain an edge detection result E(x,y);
[0052] an endpoint detection module, configured to perform endpoint detection on each edge line detection result E(x,y) to extract endpoints of each edge line to obtain an endpoint detection result C(x,y);
[0053] an edge completion module, configured to measure an extension direction D of each endpoint in the endpoint detection result C(x,y), calculate a pairing result P according to the extension direction D of each endpoint and a geometric distance between the endpoints, and connect and complete a missing part of the edge line according to the pairing result P to obtain a complete edge line E'(x,y);
[0054] a binarization module, configured to perform binarization processing on the gray-scale image f(x,y) by using a locally self-adaptive threshold segmentation method to obtain a binary image f 0-1 (x,y), and segment the obtained binary image f 0-1 (x,y) by using the complete edge line E'(x,y) to obtain a target image f0' -1 (x,y).
[0055] The present application can produce the following beneficial effects:
[0056] 1) The stone edge image segmentation method for stone image provided by the present application, after the stone block edge is extracted by the two-dimensional discrete matrix Roberts differential operator of the color image, the endpoint pixel value of the edge image is detected, the extension direction of each endpoint is determined, each endpoint value is connected, the complete edge line is filled, the original image is binarized, and the target image is obtained by segmenting the binarized image with the complete edge line. The stone particle edge in the obtained image is clear and complete, and compared with the existing gray value image processing result, the accuracy of the stone block edge line detection result can be improved. BRIEF DESCRIPTION OF DRAWINGS
[0057] Figure 1 The stone edge image segmentation method for stone image provided by the present application is shown in the flowchart;
[0058] Figure 2 The original image of the stone to be segmented in the embodiment of the present application is processed;
[0059] Figure 3 The gray scale image after processing the stone original image in the embodiment of the present application is shown in the flowchart;
[0060] Figure 4 The preliminary detection result of the stone edge line in the embodiment of the present application is shown in the flowchart;
[0061] Figure 5 The endpoint detection result of the stone edge line in the embodiment of the present application is shown in the flowchart;
[0062] Figure 6 The effect diagram of the stone edge line endpoint pairing and connection in the embodiment of the present application is shown in the flowchart;
[0063] Figure 7 The stone edge line detection effect diagram in the embodiment of the present application is shown in the flowchart;
[0064] Figure 8 The stone particle image segmentation result obtained by using the method provided by the present application in the embodiment of the present application is shown in the comparison diagram, wherein a) is the stone particle binary image obtained by using the existing method; b) is the stone particle binary image obtained by using the method provided by the present application;
[0065] Figure 9 The stone edge image segmentation device module schematic diagram provided by the present application for stone image is shown in the flowchart. DETAILED DESCRIPTION
[0066] In order to make the purposes, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings can be arranged and designed in various different configurations.
[0067] Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the claimed present application, but only represents selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative labor fall within the scope of protection of the present application.
[0068] The technical means not described in detail in the present application and not used to solve the technical problems of the present application are set according to common knowledge in the art, and various common knowledge setting modes can be implemented.
[0069] Referring to Figure 1 The stone edge image segmentation method for stone images provided by the present application comprises the following steps:
[0070] Step S1: performing gray-scale processing on a color stone image to obtain a gray-scale image f(x, y) and converting the gray-scale image f(x, y) into a two-dimensional discrete matrix f(x, y);
[0071] Step S2: performing edge detection on the gray-scale image f(x, y) by using a Roberts differential operator to obtain an edge detection result E(x, y);
[0072] Step S3: performing endpoint detection on each edge line detection result E(x, y) to extract the endpoints of each edge line and obtain an endpoint detection result C(x, y);
[0073] Step S4: measuring the extension direction D of each endpoint in the endpoint detection result C(x, y), calculating a pairing result P according to the extension direction D of each endpoint and the geometric distance between each endpoint, and connecting and completing the missing parts of the edge lines according to the pairing result P to obtain a complete edge line E'(x, y);
[0074] Step S5: performing binaryzation processing on the gray-scale image f(x, y) by using a local adaptive threshold segmentation method to obtain a binary image f(x, y), and segmenting the obtained binary image f(x, y) by using the complete edge line E'(x, y) to obtain a target image f0'(x, y). 0-1 0-1 -1
[0075] The edge of the gray-scale image is detected by using the Roberts differential operator on the two-dimensional discrete matrix according to the above operation steps, and the endpoint value of the obtained edge is extracted, so that the endpoint detection result is effectively obtained, and the edge line of the stone particle in the image is completed by using the endpoint connection line, and the subsequent binarization processing object is the image whose edge line is completed, which can effectively avoid the edge loss caused by direct binarization processing, improve the integrity and separation accuracy of the final obtained stone particles, and avoid the unclear edge problem of the binary image obtained from the gray-scale image, and improve the segmentation accuracy of the stone particles.
[0076] The method detects the edge line of the stone particle by using the Roberts differential operator, has high accuracy of the detection result, can effectively identify the blocked edge line area, and obtains a complete stone particle contour.
[0077] Preferably, the two-dimensional discrete matrix in step S1 is calculated according to the following formula:
[0078] f(x,y) = 0.2989xf R + 0.5870xf G + 0.1140xf B
[0079] In the formula, f R , f G and f B respectively represent the red component, the green component and the blue component in the color stone image f(R, G, B).
[0080] Preferably, the Roberts differential operator method in step S2 includes the following steps:
[0081] Step S21: assuming that the discrete gray-scale image is f(x, y), wherein (x i ,y j ) represents the coordinates of the i-th row and j-th column pixel point in the discrete gray-scale image matrix, and f(x i ,y j ) represents the gray-scale value of the corresponding pixel point, when the image edge is detected, the vertical difference and the horizontal difference of the image are used to approximate the gradient operator, that is:
[0082] Δf = (f(x, y)-f(x-1, y), f(x, y)-f(x, y-1))
[0083] When the Roberts differential operator calculates Δf, the gradient Δf(x i ,y j ) of each pixel point is calculated according to the following formula, and then the absolute value of the obtained result is calculated:
[0084]
[0085] Step S22: The Roberts differential operator consists of the following two templates:
[0086]
[0087] Thresholding the gradient Δf(x) for each pixel i ,y j The edge detection result E(x,y) is obtained. Let the threshold be V. Then the edge detection result E(x,y) is... i ,y i It can be calculated using the following formula:
[0088]
[0089] The edge detection result E(x,y) is a binary image. In the image matrix, a value of 1 represents an edge line, a value of 0 represents a non-edge line, and V is a manually set threshold scalar.
[0090] This method is used to calculate the gradient Δf(x) for each pixel. i ,y j This method obtains the edge detection result E(x,y), thereby effectively improving the accuracy of the edge detection result.
[0091] Preferably, the endpoint detection in step S3 includes the following steps:
[0092] Step S31: In the edge detection result E(x,y), a value of 1 represents an edge line and a value of 0 represents a non-edge line. Now, all pixels with a value of 1 in E(x,y) are divided into three categories: isolated points, edge line endpoints, and points inside the edge line.
[0093] Step S32: The pixels in the color image are divided into three categories according to their spatial location: corner pixels located at the four corners of the image, edge pixels located on the four sides of the image, and internal pixels located inside the image. Corner pixels are adjacent to 3 pixels, edge pixels are adjacent to 5 pixels, and internal pixels are adjacent to 8 pixels.
[0094] Step S33: For all pixels with a value of 1 in the edge detection result E(x,y), the following judgment is made: if the value of all pixels adjacent to the target pixel is 0, then the pixel is an isolated point;
[0095] If there is exactly one pixel with a value of 1 among the pixels adjacent to the target pixel, then the point is the endpoint of the edge line;
[0096] If the number of pixels with a value of 1 among the pixels adjacent to the target pixel is greater than or equal to 2, then the pixel is an inside point of the edge line, and the judgment result of each pixel is output.
[0097] Step S34: if the edge pixel point is an isolated point, set the pixel value of the edge pixel point as 1; if the edge pixel point is an end point, set the pixel value of the edge pixel point as 2; otherwise, set the pixel value of the edge pixel point as 3, which is represented as follows:
[0098]
[0099] In the above formula, C(x, y) is a pixel point type label result, e(x i ,y j ) is a neighboring pixel point of the pixel point (x i ,y j ), and the value of the pixel point number m is 3 or 5 or 8.
[0100] After the assignment result of the pixel points around each pixel point with a median value of 1 is screened by the above method, a more accurate position of the pixel point in the stone block particle is obtained. Thus, the processing accuracy of the detection result is improved.
[0101] Preferably, specifically, the edge line direction measurement in step S4 includes the following steps:
[0102] For the pixel point with a median value of 2 in the end point detection result C(x, y) (such a point is an edge line end point), the edge pixel point connected with the end point (x l ,y l ) is (x l-nect ,y l-nect ), and the extension direction of the edge line at the point (x l ,y l ) is calculated according to the following formula:
[0103] D l =(x l ,y l )-(x l-nect ,y l-nect ),1≤l≤N
[0104] wherein, D l represents the extension direction of the edge line at the end point (x l ,y l ), l is the end point number, and N is the number of end points.
[0105] The calculation of the extension direction of the edge line end point with a median value of 2 in the end point detection result C(x, y) according to the above steps can effectively improve the accuracy of the corresponding edge line of the end point.
[0106] Preferably, specifically, the obtaining of the complete edge line in step S4 includes the following steps:
[0107] Step S42: Locate each pair of endpoints that should originally be connected along the actual edge line of the stone, and then connect the obtained endpoints. This includes the following steps:
[0108] Given that the edge line is in (x l ,y l The direction of extension at point D is... l , with (x l ,y l Using a circle with center r and radius r, find all endpoints C that fall within the circle. l,r,n (x, y), where n is the number of endpoints falling inside the circle. The specific calculation formula is as follows:
[0109]
[0110] Then from C l,r,n Select endpoint (x) in (x,y) l ,y l The paired endpoints (x) l-p ,y l-p ), in performing (x l ,y l When pairing endpoints, the point with the smallest distance between the two points is selected based on the distance between them and the measurement direction; endpoints with opposite measurement directions are selected for pairing, as shown in the following formula:
[0111] P l =min{w1||(x1,y1)-(x l ,y l )||+w2[|(x1+x l )|+|(y1+y l )|],
[0112] w1||(x2,y2)-(x l ,y l )||+w2[|(x2+x l )|+|(y2+y l )|],…,
[0113] w1||(x k ,y k )-(x l ,y l )||+w2[|(x k +x l )|+|(y k +y l )|],…,
[0114] w1||(x n ,y n )-(x l,y l )||+w2[|(x n +x l )|+|(y n +y l )|]},
[0115] C l,r,k (x,y)=1,1≤k≤n
[0116] Among them, P l For endpoints (x) l ,y l The paired endpoints of ) have coordinates (x l-p ,y l-p w1 and w2 are weighting coefficients, satisfying the condition w1 + w2 = 1;
[0117] Step S43: Connect the paired pixels (x l ,y l ) and (x l-p ,y l-p ), to obtain the complete edge line E'(x,y).
[0118] Using the above steps to complete the edge lines can improve the accuracy of the completed edge lines and effectively eliminate error-prone edge lines.
[0119] Preferably, in step S5, the grayscale image f(x,y) is subjected to local adaptive threshold segmentation according to the following formula to obtain the binary image f. 0-1 (x,y):
[0120]
[0121] In the formula, f0' -1 (x,y) is the target binary image after segmentation.
[0122] See Figure 9 Another aspect of this application provides a stone edge image segmentation apparatus for stone images as described above, comprising:
[0123] The conversion module is used to perform grayscale processing on the colored stone image to obtain a grayscale image f(x,y), and then convert it into a two-dimensional discrete matrix f(x,y);
[0124] The edge detection module is used to perform edge detection on the grayscale image f(x,y) using the Roberts differential operator to obtain the edge detection result E(x,y);
[0125] The endpoint detection module is used to perform endpoint detection on the edge line detection results E(x,y) and extract the endpoints of each edge line to obtain the endpoint detection result C(x,y);
[0126] an edge completion module, configured to calculate the extension direction D of each end point in the end point detection result C(x, y), calculate the pairing result P according to the extension direction D of each end point and the geometric distance between each end point, and connect and complete the missing part of the edge line according to the pairing result P, to obtain the complete edge line E'(x, y);
[0127] a binarization module, configured to perform binarization processing on the gray-scale image f(x, y) by using a local adaptive threshold segmentation method to obtain a binary image f 0-1 (x, y), and segment the obtained binary image f 0-1 (x, y) by using the complete edge line E'(x, y) to obtain a target image f' 0-1 (x, y).
[0128] The device can effectively process the stone image and output a processing result.
[0129] Embodiment
[0130] comprising the following steps:
[0131] Step S1, performing gray-scale processing on the color stone image f(R, G, B) to convert it into a two-dimensional discrete matrix f(x, y), and the calculation formula is as follows:
[0132] f(x, y) = 0.2989 * f R + 0.5870 * f G + 0.1140 * f B
[0133] In the formula, f R , f G , and f B respectively represent the red component, the green component, and the blue component in the color image f(R, G, B);
[0134] Step S2, performing edge detection on the gray-scale image f(x, y) by using a Roberts differential operator to obtain an edge detection result E(x, y), and the calculation process is as follows:
[0135] In combination with the general rule of the stone particle image, the stone particle contour line features are analyzed, and finally the Roberts differential operator is selected for stone particle edge line detection, and the principle of the Roberts differential operator is as follows:
[0136] The object for performing edge detection is a discrete gray-scale image, and the discrete gray-scale image is denoted as f(x, y), where (x i , y j ) represents the coordinates of the i-th row and j-th column pixel point in the discrete gray-scale image matrix, and f(x i , y j) represents the gray value of the corresponding pixel. When performing image edge detection, vertical and horizontal difference of the image is used to approximate the gradient operator, i.e.:
[0137] Δf = (f(x, y) - f(x-1, y), f(x, y) - f(x, y-1))
[0138] Roberts differential operator calculates the gradient Δf(x i ,y j ) of each pixel respectively, and then calculates the absolute value, the formula is:
[0139]
[0140] Roberts differential operator is composed of the following two templates:
[0141]
[0142] Finally, the gradient Δf(x i ,y j ) of each pixel is thresholded, and the edge detection result is obtained. Let the threshold be V, then the edge detection result E(x i ,y i ) can be calculated as follows:
[0143]
[0144] Where the edge detection result E(x, y) is a binary image, the value 1 in the image matrix represents an edge line, and the value 0 represents a non-edge line, and V is a threshold scalar set by man.
[0145] Step S3, endpoint detection is performed on the edge line detection result E(x, y), and the endpoints of each edge line are extracted, and the endpoint detection result is C(x, y), the calculation process is as follows:
[0146] The value 1 in the edge detection result E(x, y) represents an edge line, and the value 0 represents a non-edge line, now all the pixels with value 1 in E(x, y) are judged as follows: and according to the judgment result, they are divided into isolated points, edge line endpoints and edge line internal points.
[0147] It is known that the pixel points in an image can be classified into three categories according to their spatial positions, i.e. corner pixel points located at four corners of the image, edge pixel points located on four edges of the image and internal pixel points located in the interior of the image, wherein the corner pixel points are adjacent to three pixel points, the edge pixel points are adjacent to five pixel points and the internal pixel points are adjacent to eight pixel points. The classification rules of all pixel points with a value of 1 are as follows: if the values of all pixel points adjacent to the target pixel point are 0, the target pixel point is an isolated point; if only one pixel point adjacent to the target pixel point has a value of 1, the target pixel point is an edge line end point; if the number of pixel points adjacent to the target pixel point with a value of 1 is greater than or equal to 2, the target pixel point is an edge line internal point. The classification result of the edge pixel point is C(x, y), if the edge pixel point is an isolated point, the pixel value of the edge pixel point is set to 1, if the edge pixel point is an end point, the pixel value of the edge pixel point is set to 2, otherwise, the pixel value of the edge pixel point is set to 3, which is represented as follows:
[0148]
[0149] In the above formula, C(x, y) is the type label result of the pixel point, e(x i ,y j ) is the adjacent pixel point of the pixel point (x l ,y l ), and the value of the number m of pixel points is 3 or 5 or 8.
[0150] Step S4, edge line direction measurement, the extension direction D of each end point in C(x, y) is measured and calculated, and the calculation process is as follows:
[0151] The edge line direction measurement is only for the pixel points with a value of 2 in C(x, y) (edge line end points). Assuming that a certain end point is (x l-nect ,y l-nect ), the edge pixel points connected thereto are (x l ,y l ), the possible extension direction of the edge line at the point (x l ,y l ) is calculated by the following formula:
[0152] D l =(x l-nect ,y l-nect )-(x l ,y l ), 1≤l≤N
[0153] In the above formula, D l represents the extension direction of the edge line at the end point (x l ,y l ), l is the end point number, and N is the number of end points.
[0154] Step S5, the edge line each end point pair connection, according to the extension direction D and the geometry distance between each end point, calculate the pairing result P, and according to the pairing result P, the edge line missing part is connected, get the complete edge line E'(x, y), the calculation process is as follows:
[0155] Edge line end point pair connection refers to find out each pair of end points which should be connected together in the actual edge line of stone, and then connect them together. Given the edge line in (x l ,y l ) point possible extension direction is D l , now take (x l ,y l ) as the center, take the set value r as the radius, find all the end points C l,r,n (x,y) falling within the circle, n is the number of end points falling within the circle, the specific calculation formula is as follows:
[0156]
[0157] Then the pairing end point (x l-p ,y l-p ) of the end point (x l ,y l ) should be selected from C l,r,n (x,y), when pairing the end point (x l ,y l ), two factors are mainly considered, the first is the distance between two points, theoretically, the smaller the distance is, the better, the second is the measuring direction, theoretically, the measuring direction of the two end points to be paired is opposite, so the pairing mode is as follows:
[0158] P l =min{w1||(x1,y1)-(x l ,y l )||+w2[|(x1+x l )|+|(y1+y l )|],
[0159] w1||(x2,y2)-(x l ,y l )||+w2[|(x2+x l )|+|(y2+y l )|],…,
[0160] w1||(x k ,y k )-(x l ,y l )||+w2[|(x k +x l )|+|(yk +y l )|],…,
[0161] w1||(x n ,y n )-(x l ,y l )||+w2[|(x n +x l )|+|(y n +y l )|]},
[0162] C l,r,k (x,y)=1,1≤k≤n
[0163] In the above formula, P l is a paired end point of the end point (x l ,y l ), and the coordinate value is (x l-p ,y l-p ), w1 and w2 are weight coefficients, and satisfy the condition w1+w2=1.
[0164] The paired pixel points (x l ,y l ) and (x l-p ,y l-p ) are connected, and the complete edge line E'(x,y) is obtained.
[0165] Step S6, the gray-scale image f(x,y) is binarized to obtain a binary image f 0-1 (x,y), wherein the binarization method adopts a local adaptive threshold segmentation method. The binarized image f 0-1 (x,y) is segmented by the completed edge line E'(x,y) to obtain a target image f0' -1 (x,y), and the segmentation formula is as follows:
[0166]
[0167] In the formula, f0' -1 (x,y) is the target binary image after segmentation.
[0168] In this example, the stone image shown in Fig. Figure 2 is taken as the detection object, and the stone particles in the image are segmented.
[0169] By using the above operation steps, the stone image is first converted into a gray-scale image, and then after image filtering, image enhancement and other operations, the effect is as shown in Fig. Figure 3 .
[0170] According to the algorithm implementation principle, a larger edge detection parameter is set, which is 0.1 in the embodiment, and the Roberts differential operator is used to detect the particle edge line in the stone image, and the detection effect is as shown in Figure 4 .
[0171] The edge line endpoint detection is performed on the basis of Figure 4 , and the detection result is as shown in Figure 5 .
[0172] According to the endpoint detection in Figure 5 , the endpoints are paired and connected, and the result is as shown in Figure 6 .
[0173] The edge detection result obtained in Figure 6 is marked in the original image, and the obtained result is as shown in Figure 7 .
[0174] The stone binary image is segmented by using the above edge line, and the segmentation effect is as shown in Figure 8 , wherein Figure 8 a) is the stone particle binary image obtained after processing by the method provided in the application; Figure 8 b) is the binary image segmentation effect obtained after processing by the method provided in the application.
[0175] As can be seen from the comparison of Figure 8 a)~b), in the stone particle segmentation effect diagram of the binary image edge line obtained by the method provided in the application, the edge contour of the stone particle is clear and accurate, and the segmentation effect is obviously better than Figure 8 a) the binary segmentation result based on gray scale.
[0176] Although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacements to part of the technical features, and any modification, equivalent replacement, improvement, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.
Claims
1. A stone edge image segmentation method for a stone image, characterized by, The method comprises the following steps: Step S1: grayscale processing is performed on the color stone image to obtain a grayscale image f(x, y), and the grayscale image f(x, y) is converted into a two-dimensional discrete matrix f(x, y); Step S2: an edge detection result E(x, y) is obtained by performing edge detection on the grayscale image f(x, y) by using a Roberts differential operator; Step S3: endpoint detection is performed on each edge line detection result E(x, y), and an endpoint detection result C(x, y) is obtained by extracting endpoints of each edge line; The endpoint detection in step S3 comprises the following steps: Step S31: all pixel points with a value of 1 in the edge detection result E(x, y) are divided into three categories, i.e., isolated points, edge line endpoints and edge line internal points; Step S32: pixel points in the color image are divided into corner pixel points located at four corners of the image, edge pixel points located on four edge lines of the image and internal pixel points located in the interior of the image according to spatial positions of the pixel points, wherein the corner pixel points are adjacent to three pixel points, the edge pixel points are adjacent to five pixel points, and the internal pixel points are adjacent to eight pixel points; Step S33: all pixel points with a value of 1 in the edge detection result E(x, y) are judged as follows: if values of all pixel points adjacent to a target pixel point are 0, the target pixel point is an isolated point; if only one pixel point among the pixel points adjacent to the target pixel point has a value of 1, the target pixel point is an edge line endpoint; if the number of pixel points with a value of 1 among the pixel points adjacent to the target pixel point is greater than or equal to 2, the target pixel point is an edge line internal point, and a judgment result of each pixel point is outputted; Step S34: the judgment result of the edge pixel point is C(x, y), if the edge pixel point is an isolated point, a pixel value of the edge pixel point is set to 1, if the edge pixel point is an endpoint, the pixel value of the edge pixel point is set to 2, otherwise, the pixel value of the edge pixel point is set to 3, and the setting is represented as follows: Step S4: a direction D of extension of each endpoint in the endpoint detection result C(x, y) is calculated, a pairing result P is calculated according to the direction D of extension of each endpoint and a geometric distance between the endpoints, and a missing part of the edge line is connected and completed according to the pairing result P, so that a complete edge line E'(x, y) is obtained; The two-dimensional discrete matrix in step S1 is calculated according to the following formula: In the above formula, C(x, y) is a pixel point type marking result, e(x i ,y j ) is a neighboring pixel point of the pixel point (x i ,y j ), and the value of the pixel point number m is 3 or 5 or 8; The Roberts differential operator method in step S2 comprises the following steps: Step S5: the gray-scale image f(x, y) is binarized by using a local adaptive threshold segmentation method to obtain a binary image f 0-1 (x, y), and the obtained binary image f 0-1 (x, y) is segmented by using a complete edge line E'(x, y) to obtain a target image f' 0-1 (x, y).
2. The stone edge image segmentation method for stone images according to claim 1, characterized in that, Δf = (f(x, y)-f(x-1, y), f(x, y)-f(x, y-1)) f(x,y) = 0.2989 x f R + 0.5870 x f G + 0.1140 x f B where f R , f G , and f B represent the red, green, and blue components, respectively, of the color stone image f(R,G,B).
3. The stone edge image segmentation method for stone images according to claim 1, characterized in that, Step S22: the Roberts differential operator is composed of the following two templates: Step S21: Set the discrete gray image as f(x, y), wherein (x i ,y j ) represents the coordinates of the i-th row and j-th column pixel point in the discrete gray image matrix, and f(x i ,y j ) represents the gray value of the corresponding pixel point. When the image edge is detected, the vertical difference and the horizontal difference of the image are used to approximate the gradient operator, that is: Wherein, the edge detection result E(x, y) is a binary image, a value of 1 in the image matrix represents an edge line, and a value of 0 represents a non-edge line, and V is a threshold scalar artificially set. Roberts differential operator calculates the gradient Δf(x i ,y j ) of each pixel point when calculating Δf, and then takes the absolute value of the result: The edge line direction calculation in step S4 comprises the following steps: The threshold operation is performed on the gradient Af(x i ,y j ) of each pixel point to obtain an edge detection result E(x,y). Assuming that the threshold value is V, the edge detection result E(x i ,y i ) can be calculated by the following formula: The complete edge line obtained in step S4 comprises the following steps:
4. The stone edge image segmentation method for stone images according to claim 1, characterized in that, Step S42: endpoints originally connected together in the actual edge line of the stone are found out, and the obtained endpoints are connected, and the connecting specifically comprises the following steps: For pixels with a value of 2 in the endpoint detection result C(x,y) (these pixels are edge endpoints), let the endpoint be (x,y) l ,y l The edge pixels connected by (x) are (x) l-nect ,y l-nect ), calculate the edge line at (x) using the following formula. l ,y l The direction of extension at point: D l = (x l ,y l ) - (x l-nect ,y l-nect ), 1≤l≤N where D l represents the direction of the extension of the edge line at the endpoint (x l ,y l ), l is the endpoint number, and N is the number of endpoints.
5. The stone edge image segmentation method for stone images according to claim 4, characterized in that, It comprises: The extension direction of the edge line at the point (x l ,y l ) is D l , and all end points C l,r,n (x,y) falling within a circle with (x l ,y l ) as the center and a set value r as the radius are found, and n is the number of end points falling within the circle, and the specific calculation formula is as follows: Then select the pair of end points (x l,r,n ,y l ) from (x l ,y l-p ) in C l-p , when pairing the end points of (x l ,y l ), select the point with the smallest distance between the two points according to the distance and the measuring direction, and select the two end points with opposite measuring directions for pairing, as shown in the following formula: P l = min{wl || (xl,yl) - (x l ,y l )|| + w2 [|(xl+x l )| + |(yl+y l )|], w1 || (x2, y2) - (x l , y l ) + w2 [ | (x2 + x l ) | + | (y2 + y l ) | ],..., w1 || (x k ,y k ) - (x l ,y l ) + w2 [ (x k +x l ) + (y k +y l ) ],..., w1 || (x n ,y n )-(x l ,y l )|| + w2 [ | (x n +x l )|+ | (y n +y l )|]}, C l,r,k (x,y) = 1,1 < k < n wherein P l is a pair of end points of the end point (x l ,y l ), and has coordinate values (x l-p ,y l-p ), w1 and w2 are weight coefficients, and satisfy the condition w1+w2=1; Step S43: connecting the paired pixel points (x l ,y l ) and (x l-p ,y l-p ), to obtain the complete edge line E'(x,y).
6. The stone edge image segmentation method for stone images according to claim 1, characterized in that, In step S5, the gray-scale image f(x, y) is locally self-adaptively threshold segmented to obtain a binary image f 0-1 (x, y): In the formula, f′ 0-1 (x, y) is the target binary image after segmentation.
7. The stone edge image segmentation apparatus for a stone image according to any one of claims 1 to 6, characterized by A conversion module is configured to convert a color stone image into a gray image f(x, y) and a two-dimensional discrete matrix f(x, y); An edge detection module is configured to perform edge detection on the gray image f(x, y) by using a Roberts differential operator to obtain an edge detection result E(x, y); An endpoint detection module is configured to perform endpoint detection on each edge line detection result E(x, y) to extract endpoints of each edge line to obtain an endpoint detection result C(x, y); The endpoint detection in step S3 includes the following steps: Step S31: all pixel points with a value of 1 in the edge detection result E(x, y) are divided into three categories, i.e., isolated points, edge line endpoints and edge line internal points; Step S32: pixel points in a color image are divided into corner pixel points located at four corners of the image, edge pixel points located on four edge lines of the image and internal pixel points located in the interior of the image according to their spatial positions, wherein the corner pixel points are adjacent to three pixel points, the edge pixel points are adjacent to five pixel points, and the internal pixel points are adjacent to eight pixel points; Step S33: all pixel points with a value of 1 in the edge detection result E(x, y) are judged as follows: if values of all pixel points adjacent to a target pixel point are 0, the target pixel point is an isolated point; if only one pixel point among the pixel points adjacent to the target pixel point has a value of 1, the target pixel point is an edge line endpoint; if the number of pixel points with a value of 1 among the pixel points adjacent to the target pixel point is greater than or equal to 2, the target pixel point is an edge line internal point, and a judgment result of each pixel point is outputted; Step S34: assuming that the edge pixel point judgment result is C(x, y), if the edge pixel point is an isolated point, a pixel value of the edge pixel point is set to 1, if the edge pixel point is an endpoint, the pixel value of the edge pixel point is set to 2, otherwise, the pixel value of the edge pixel point is set to 3, and the setting is represented as follows: In the above formula, C(x, y) is a pixel point type label result, e(x i ,y j ) is a neighboring pixel point of the pixel point (x i ,y j ), and the value of the pixel point number m is 3 or 5 or 8. An edge completion module is configured to measure an extension direction D of each endpoint in the endpoint detection result C(x, y), calculate a pairing result P according to the extension direction D of each endpoint and a geometric distance between the endpoints, and connect and complete a missing part of an edge line according to the pairing result P to obtain a complete edge line E'(x, y); A binarization module is configured to binarize the gray-scale image f(x, y) to obtain a binary image f 0-1 (x, y) using a local adaptive threshold segmentation method, and segment the obtained binary image f 0-1 (x, y) using the complete edge line E'(x, y) to obtain a target image f' 0-1 (x, y).
Citation Information
Patent Citations
Distribution uniformity assessment method based on watershed algorithm and minimum spanning tree
CN104282026A
Infrared thermal image-based external wall external thermal insulation system defect identification and damage degree evaluation method
CN112669286A