A TBM image slagging segmentation method based on machine vision
By employing a machine vision-based image segmentation method, median filtering, optimal threshold segmentation, eight-neighbor scanning, and the Douglas-Peucker algorithm are used to handle mild adhesion, while skeleton analysis and multi-scale watershed transformation are combined to handle severe adhesion. This approach solves the problem of dense stacking and adhesion of rock debris in TBM slag discharge, achieving accuracy and adaptability in rock debris segmentation.
Patent Information
- Application Number
- CN202611213433.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-11
- Publication Date
- 2026-11-27
AI Technical Summary
Existing technologies for processing TBM slag have problems with dense stacking and adhesion of rock slag, which leads to inaccurate rock slag segmentation and affects the accuracy of particle size statistics and surrounding rock identification.
A machine vision-based image segmentation method is adopted. Binarized images are generated by median filtering and optimal threshold segmentation. The eight-neighbor scanning method and Douglas-Peucker algorithm are combined to handle mild adhesion, and skeleton analysis and multi-scale watershed transformation are used to handle severe adhesion, thus achieving lossless segmentation.
It effectively separates adhering rock debris, ensuring the accuracy of rock debris size statistics and the reliability of segmentation results, adapting to the segmentation needs of rock debris with different degrees of adhesion, and improving the accuracy of TBM slag discharge monitoring.
Smart Images

Figure CN123181479A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image analysis technology, specifically to a machine vision-based method for slag segmentation of TBM images. Background Technology
[0002] During tunnel boring machine construction, the rock debris produced by the disc cutter cutting the rock strata is continuously transported out by belt conveyor. Information such as the particle size distribution, shape characteristics and amount of rock debris are important basis for judging the surrounding rock conditions at the tunnel face, assessing the wear of the cutterhead and tunneling efficiency. Traditional muck analysis relies on manual sampling and screening, which has defects such as low efficiency, large lag and insufficient sample representativeness. In recent years, image segmentation technology based on machine vision has been gradually introduced into the field of TBM slag monitoring. The aim is to automatically segment each rock slag target by acquiring images of rock slag on the conveyor belt using industrial cameras and image processing algorithms, and then statistically analyze its particle size and morphological parameters. Existing segmentation methods mainly fall into three categories: First, methods based on threshold segmentation and morphological processing. After obtaining binary images using the Otsu method, operations such as erosion and opening are used to separate adhered targets. However, these operations alter the actual size of the rock slag, leading to distorted statistical results. Second, methods based on watershed transformation. Distance transformation is used to generate markers for segmentation, but the segmentation effect is poor for severely overlapping targets. Third, adhesion separation methods based on concave point detection. Contour concave points are extracted and matched to generate segmentation lines. However, when rock slag overlaps over a large area, the contour features at the adhesion points are not obvious, concave points are difficult to detect effectively, and the segmentation line positioning deviation is large. The methods mentioned above all face the problem of densely stacked and mutually adhered rock debris on the conveyor belt, with a huge size range. Existing algorithms are prone to undersegmentation when dealing with severe adhesion—misidentifying multiple rock debris as a single target, which seriously restricts the accuracy of subsequent particle size statistics and surrounding rock identification. Therefore, there is an urgent need for a rock debris segmentation method that can adaptively process different degrees of adhesion without changing the target size. Summary of the Invention
[0003] The purpose of this invention is to provide a machine vision-based method for slag segmentation of TBM images, in order to solve the problems mentioned in the background art.
[0004] To achieve the above objectives, the present invention provides the following technical solution: a TBM image slag segmentation method based on machine vision, comprising the following steps: S1. After acquiring the color image of the rock debris, convert it to grayscale, perform a series of operations such as median filtering to remove noise and enhancing contrast, solve for the optimal threshold, and use the optimal threshold to generate a binary image to separate the rock debris from the background. S2. The connected components in the binary image are marked by the eight-neighbor double-scan method. After equivalent merging and unified numbering, the sequence of outer contour points of each connected component is extracted. The sequence of circumscribed convex hull vertices is analyzed from the outer contour points, and the ratio of the area of the circumscribed convex hull to the area of the contour is calculated. If the ratio is not less than the threshold, it is judged as mild adhesion; otherwise, it is severe adhesion. S3. Receive connected regions that are determined to be slightly adhered, use the Douglas-Peucker approximation of the outer contour, and filter out candidate concave points. Match them by distance, and use the shortest effective match to generate a dividing line as the boundary path of the rock debris. Separate the adhered rock debris into independent sub-connected regions according to the boundary path. S4. Receive the binary image of the connected region determined to be heavily adhered, perform morphological refinement on the connected region to extract the skeleton, analyze the branch points and ends of the skeleton to identify the boundary direction of each rock fragment in the overlapping area, use the skeleton ends as foreground seeds and the branch points as segmentation ridges, and adaptively adjust the labeling range according to the size of the connected region to generate a multi-scale labeled image. Use this labeled image to guide the watershed transform to perform region growth on the gradient map to achieve non-destructive segmentation of the adhered rock fragment. S5. Statistically analyze all independent rock debris regions generated after segmentation, remove noise from fragments with too small an area, calculate the size parameters of the effective rock debris and output them.
[0005] Preferably, step S1 specifically includes the following steps: S101. After acquiring the original color image of rock slag using an industrial camera, convert it into a grayscale image using a weighted average method. Use a 3×3 window mid-range filter to remove noise. Take a 3×3 neighborhood centered on each pixel in the grayscale image, sort the grayscale values of the 9 pixels in the neighborhood, and take the median as the new value of the current pixel. Traverse the entire image to eliminate noise. S102. Divide the grayscale image into 8×8 sub-blocks, calculate the grayscale histogram for each block, set the cropping threshold to 2% of the total number of pixels in the sub-block, crop the portion exceeding the threshold and redistribute it evenly to each grayscale level, perform cumulative distribution function mapping on the cropped histogram, and process the sub-block boundary pixels using bilinear interpolation. S103. Traverse the gray levels from 0 to 255 to determine multiple candidate thresholds. Use each candidate threshold to divide the pixels into background and target. Calculate the inter-class variance corresponding to the current candidate threshold. Take the candidate threshold with the largest variance as the optimal threshold. Use the optimal threshold to compare pixel by pixel. If the gray value is greater than the optimal threshold, directly assign its gray value to 255. Otherwise, assign its gray value to 0, thereby outputting a binarized image.
[0006] Preferably, step S2 specifically includes the following steps: S201. Traverse the entire binarized image and use a two-pass scanning method for labeling. In the first pass, scan each pixel from left to right and from top to bottom. If the current pixel is 255, check the label values of its two neighboring pixels to the left and above. If neither of them is labeled, assign a new label to the current pixel. If only one of them is labeled, assign that label to the current pixel. If both of them are different labels, assign one of the labels to the current pixel and record the equivalence relationship between the two. In the second pass, unify the equivalent labels to the same number. S202. After the marking is completed, for each connected component corresponding to the label, the Suzuki contour tracing algorithm is used to extract its outer contour. That is, starting from the starting point on the boundary of the connected component, the algorithm traces clockwise along the boundary until it returns to the starting point, and records the coordinate sequence of all boundary points. This sequence is the outer contour of the connected component. S203. Determine the set of contour points according to the outer contour of each connected component. Find the point with the smallest ordinate in the set of contour points as the reference point. If there are multiple points, take the one with the smallest abscissa. Sort the remaining points according to the polar angle relative to the reference point. Maintain a stack structure. Push the sorted points into the stack in turn and check the turning direction formed by the top three points of the stack. If it is not a left turn, pop the middle point of the top of the stack. Finally, all the remaining points in the stack are used as convex hull vertices to generate the corresponding sequence. S204. Calculate the area of the polygon enclosed by the sequence of convex hull vertices, use it as the area of the circumscribed convex hull, integrate the contour point sequence to analyze the actual area of the connected region, and use the area of the circumscribed convex hull and the actual area to calculate the convex hull ratio. S205. Compare the convex hull ratio with a preset threshold. If the convex hull ratio is greater than or equal to the preset threshold, it is determined to be slightly adhered; otherwise, it is determined to be heavily adhered. After the classification is completed, the slightly adhered connected components and the heavily adhered connected components enter their respective splitting branches.
[0007] Preferably, step S3 specifically includes the following steps: S301. Receive the connected components determined to be slightly adhered, and take their outer contour point sequence. For any point in the sequence... , and the front and back Each point serves as a local neighborhood, i.e., the previous point. and back point Calculate vector with vector The included angle ,in , , , Indicates the sequence number, As a point Steering angle and curvature value at the location Defined as the supplementary angle of the steering angle, where ; S302. The Douglas-Peucker algorithm is used to approximate the contour into a polygon, retaining the main inflection points of the contour. Curvature is calculated only at the vertices of the approximate polygon, and all points with curvature values less than the preset concave point threshold are marked as candidate concave points. S303. For each candidate concave point, calculate its spatial distance from other concave points. After taking the two closest concave points as candidate pairing objects, check whether the line connecting the concave point and the candidate concave point is completely inside the connected domain. If the line is inside the connected domain, it is a valid dividing line; otherwise, it is not a valid dividing line.
[0008] Preferably, step S3 further includes the following steps: S304. Statistically analyze all pairs of concave points whose lines are located within the connected domain, select the pair with the shortest line length as the optimal match, connect the pair of concave points to generate a dividing line, and this dividing line is the boundary path between two adhering rock fragments. S305. Count the pixels traversed by the boundary path and change their pixel values from 255 to 0 in the binarized image. S306. After completion, the original connected domain is divided into two independent sub-connected domains, each representing two independent rock debris targets. If there are multiple pairs of matching concave points in a connected domain, the same operation is repeated to cut multiple times until all valid concave point pairs are processed. All the cut sub-connected domains are then output as independent rock debris.
[0009] Preferably, step S4 specifically includes the following steps: S401. Receive the binary image of the connected component that is determined to be heavily connected, delete the pixels that meet the specific conditions on the boundary of the connected component one by one, and use the binary image composed of all the remaining pixels as the skeleton graph of the connected component. S402. Scan the entire skeleton image and count the number of other skeleton pixels in the neighborhood of each skeleton pixel. Classify each pixel into endpoints, branch points, and ordinary points. Starting from each branch point, trace along the skeleton branch to the endpoint or other branch points. Record the path length and direction vector of each branch. When the path length is less than the preset length threshold, the branch is regarded as a noise branch and removed from the skeleton structure. S403. Calculate the coordinate position of each endpoint in the skeleton diagram, generate a circular area with it as the center, assign the value 1 to all pixels in the circular area as the foreground marker, representing the seed area of each independent rock debris. S404. For the coordinate position corresponding to each branch point, assign the value 2 to the pixel where it is located as a dividing line marker, representing the boundary constraint between different rock fragments, and use differentiated marking scales for connected regions of different sizes.
[0010] Preferably, step S4 further includes the following steps: S405. Draw a circular foreground marking region with each endpoint as the center and the marking scale as the radius. Draw a segmentation marking region with each branch point as the center and one-third of the marking scale as the radius. Finally, a multi-scale marking image is generated. S406. Calculate the gradient magnitude using the original grayscale image to obtain a gradient image. Regions in the gradient image with gradient values higher than a preset value correspond to the edge positions of the rock debris. Use the multi-scale labeled image as the initial seed for watershed transformation. Perform label-based watershed transformation on the gradient image. Use pixels with a value of 1 in the labeled image as seed points for forced minimum values and pixels with a value of 2 as constraint points for watershed ridges. Start from various sub-points and perform region growth on the gradient image. Regions grown from different seed points meet at the gradient ridge and stop expanding. Determine the boundaries of each region and use them as the segmentation result. S407. Use watershed transformation to divide the heavily cohesive connected domain into multiple independent regions, and output each independent region as a rock debris target.
[0011] Preferably, step S5 specifically includes the following steps: S501. Count all independent rock debris regions, calculate the pixel area of each region, compare the pixel area with the preset minimum area threshold, if the pixel area is less than the preset minimum area threshold, then determine that the region is a fragment generated by over-segmentation and remove it from the segmentation result. S502. After completing the area screening, calculate the size parameters for each retained effective rock debris area, and output the effective rock debris area and its size parameters through a visual interface.
[0012] Compared with the prior art, the beneficial effects of the present invention are: This invention classifies the degree of adhesion by convex hull ratio. Mild adhesion is cut using concave point matching, while severe adhesion is segmented using skeleton analysis and multi-scale watershed segmentation. This avoids misidentifying multiple adhered rock fragments as a single target. The watershed marker scale is adaptively calculated based on the area of the connected domain, allowing the segmentation parameters to be dynamically adjusted according to the size of the rock fragments. This invention can effectively segment the adhesion of large rock fragments as well as accurately separate the adhesion of fine rock fragments, and has good applicability to actual working conditions where the size range of rock fragments in TBM slag discharge is extremely large. Attached Figure Description
[0013] Figure 1 An overall method flowchart is provided for embodiments of the present invention. Detailed Implementation
[0014] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0015] Example 1: Please see Figure 1 This invention provides a technical solution: a machine vision-based method for segmenting slag from TBM images, comprising the following steps: S1. After acquiring the color image of the rock debris, convert it to grayscale, perform a series of operations such as median filtering to remove noise and enhancing contrast, solve for the optimal threshold, and use the optimal threshold to generate a binary image to separate the rock debris from the background. S2. The connected components in the binary image are marked by the eight-neighbor double-scan method. After equivalent merging and unified numbering, the sequence of outer contour points of each connected component is extracted. The sequence of circumscribed convex hull vertices is analyzed from the outer contour points, and the ratio of the area of the circumscribed convex hull to the area of the contour is calculated. If the ratio is not less than the threshold, it is judged as mild adhesion; otherwise, it is severe adhesion. S3. Receive connected regions that are determined to be slightly adhered, use the Douglas-Peucker approximation of the outer contour, and filter out candidate concave points. Match them by distance, and use the shortest effective match to generate a dividing line as the boundary path of the rock debris. Separate the adhered rock debris into independent sub-connected regions according to the boundary path. S4. Receive the binary image of the connected region determined to be heavily adhered, perform morphological refinement on the connected region to extract the skeleton, analyze the branch points and ends of the skeleton to identify the boundary direction of each rock fragment in the overlapping area, use the skeleton ends as foreground seeds and the branch points as segmentation ridges, and adaptively adjust the labeling range according to the size of the connected region to generate a multi-scale labeled image. Use this labeled image to guide the watershed transform to perform region growth on the gradient map to achieve non-destructive segmentation of the adhered rock fragment. S5. Statistically analyze all independent rock debris regions generated after segmentation, remove noise from fragments with too small an area, calculate the size parameters of the effective rock debris and output them.
[0016] S1 specifically includes the following steps: S101. After acquiring the original color image of rock slag using an industrial camera, convert it into a grayscale image using a weighted average method. Use a 3×3 window mid-range filter to remove noise. Take a 3×3 neighborhood centered on each pixel in the grayscale image, sort the grayscale values of the 9 pixels in the neighborhood, and take the median as the new value of the current pixel. Traverse the entire image to eliminate noise. S102. Divide the grayscale image into 8×8 sub-blocks, calculate the grayscale histogram for each block, set the cropping threshold to 2% of the total number of pixels in the sub-block, crop the portion exceeding the threshold and redistribute it evenly to each grayscale level, perform cumulative distribution function mapping on the cropped histogram, and process the sub-block boundary pixels using bilinear interpolation. S103. Traverse the gray levels from 0 to 255 to determine multiple candidate thresholds. Use each candidate threshold to divide the pixel into background and target. Calculate the inter-class variance corresponding to the current candidate threshold. Take the candidate threshold with the largest variance as the optimal threshold. Use the optimal threshold to compare pixel by pixel. If the gray value is greater than the optimal threshold, directly assign its gray value to 255. Otherwise, assign its gray value to 0, thereby outputting a binarized image. S2 specifically includes the following steps: S201. Traverse the entire binarized image and use a two-pass scanning method for labeling. In the first pass, scan each pixel from left to right and from top to bottom. If the current pixel is 255, check the label values of its two neighboring pixels to the left and above. If neither of them is labeled, assign a new label to the current pixel. If only one of them is labeled, assign that label to the current pixel. If both of them are different labels, assign one of the labels to the current pixel and record the equivalence relationship between the two. In the second pass, unify the equivalent labels to the same number. S202. After the marking is completed, for each connected component corresponding to the label, the Suzuki contour tracing algorithm is used to extract its outer contour. That is, starting from the starting point on the boundary of the connected component, the algorithm traces clockwise along the boundary until it returns to the starting point, and records the coordinate sequence of all boundary points. This sequence is the outer contour of the connected component. S203. Determine the set of contour points according to the outer contour of each connected component. Find the point with the smallest ordinate in the set of contour points as the reference point. If there are multiple points, take the one with the smallest abscissa. Sort the remaining points according to the polar angle relative to the reference point. Maintain a stack structure. Push the sorted points into the stack in turn and check the turning direction formed by the top three points of the stack. If it is not a left turn, pop the middle point of the top of the stack. Finally, all the remaining points in the stack are used as convex hull vertices to generate the corresponding sequence. S204. Calculate the area of the polygon enclosed by the sequence of convex hull vertices, use it as the area of the circumscribed convex hull, integrate the contour point sequence to analyze the actual area of the connected region, and use the area of the circumscribed convex hull and the actual area to calculate the convex hull ratio. S205. Compare the convex hull ratio with a preset threshold. If the convex hull ratio is greater than or equal to the preset threshold, it indicates that the shape of the connected region is close to convex and there is no serious internal depression. It is judged as slightly adherent. Otherwise, it indicates that the connected region has a large area of depression and is judged as heavily adherent. After the classification is completed, the slightly adherent connected regions and the heavily adherent connected regions enter their respective splitting branches. S3 specifically includes the following steps: S301. Receive the connected components determined to be slightly adhered, and take their outer contour point sequence. For any point in the sequence... , and the front and back Each point serves as a local neighborhood, i.e., the previous point. and back point Calculate vector with vector The included angle ,in , , , Indicates the sequence number, As a point Steering angle and curvature value at the location Defined as the supplementary angle of the steering angle, where ; S302. The Douglas-Peucker algorithm is used to approximate the contour into a polygon, retaining the main inflection points of the contour. Curvature is calculated only at the vertices of the approximate polygon, and all points with curvature values less than the preset concave point threshold are marked as candidate concave points. S303. For each candidate concave point, calculate its spatial distance from other concave points. After taking the two closest concave points as candidate pairing objects, check whether the line connecting the concave point and the candidate concave point is completely inside the connected domain. If the line is inside the connected domain, it is a valid dividing line; otherwise, it is not a valid dividing line. S3 also includes the following steps: S304. Statistically analyze all pairs of concave points whose lines are located within the connected domain, select the pair with the shortest line length as the optimal match, connect the pair of concave points to generate a dividing line, and this dividing line is the boundary path between two adhering rock fragments. S305. Statistically determine the pixels along the boundary path and change their pixel values from 255 to 0 in the binarized image. This removes them from the white target area, cutting off the originally connected rock debris area along the dividing line, thereby achieving the separation of the adhering rock debris. S306. After completion, the original connected domain is divided into two independent sub-connected domains, representing two independent rock debris targets respectively. If there are multiple pairs of matching concave points in a connected domain, the same operation is repeated to cut multiple times until all valid concave point pairs are processed. All the cut sub-connected domains are output as independent rock debris. S4 specifically includes the following steps: S401. Receive the binary image of the connected component determined to be heavily connected, and delete pixels on the boundary of the connected component that meet specific conditions. Specifically, for a boundary pixel, check the distribution pattern of the surrounding pixels in its 3×3 neighborhood. If the deletion of the pixel will not destroy the topological connectivity of the connected component and will not shorten the end of the skeleton branch, then the pixel is removed from the target region. The deletion process is iterated. In each round, all boundary pixels of the current connected component are traversed, and all pixels that meet the deletion conditions are marked. After the end of this round of traversal, all marked pixels are removed from the target region, and then the next round of iteration begins. When no pixels are marked for deletion in a certain round of traversal, the iteration terminates, and the binary image composed of all remaining pixels is used as the skeleton graph of the connected component. S402. Scan the entire skeleton image and count the number of other skeleton pixels in the neighborhood of each skeleton pixel. Classify each pixel into endpoints, branch points, and ordinary points. An endpoint is a point with only one skeleton pixel in its neighborhood, a branch point is a point with three or four skeleton pixels in its neighborhood, and an ordinary point is a point with two skeleton pixels in its neighborhood. Starting from each branch point, trace along the skeleton branch to the endpoint or other branch points. Record the path length and direction vector of each branch. When the path length is less than a preset length threshold, the branch is regarded as a noise branch and removed from the skeleton structure. S403. Calculate the coordinate position of each endpoint in the skeleton diagram, generate a circular area with it as the center, assign the value 1 to all pixels in the circular area as the foreground marker, representing the seed area of each independent rock debris. S404. For the coordinates of each branch point, assign a value of 2 to its corresponding pixel as a dividing line marker, representing the boundary constraint between different rock fragments. Different marking scales are used for connected regions of different sizes. Let the area of the current connected region be... Then the scale of the marking according to Calculation, where Represents the scaling factor. This represents the characteristic radius of the connected component; S4 also includes the following steps: S405. Draw a circular foreground marking region with each endpoint as the center and the marking scale as the radius. Draw a segmentation marking region with each branch point as the center and one-third of the marking scale as the radius. Finally, a multi-scale marking image is generated. S406. Calculate the gradient magnitude using the original grayscale image to obtain a gradient image. Regions in the gradient image with gradient values higher than a preset value correspond to the edge positions of the rock debris. Use the multi-scale labeled image as the initial seed for watershed transformation. Perform label-based watershed transformation on the gradient image. Use pixels with a value of 1 in the labeled image as seed points for forced minimum values and pixels with a value of 2 as constraint points for watershed ridges. Start from various sub-points and perform region growth on the gradient image. Regions grown from different seed points meet at the gradient ridge and stop expanding. Determine the boundaries of each region and use them as the segmentation result. S407. Use watershed transformation to divide the heavily cohesive connected domain into multiple independent regions, and output each independent region as a rock debris target. S5 specifically includes the following steps: S501. Count all independent rock debris regions, calculate the pixel area of each region, compare the pixel area with the preset minimum area threshold, if the pixel area is less than the preset minimum area threshold, then determine that the region is a fragment generated by over-segmentation and remove it from the segmentation result. S502. After completing the area screening, calculate the size parameters for each retained effective rock debris area, and output the effective rock debris area and its size parameters through a visual interface.
[0017] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus.
[0018] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.
Claims
1. A machine vision-based method for segmenting slag discharge from TBM images, characterized in that, The method includes the following steps: S1. After acquiring the color image of the rock debris, convert it to grayscale, perform a series of operations such as median filtering to remove noise and enhancing contrast, solve for the optimal threshold, and use the optimal threshold to generate a binary image to separate the rock debris from the background. S2. The connected components in the binary image are marked by the eight-neighbor double-scan method. After equivalent merging and unified numbering, the sequence of outer contour points of each connected component is extracted. The sequence of circumscribed convex hull vertices is analyzed from the outer contour points, and the ratio of the area of the circumscribed convex hull to the area of the contour is calculated. If the ratio is not less than the threshold, it is judged as mild adhesion; otherwise, it is severe adhesion. S3. Receive connected regions that are determined to be slightly adhered, use the Douglas-Peucker approximation of the outer contour, and filter out candidate concave points. Match them by distance, and use the shortest effective match to generate a dividing line as the boundary path of the rock debris. Separate the adhered rock debris into independent sub-connected regions according to the boundary path. S4. Receive the binary image of the connected region determined to be heavily adhered, perform morphological refinement on the connected region to extract the skeleton, analyze the branch points and ends of the skeleton to identify the boundary direction of each rock fragment in the overlapping area, use the skeleton ends as foreground seeds and the branch points as segmentation ridges, and adaptively adjust the labeling range according to the size of the connected region to generate a multi-scale labeled image. Use this labeled image to guide the watershed transform to perform region growth on the gradient map to achieve non-destructive segmentation of the adhered rock fragment. S5. Statistically analyze all independent rock debris regions generated after segmentation, remove noise from fragments with too small an area, calculate the size parameters of the effective rock debris and output them.
2. The TBM image slag segmentation method based on machine vision according to claim 1, characterized in that, S1 specifically includes the following steps: S101. After acquiring the original color image of rock slag using an industrial camera, convert it into a grayscale image using a weighted average method. Use a 3×3 window mid-range filter to remove noise. Take a 3×3 neighborhood centered on each pixel in the grayscale image, sort the grayscale values of the 9 pixels in the neighborhood, and take the median as the new value of the current pixel. Traverse the entire image to eliminate noise. S102. Divide the grayscale image into 8×8 sub-blocks, calculate the grayscale histogram for each block, set the cropping threshold to 2% of the total number of pixels in the sub-block, crop the portion exceeding the threshold and redistribute it evenly to each grayscale level, perform cumulative distribution function mapping on the cropped histogram, and process the sub-block boundary pixels using bilinear interpolation. S103. Traverse the gray levels from 0 to 255 to determine multiple candidate thresholds. Use each candidate threshold to divide the pixels into background and target. Calculate the inter-class variance corresponding to the current candidate threshold. Take the candidate threshold with the largest variance as the optimal threshold. Use the optimal threshold to compare pixel by pixel. If the gray value is greater than the optimal threshold, directly assign its gray value to 255. Otherwise, assign its gray value to 0, thereby outputting a binarized image.
3. The TBM image slag segmentation method based on machine vision according to claim 1, characterized in that, S2 specifically includes the following steps: S201. Traverse the entire binarized image and use a two-pass scanning method for labeling. In the first pass, scan each pixel from left to right and from top to bottom. If the current pixel is 255, check the label values of its two neighboring pixels to the left and above. If neither of them is labeled, assign a new label to the current pixel. If only one of them is labeled, assign that label to the current pixel. If both of them are different labels, assign one of the labels to the current pixel and record the equivalence relationship between the two. In the second pass, unify the equivalent labels to the same number. S202. After the marking is completed, for each connected component corresponding to the label, the Suzuki contour tracing algorithm is used to extract its outer contour. That is, starting from the starting point on the boundary of the connected component, the algorithm traces clockwise along the boundary until it returns to the starting point, and records the coordinate sequence of all boundary points. This sequence is the outer contour of the connected component. S203. Determine the set of contour points according to the outer contour of each connected component. Find the point with the smallest ordinate in the set of contour points as the reference point. If there are multiple points, take the one with the smallest abscissa. Sort the remaining points according to the polar angle relative to the reference point. Maintain a stack structure. Push the sorted points into the stack in turn and check the turning direction formed by the top three points of the stack. If it is not a left turn, pop the middle point of the top of the stack. Finally, all the remaining points in the stack are used as convex hull vertices to generate the corresponding sequence. S204. Calculate the area of the polygon enclosed by the sequence of convex hull vertices, use it as the area of the circumscribed convex hull, integrate the contour point sequence to analyze the actual area of the connected region, and use the area of the circumscribed convex hull and the actual area to calculate the convex hull ratio. S205. Compare the convex hull ratio with a preset threshold. If the convex hull ratio is greater than or equal to the preset threshold, it is determined to be slightly adhered; otherwise, it is determined to be heavily adhered. After the classification is completed, the slightly adhered connected components and the heavily adhered connected components enter their respective splitting branches.
4. The TBM image slag segmentation method based on machine vision according to claim 1, characterized in that, S3 specifically includes the following steps: S301. Receive the connected components determined to be slightly adhered, and take their outer contour point sequence. For any point in the sequence... , and the front and back Each point serves as a local neighborhood, i.e., the previous point. and back point Calculate vector with vector The included angle ,in , , , Indicates the sequence number, As a point Steering angle and curvature value at the location Defined as the supplementary angle of the steering angle, where ; S302. The Douglas-Peucker algorithm is used to approximate the contour into a polygon, retaining the main inflection points of the contour. Curvature is calculated only at the vertices of the approximate polygon, and all points with curvature values less than the preset concave point threshold are marked as candidate concave points. S303. For each candidate concave point, calculate its spatial distance from other concave points. After taking the two closest concave points as candidate pairing objects, check whether the line connecting the concave point and the candidate concave point is completely inside the connected domain. If the line is inside the connected domain, it is a valid dividing line; otherwise, it is not a valid dividing line.
5. The TBM image slag segmentation method based on machine vision according to claim 4, characterized in that, S3 specifically includes the following steps: S304. Statistically analyze all pairs of concave points whose lines are located within the connected domain, select the pair with the shortest line length as the optimal match, connect the pair of concave points to generate a dividing line, and this dividing line is the boundary path between two adhering rock fragments. S305. Count the pixels traversed by the boundary path and change their pixel values from 255 to 0 in the binarized image. S306. After completion, the original connected domain is divided into two independent sub-connected domains, each representing two independent rock debris targets. If there are multiple pairs of matching concave points in a connected domain, the same operation is repeated to cut multiple times until all valid concave point pairs are processed. All the cut sub-connected domains are then output as independent rock debris.
6. The TBM image slag segmentation method based on machine vision according to claim 1, characterized in that, S4 specifically includes the following steps: S401. Receive the binary image of the connected component that is determined to be heavily connected, delete the pixels that meet the specific conditions on the boundary of the connected component one by one, and use the binary image composed of all the remaining pixels as the skeleton graph of the connected component. S402. Scan the entire skeleton image and count the number of other skeleton pixels in the neighborhood of each skeleton pixel. Classify each pixel into endpoints, branch points, and ordinary points. Starting from each branch point, trace along the skeleton branch to the endpoint or other branch points. Record the path length and direction vector of each branch. When the path length is less than the preset length threshold, the branch is regarded as a noise branch and removed from the skeleton structure. S403. Calculate the coordinate position of each endpoint in the skeleton diagram, generate a circular area with it as the center, assign the value 1 to all pixels in the circular area as the foreground marker, representing the seed area of each independent rock debris. S404. For the coordinate position corresponding to each branch point, assign the value 2 to the pixel where it is located as a dividing line marker, representing the boundary constraint between different rock fragments, and use differentiated marking scales for connected regions of different sizes.
7. A TBM image slag segmentation method based on machine vision according to claim 6, characterized in that, S4 specifically includes the following steps: S405. Draw a circular foreground marking region with each endpoint as the center and the marking scale as the radius. Draw a segmentation marking region with each branch point as the center and one-third of the marking scale as the radius. Finally, a multi-scale marking image is generated. S406. Calculate the gradient magnitude using the original grayscale image to obtain a gradient image. Regions in the gradient image with gradient values higher than a preset value correspond to the edge positions of the rock debris. Use the multi-scale labeled image as the initial seed for watershed transformation. Perform label-based watershed transformation on the gradient image. Use pixels with a value of 1 in the labeled image as seed points for forced minimum values and pixels with a value of 2 as constraint points for watershed ridges. Start from various sub-points and perform region growth on the gradient image. Regions grown from different seed points meet at the gradient ridge and stop expanding. Determine the boundaries of each region and use them as the segmentation result. S407. Use watershed transformation to divide the heavily cohesive connected domain into multiple independent regions, and output each independent region as a rock debris target.
8. The TBM image slag segmentation method based on machine vision according to claim 1, characterized in that, S5 specifically includes the following steps: S501. Count all independent rock debris regions, calculate the pixel area of each region, compare the pixel area with the preset minimum area threshold, if the pixel area is less than the preset minimum area threshold, then determine that the region is a fragment generated by over-segmentation and remove it from the segmentation result. S502. After completing the area screening, calculate the size parameters for each retained effective rock debris area, and output the effective rock debris area and its size parameters through a visual interface.
