Line structured light center extraction method and system based on spatial gray gravity center propulsion
By using a spatial gray-scale centroid advancement method, combined with eight-neighbor determination and an improved Otsu's method, the shortcomings of linear structured light center extraction algorithms in terms of accuracy and speed are solved, achieving efficient and stable light stripe center extraction, which is suitable for industrial online inspection.
Patent Information
- Application Number
- CN202310629322.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-31
- Publication Date
- 2025-12-30
- Estimated Expiration
- 2043-05-31
AI Technical Summary
Existing line structured light center extraction algorithms struggle to balance extraction accuracy and speed simultaneously, and they also have high image quality requirements, especially performing poorly in underexposed light bar images.
A method based on spatial gray-level centroid advancement is adopted, which combines the eight-neighborhood judgment method and the improved Otsu method for image binarization. The light stripe region is located by combining the laser skeleton trend, and the center coordinates are extracted by spatial gray-level centroid. Finally, the 3σ criterion is used to remove outliers.
It improves the utilization rate of pixels in the light stripe area, enhances the stability and accuracy of the algorithm, reduces the requirements for image quality, and is suitable for industrial online inspection.
Smart Images

Figure CN116681753B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image data processing technology, and in particular to a method and system for extracting the center of a line structured light based on spatial grayscale centroid advancement. Background Technology
[0002] In recent years, with the continuous improvement of industrial levels, accurately acquiring three-dimensional data of workpiece dimensions has become one of the important research directions in the field of measurement. Line structured light three-dimensional measurement technology has advantages such as non-contact operation, simple structure, high stability, and high accuracy, and is widely used in dimensional measurement, weld tracking, and defect detection. A line structured light measurement system mainly consists of an industrial camera and a line structured laser emitter. Based on the laser triangulation measurement principle, the laser projects line structured light onto the workpiece, and the camera acquires the laser stripe image on the workpiece surface. By combining the triangulation relationship between the line structured light laser and the industrial camera, the surface dimension information of the workpiece can be obtained. The measurement process mainly includes two steps: First, the calibration of the measurement system. Based on the positional relationship between the laser and the industrial camera, and the internal parameters of the industrial camera, a correspondence is established between the pixel coordinates of the laser stripe image and the actual physical coordinates of the workpiece. Second, the extraction of the laser stripe centerline. The laser stripes acquired by the industrial camera usually occupy a certain pixel width in the image, requiring the extraction of the laser centerline. The accuracy of the laser centerline extraction directly affects the measurement accuracy of the entire system. Therefore, a fast, stable, and accurate laser centerline extraction algorithm is particularly important for the measurement accuracy of a 3D measurement system.
[0003] Traditional light stripe centerline extraction algorithms are mainly divided into two categories: those based on light stripe geometric features, such as the geometric center method and skeleton thinning method; and those based on image grayscale features, such as the extremum method, grayscale centroid method, orientation template method, and Steger method. However, these methods often cannot simultaneously achieve both extraction accuracy and extraction speed.
[0004] Although scholars both domestically and internationally have proposed many improved algorithms for extracting laser centerlines from traditional methods, these algorithms often fail to adequately balance stability, accuracy, and speed. The Steger algorithm offers high accuracy but is relatively slow, and improper selection of the Gaussian kernel can significantly impact the extraction results. Furthermore, it is highly sensitive to image quality, performing poorly on laser centerlines extracted from images with poor image quality. Gray-scale centroid methods and thresholding methods are fast but susceptible to noise, exhibiting low accuracy in extracting laser stripe images with poor quality, and are prone to producing breaks and missing points in underexposed light stripe images. Summary of the Invention
[0005] To address the aforementioned problems, the present invention aims to provide a method and system for extracting the center of line structured light based on spatial grayscale centroid advancement. This method offers high extraction accuracy, enhances the processing capability for underexposed light bar images, and effectively reduces environmental limitations on line structured light measurements.
[0006] To achieve the above objectives, in a first aspect, the technical solution adopted by the present invention is as follows: a method for extracting the center of a line structured light based on spatial gray-scale centroid advancement, comprising: locating the starting point of the laser stripe region in a laser stripe image based on the eight-neighbor determination method, and advancing it in conjunction with the trend of the laser skeleton to select a laser stripe spatial region; extracting the spatial gray-scale centroid of the laser stripe spatial region to obtain the sub-pixel center coordinates of the laser stripe in the laser stripe spatial region; and using the 3σ criterion to remove abnormal center points in the sub-pixel center coordinates of the laser stripe to obtain the laser center coordinate point.
[0007] Furthermore, the laser stripe spatial region is selected, including: performing bilateral filtering noise reduction on the laser stripe image; using the improved Otsu method to adaptively select the binarization segmentation threshold for each column of the image; performing image binarization to divide the laser stripe image into stripe region and background region; traversing the laser stripe image pixels obtained by the Otsu method segmentation from left to right and from top to bottom, column by column and row by row; if the pixel value of the current point is 255, the eight-neighbor determination method is used to determine the nature of the current point until the starting point of the starting column of the laser stripe region is located; based on the laser skeleton trend combined with the eight-neighbor determination method, the starting point of the next column of light stripes is quickly located until the entire image is traversed to obtain the laser stripe spatial region.
[0008] Furthermore, an improved Otsu's method is used to adaptively select the binarization segmentation threshold for each column of the image, including: the pixel length of the laser stripe image is L, the width is W, and the total number of pixels is L×W; traversing the image pixels, the number of pixels with gray value i is recorded as n. i The probability of a pixel with grayscale value i appearing in the image is p. i For a laser stripe image, the pixel with the larger grayscale value is the target pixel. Choosing a binarization segmentation threshold of t, and letting P0(t) and P1(t) represent the probabilities of the background pixel and the target pixel appearing in the image, respectively, then:
[0009]
[0010]
[0011] Where, p i =n i / (L×W);
[0012] Let u(t), u0(t), and u1(t) be the average values of the entire image, the background pixels, and the foreground pixels, respectively. Then:
[0013]
[0014]
[0015]
[0016] The inter-class variance δ was obtained b (t) is:
[0017] δ b (t)=P0(t)[u0(t)-u(t)] 2 +P1(t)[u1(t)-u(t)] 2
[0018] When the binarization segmentation threshold t makes the inter-class variance δ b When (t) is at its maximum, it is denoted as the optimal threshold T.
[0019] Furthermore, based on the laser skeleton trend combined with the eight-neighbor determination method, the starting point of the next column of light stripes is quickly located, including:
[0020] Assuming the spatial gray-scale centroid coordinates of the previous column are (x, y), advance one column along the skeleton direction based on these coordinates, and determine whether the gray value of the pixel (x+1, y) is zero. If it is zero, then traverse the image again in order to find the starting point of the next light bar column.
[0021] If it is not zero, the eight-neighborhood determination method is used to determine whether it meets the requirements of the light stripe starting point; if it does, the pixel bright spots are searched upwards and downwards from this point to expand the target light stripe area of the current column.
[0022] If a point is identified as noise, the image is re-traversed in order.
[0023] Furthermore, the eight-neighbor determination method is as follows:
[0024] The nature of the current point is determined by counting the number of bright spots in the eight neighboring pixels. Let j be the number of bright spots in the eight neighboring pixels. If j≤5, the current point is determined to be a noise point; if j>5, the point is considered to be the starting point of the light stripe region.
[0025] Based on the coordinates of the starting point of the current column of light stripes, search for pixel highlights upwards and downwards respectively, and expand to obtain the target light stripe region of the starting column of light stripes.
[0026] Furthermore, the spatial grayscale centroid of the laser stripe spatial region is extracted, including:
[0027] Depending on the number of light stripe regions currently stored, the spatial grayscale centroid method for extracting the center of light stripes falls into the following three categories:
[0028] If both the current column point set and the previous column point set are empty, the gray-scale centroid method is used to extract the gray-scale centroid of the current column light stripe for the next column point set region.
[0029] If the current column point set is not empty and the previous column point set is empty, extract the spatial gray-scale centroid of the region between the next column point set and the current column point set;
[0030] If neither the current column point set nor the previous column point set is empty, extract the spatial grayscale centroid for the regions of the next column point set, the current column point set, and the previous column point set.
[0031] Furthermore, the 3σ criterion is used to eliminate abnormal center points in the sub-pixel center coordinates of the laser stripe, including:
[0032] The vertical distance between adjacent center point pixels in the laser stripe image is calculated to obtain the distribution of distances between adjacent center point pixels;
[0033] The vertical distance distribution between adjacent pixels in the laser stripe image approximates a normal distribution. Points whose distance between adjacent center pixels is greater than a preset distance are considered as outliers.
[0034] Secondly, the technical solution adopted by the present invention is as follows: a line structured light center extraction system based on spatial gray-scale centroid advancement, comprising: a first processing module, which locates the starting point of the laser stripe region in the laser stripe image based on the eight-neighbor determination method, and advances the selection of the laser stripe spatial region in combination with the trend of the laser skeleton; a second processing module, which extracts the spatial gray-scale centroid of the laser stripe spatial region to obtain the sub-pixel center coordinates of the laser stripe in the laser stripe spatial region; and a third processing module, which uses the 3σ criterion to remove abnormal center points in the sub-pixel center coordinates of the laser stripe to obtain the laser center coordinate point.
[0035] Thirdly, the technical solution adopted by the present invention is: a computer-readable storage medium for storing one or more programs, wherein the one or more programs include instructions, which, when executed by a computing device, cause the computing device to perform any of the methods described above.
[0036] Fourthly, the technical solution adopted by the present invention is: a computing device comprising: one or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs include instructions for performing any of the methods described above.
[0037] The present invention has the following advantages due to the adoption of the above technical solutions:
[0038] 1. The present invention solves the problem of discontinuous light stripes caused by global threshold by selecting binarization thresholds by column.
[0039] 2. This invention is based on the extraction of spatial centroid coordinates combined with the trend advancement of the structured light skeleton, which avoids accessing the background pixels of the image and improves the running speed of the algorithm.
[0040] 3. This invention uses the spatial gray-scale centroid method to extract the center coordinates of the stored three columns of light stripe regions, realizing the reuse of pixels in the light stripe regions, improving the extraction accuracy of the algorithm, and enhancing the stability of the algorithm.
[0041] 4. This invention uses the Laida criterion to remove outliers, avoiding errors caused by missing light stripe regions.
[0042] In summary, this invention offers advantages such as fast extraction speed, stable extraction results, and high precision. It also reduces the requirements for image quality, making it suitable for online inspection in industrial applications. Attached Figure Description
[0043] Figure 1 This is a flowchart of the line structured light center extraction method based on spatial grayscale centroid advancement in this embodiment of the invention;
[0044] Figure 2 This is a schematic diagram of the eight-neighborhood of an image in an embodiment of the present invention;
[0045] Figure 3 This is a binarized light bar image from an embodiment of the present invention;
[0046] Figure 4 This is a schematic diagram of the propulsion method in an embodiment of the present invention;
[0047] Figure 5 This is a schematic diagram of the spatial grayscale centroid method in an embodiment of the present invention;
[0048] Figure 6a This is a schematic diagram of the theoretically extracted light stripe region in an embodiment of the present invention;
[0049] Figure 6b This is a schematic diagram of the actual extracted light stripe area in an embodiment of the present invention;
[0050] Figure 7 This is a distribution map of the distance between adjacent center points pixels in an embodiment of the present invention;
[0051] Figure 8a This is a diagram illustrating the extraction effect of complex stripes in an embodiment of the present invention;
[0052] Figure 8b This is a diagram illustrating the extraction effect of brightness discontinuous stripes in an embodiment of the present invention;
[0053] Figure 8cThis is an image showing the extraction effect of uneven brightness stripes in an embodiment of the present invention;
[0054] Figure 9 This is an image of discontinuous light bar brightness in an embodiment of the present invention;
[0055] Figure 10a This is a schematic diagram illustrating the extraction effect of an image with uneven light stripe brightness distribution in an embodiment of the present invention;
[0056] Figure 10b This is a schematic diagram illustrating the extraction effect of the gray-scale centroid method on an image with uneven light stripe brightness distribution;
[0057] Figure 10c This is a schematic diagram illustrating the extraction effect of an image with uneven light stripe brightness distribution using an internal propagation algorithm.
[0058] Figure 10d This is a schematic diagram illustrating the extraction effect of the Steger method on an image with uneven light stripe brightness distribution;
[0059] Figure 11a This is the laser stripe image image_1 in the embodiment of the present invention;
[0060] Figure 11b This is a local image of image_1 extracted using the traditional Steger method;
[0061] Figure 11c This is a diagram showing the effect of the Steger improved algorithm extracting image_1 in an embodiment of the present invention;
[0062] Figure 12 This is a comparison chart of extraction accuracy and extraction speed in embodiments of the present invention. Detailed Implementation
[0063] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, 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, not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the described embodiments of the present invention are within the scope of protection of the present invention.
[0064] It should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the scope of exemplary embodiments according to the invention. As used herein, the singular form is intended to include the plural form as well, unless the context clearly indicates otherwise. Furthermore, it should be understood that when the terms "comprising" and / or "including" are used in this specification, they indicate the presence of features, steps, operations, devices, components, and / or combinations thereof.
[0065] When using line structured light for 3D measurement of workpieces, rapid and accurate extraction of the laser bar center is one of the key technologies of the measurement system. This invention proposes a laser center extraction method based on spatial gray-scale centroid advancement. This method selects the spatial region of the laser bar by combining laser bar skeleton trend advancement with an eight-neighborhood judgment method, and then extracts the spatial gray-scale centroid of the selected region. After extracting the entire image, the 3σ criterion (Laida criterion) is used to eliminate abnormal center points, finally obtaining the laser center coordinate information. Experimental results show that the root mean square error of the extracted center is 0.4923 pixels, which is 9.8% higher than the Steger improved algorithm with the best extraction accuracy and 5 times faster extraction speed; compared with the internal advancement algorithm with the best processing speed, the extraction accuracy is improved by 24.1% while maintaining the extraction speed. At the same time, this invention greatly enhances the processing capability of underexposed light bar images and effectively reduces the environmental limitations on line structured light measurement. It can achieve stable, fast, and accurate extraction of the laser center line, meeting the real-time requirements of industrial measurement.
[0066] In one embodiment of the present invention, a method is provided. In this embodiment, as... Figure 1 As shown, the method includes the following steps:
[0067] 1) Based on the eight-neighbor determination method, locate the starting point of the laser stripe region in the laser stripe image, and combine it with the trend of the laser skeleton to select the laser stripe spatial region.
[0068] 2) Extract the spatial grayscale centroid of the laser stripe spatial region to obtain the coordinates of the sub-pixel center of the laser stripe in the laser stripe spatial region;
[0069] 3) The 3σ criterion is used to remove abnormal center points in the sub-pixel center coordinates of the laser stripe to obtain the laser center coordinates.
[0070] In step 1) above, selecting the laser stripe spatial region includes the following steps:
[0071] 1.1) The laser stripe image is subjected to bilateral filtering noise reduction. The improved Otsu method is used to adaptively select the binarization segmentation threshold for each column of the image and perform image binarization to divide the laser stripe image into stripe region and background region.
[0072] In this embodiment, noise reduction processing is required before binarizing the laser stripe image. Bilateral filtering is based on a spatially distributed Gaussian filtering function, which takes into account both the spatial proximity and pixel value approximation of the image during the noise reduction process. Its advantage is that it can better preserve the edge information of the image, and can better protect the edge information of the laser stripe while removing noise in the laser stripe image noise reduction process.
[0073] 1.2) The laser stripe image pixels are segmented using the Otsu method, traversing column by column and row by row from left to right and top to bottom. If the pixel value of the current point is 255, the eight-neighbor determination method is used to determine the nature of the current point until the starting point of the starting column of the laser stripe region is located; the eight-neighbor diagram of the image is shown. Figure 2 As shown.
[0074] 1.3) Based on the laser skeleton trend combined with the eight-neighbor determination method, the starting point of the next column of light stripes is quickly located until the entire image is traversed to obtain the spatial region of the laser stripes.
[0075] In step 1.1) above, the Otsu's method, also known as the maximum inter-class variance method, divides the image into background and target parts by selecting a threshold that maximizes the inter-class variance between the target and background pixels. This threshold is then used as the optimal threshold for image binarization segmentation. Typically, grayscale images have a pixel depth of 8, corresponding to pixel values ranging from 0 to 255. Since the pixel grayscale values of the stripe region and the background region in a laser stripe image differ significantly, the Otsu's method can be chosen for image binarization. However, the traditional Otsu algorithm suffers from problems such as excessive breakpoints and poor extraction results for images with uneven brightness distribution in the laser stripes. Therefore, this invention employs an improved Otsu's method to adaptively select a threshold for each column of the image, completing the binarization of the laser stripe image.
[0076] In this embodiment, an improved Otsu method is used to adaptively select the binarization segmentation threshold for each column of the image, including the following steps:
[0077] 1.1.1) The laser stripe image has a pixel length of L, a width of W, and a total number of pixels of L×W; iterate through the image pixels and record the number of pixels with grayscale value i as n. i The probability of a pixel with grayscale value i appearing in the image is p. i ;
[0078] 1.1.2) For a laser stripe image, the pixel with the larger grayscale value is the target pixel; select a binarization segmentation threshold of t, and let P0(t) and P1(t) be the probabilities of the background pixel and the target pixel appearing in the image, respectively. Then:
[0079]
[0080]
[0081] Where, p i =n i / (L×W);
[0082] 1.1.3) Let u(t), u0(t), and u1(t) be the average values of the entire image, the background pixels, and the foreground pixels, respectively. Then:
[0083]
[0084]
[0085]
[0086] The inter-class variance δ was obtained b (t) is:
[0087] δ b (t)=P0(t)[u0(t)-u(t)] 2 +P1(t)[u1(t)-u(t)] 2
[0088] 1.1.4) When the binarization segmentation threshold t makes the inter-class variance δ b When (t) is at its maximum, it is denoted as the optimal threshold T.
[0089] In step 1.3) above, since the laser stripes have continuous characteristics, it is assumed that the binarized laser stripes are as follows: Figure 3 As shown, the propulsion method is as follows Figure 4 As shown, the starting point of the next column of light stripes is quickly located based on the laser skeleton trend combined with the eight-neighbor determination method, including the following steps:
[0090] 1.3.1) Assuming the spatial gray-scale centroid coordinates of the previous column are (x,y), advance one column along the skeleton direction based on these coordinates, and determine whether the gray value of the pixel (x+1,y) is zero. If it is zero, then traverse the image again in order to find the starting point of the next light bar column.
[0091] 1.3.2) If it is not zero, the eight-neighborhood determination method is used to determine whether it meets the requirements of the light stripe starting point; if it does, the pixel bright spot is searched upward and downward from this point as the starting point to expand the target light stripe area of the current column.
[0092] 1.3.3) If a point is identified as noise, the image is retraced in order.
[0093] This process continues until the entire image has been traversed.
[0094] In step 1.2) above, the eight-neighbor determination method includes the following steps:
[0095] 1.2.1) Count the number of bright spots in the eight neighboring pixels to determine the nature of the current point. Let j be the number of bright spots in the eight neighboring pixels. If j≤5, the current point is determined to be a noise point; if j>5, the point is considered to be the starting point of the light stripe region.
[0096] 1.2.2) Based on the coordinates of the starting point of the current column of light stripe region, search for pixel bright spots upwards and downwards respectively, and expand to obtain the target light stripe region of the starting column of light stripe.
[0097] In step 2) above, the grayscale centroid method used in this embodiment refers to assigning different weighting values to each coordinate point based on the pixel grayscale value of each coordinate point. The grayscale centroid (X,Y) is:
[0098]
[0099] The spatial gray-scale centroid method, based on the eight-neighborhood determination method combined with the coordinate information of the light stripe region selected by the skeleton trend, extracts the spatial gray-scale centroid of the original laser stripe gray values. Specifically:
[0100] Three point sets are configured: `next_points` (next column point set), `current_points` (current column point set), and `old_points` (previous column point set) to store the coordinate information of the extracted three adjacent laser stripe regions. First, the `next_points` point set stores the position information (x, y, y) of the currently extracted next column of light stripe regions. i ,y i (i = 0, 1, 2, ..., n), and then the spatial gray-level centroid method is used to extract the centroid of the selected regions from the three point sets. First, the old_points point set is cleared, and the point sets stored in current_points are transferred to old_points, then current_points is cleared; then the point sets stored in next_points are transferred to current_points, then next_points is cleared. Finally, based on the extracted midpoint of the current column of light stripes, the process moves forward, and the next_points point set continues to store the coordinate information of the newly extracted light stripe region in the next column, completing the update of the light stripe region. The spatial gray-level center is extracted again until the center line of the entire image is extracted. If a breakpoint is encountered during the process, the current_points and old_points point sets are cleared, and the starting column of the light stripe is repositioned.
[0101] In this embodiment, as Figure 5 As shown, spatial gray-scale centroid extraction is performed on the spatial region of the laser stripe. Depending on the number of currently stored light stripe regions, the spatial gray-scale centroid method for extracting the light stripe center can be divided into the following three cases:
[0102] 2.1) If both the current column point set current_points and the previous column point set old_points are empty, the gray-scale centroid method is used to extract the gray-scale centroid of the current column light stripe in the next column point set next_points region;
[0103] 2.2) If the current column point set current_points is not empty and the previous column point set old_points is empty, extract the spatial gray-scale centroid of the region between the next column point set next_points and the current column point set current_points.
[0104] 2.3) If the current column point set current_points and the previous column point set old_points are both not empty, extract the spatial gray-scale centroid for the regions of the next column point set next_points, the current column point set current_points and the previous column point set old_points.
[0105] In step 3) above, when the brightness distribution of the laser stripe is uneven, the binarized laser image will contain dark spots with pixel values of zero in the stripe region. During the stripe region expansion process based on the advance point coordinates, the presence of these dark spots will result in an incomplete expanded stripe region, leading to the extraction of incorrect spatial grayscale centroid coordinates, such as... Figure 6a , Figure 6b As shown.
[0106] The basic principle of the 3σ criterion is to assume that a set of data contains only random errors, calculate the standard deviation, determine an interval with a certain probability, and consider that errors exceeding this interval are not random errors but gross errors and should be eliminated.
[0107] In this embodiment, the abnormal center points in the sub-pixel center coordinates of laser stripes are eliminated using the 3σ criterion, including the following steps:
[0108] 3.1) Due to the continuous nature of the structured light stripe image, the vertical distance between adjacent center point pixels in the laser stripe image is calculated to obtain the distribution of distances between adjacent center point pixels, such as... Figure 7 As shown;
[0109] 3.2) The vertical distance distribution between adjacent pixels in the laser stripe image is approximately a normal distribution. Points whose distance between adjacent center pixels is greater than a preset distance are considered as outliers.
[0110] Example: The rationality of this invention is verified through experimental results and analysis in this example. A line structured light image acquisition platform was built. The experimental platform uses a 450nm blue-violet line structured laser as the light source with a power of 150mW. The camera used is the Daheng Mercury series CMOS industrial camera MER-502-79U3C with a resolution of 2448×2048. This invention is developed using Visual Studio 2019 and programmed in C++ and OpenCV 4.5. The computer processor is an Intel(R) Core(TM) i5-8250U CPU@1.60GHz, with 8GB of memory, and the operating system is Windows 10.
[0111] This invention extracts laser stripe images with complex shapes, discontinuous brightness, and uneven distribution, achieving the following extraction results: Figures 8a to 8c As shown, this invention exhibits strong stability and can achieve relatively accurate centerline extraction even for light bar images with complex shapes, uneven brightness, and discontinuous patterns.
[0112] To further evaluate the extraction accuracy and speed of this invention, the method was compared with the gray-scale centroid method, the internal advancement algorithm, and the Steger method. The gray-scale centroid method reduces the error caused by uneven gray levels in the light stripe and has a faster computation speed. However, it is susceptible to noise and struggles to satisfy a Gaussian distribution. The internal advancement method avoids accessing background pixels and uses a threshold centroid method to quickly locate the center of the light stripe, accelerating the extraction speed. However, it is susceptible to noise and has poor extraction accuracy. The Steger method has high accuracy and good robustness. Its disadvantages include a large computational load, low efficiency, inability to achieve real-time results, and high requirements for laser image quality; improper Gaussian kernel selection can lead to image information distortion. The extraction results of each algorithm on images with poor quality are shown in the figure. Figure 9 The image shown is an image with uneven brightness distribution of light stripes; as shown... Figures 10a to 10d The figures shown are the extraction results of the method of this invention, the gray-scale centroid method, the internal advancement algorithm, and the Steger algorithm, respectively.
[0113] As shown in the figure, for images with uneven light stripe brightness distribution, the present invention can still stably extract the laser center line, and the extraction effect is better than the other three algorithms; the gray-scale centroid method and the internal advancement algorithm have weaker extraction effects than the present invention, but can still extract the laser center line relatively stably; the Steger algorithm has poor extraction effect for images with poor image quality.
[0114] The extraction accuracy of each algorithm is quantitatively analyzed. Since the theoretical position of the laser centerline cannot be determined during actual measurement, the accuracy analysis of laser stripe center extraction algorithms typically uses the standard deviation σ to analyze the error. Let y iThe ordinates of the pixels extracted by the algorithm, Let σ be the mean, and n be the number of center points. Then σ can be expressed as:
[0115]
[0116] This invention involves extracting the centerline of a known straight laser stripe. Based on all the extracted laser center points, a least-squares fitting method is used to fit a straight line, obtaining the equation of the line. The accuracy of the algorithm is evaluated by analyzing the standard deviation σ between the coordinates of each center point and the straight line equation.
[0117] Because the traditional Steger method requires high-quality light stripes, it is not effective in extracting underexposed stripe images. Even a small number of outlier errors can significantly impact the accuracy of the Steger method.
[0118] Therefore, an improvement to the Steger method is made by using the Laida criterion to eliminate outliers. For example... Figure 11a The image shown is image_1, representing the laser stripe pattern. Figure 11b The image shown is a local result of the traditional Steger method extracting data from image_1, which contains a few outliers. The improved Steger algorithm extracts data as follows: Figure 11c As shown, the Laida criterion accurately removes outliers. The standard deviation σ of the pixels extracted by the traditional Steger method is calculated to be 1.046 pixels; the improved Steger algorithm extracts a standard deviation σ of 0.628 pixels. It is evident that the outlier removal method based on the Laida criterion significantly improves the extraction accuracy of the Steger method for underexposed striped images.
[0119] The center lines of 10 laser straight stripe images with gradually increasing brightness were extracted using the method of this invention, the gray-scale centroid method, the Steger improved algorithm, and the internal propagation algorithm, respectively. The standard deviation σ of each image was recorded, as shown in Table 1.
[0120] Table 1 Analysis of pixel standard deviation σ extracted by each algorithm
[0121]
[0122]
[0123] As shown in Table 3-1, the method of this invention exhibits stable extraction performance, with the center line extraction effect of all laser stripe images outperforming the other three comparative algorithms, achieving an average extraction accuracy of 0.4923 pixels. Among the comparative algorithms, the improved Steger algorithm demonstrates the best extraction accuracy, with an average extraction accuracy of 0.5455 pixels. This method represents a 9.8% improvement in extraction accuracy compared to the improved Steger algorithm.
[0124] The extraction speed of each algorithm was quantitatively analyzed. The laser stripe center line was extracted from image_1 using the method of this invention, the gray-scale centroid method, the improved Steger algorithm, and the internal propagation algorithm, repeated 10 times. The extraction time of each algorithm was recorded for each iteration, and their average values were calculated, as shown in Table 2.
[0125] Table 2 Laser centerline extraction time
[0126]
[0127] As shown in Table 2, the average extraction speed of the method of the present invention is 0.0752s, which is only slightly lower than the internal advancement algorithm of 0.0066s and significantly higher than the Steger improved algorithm with the best extraction accuracy.
[0128] Based on the extraction accuracy and extraction speed data of each algorithm, we can obtain Figure 12 .Depend on Figure 12 It can be seen that the extraction accuracy of this invention is 0.4923 pixels, and the extraction speed is 0.0752 seconds. Compared with the Steger improved algorithm, which has the highest accuracy among the comparison algorithms, the extraction accuracy is improved by 9.8%, and the processing speed is improved by nearly 5 times. Compared with the internal advancement algorithm, which has the fastest processing speed among the comparison algorithms, this invention improves the extraction accuracy by 24.1% while maintaining the extraction speed. At the same time, this invention extracts the spatial gray-level centroid of the three light bar regions, which increases the pixel utilization rate of the laser image by three times, greatly improving the stability of the algorithm in processing complex images and underexposed light bar images, and reducing the algorithm's requirements for image quality.
[0129] In summary, this invention provides a laser centerline extraction method based on laser skeleton trend progression and spatial gray-level centroid. By selecting binarization thresholds column-by-column, it solves the problem of discontinuous light stripes caused by global thresholds. Combining the spatial centroid coordinates extracted from the previous column with the trend progression of the structured light skeleton avoids accessing background pixels, improving algorithm speed. The spatial gray-level centroid method extracts the center coordinates of the stored three light stripe regions, enabling the reuse of pixels in the light stripe regions, improving extraction accuracy, and enhancing algorithm stability. The Laida criterion is used for outlier removal, avoiding errors caused by missing light stripe regions. Experimental results demonstrate that this invention has advantages such as fast extraction speed, stable extraction effect, and high accuracy. Compared to the Steger improved algorithm, which has the best extraction accuracy among comparative algorithms, this invention improves extraction accuracy by 9.8% and extraction speed by nearly 5 times. Compared to the fastest internal progression algorithm among comparative algorithms, this invention improves extraction accuracy by 24.1% while maintaining its extraction speed. This invention has the advantages of high speed, high precision, and stable extraction effect, while reducing the requirements for imaging quality, making it suitable for online detection in industrial fields.
[0130] In one embodiment of the present invention, a line structured light center extraction system based on spatial grayscale centroid advancement is provided, comprising:
[0131] The first processing module locates the starting point of the laser stripe region in the laser stripe image based on the eight-neighbor determination method, and advances the selection of the laser stripe spatial region in combination with the trend of the laser skeleton.
[0132] The second processing module extracts the spatial gray-level centroid of the laser stripe spatial region to obtain the coordinates of the sub-pixel center of the laser stripe in the laser stripe spatial region.
[0133] The third processing module uses the 3σ criterion to remove abnormal center points in the sub-pixel center coordinates of the laser stripe, thereby obtaining the laser center coordinates.
[0134] In the above embodiments, the selected laser stripe spatial region includes:
[0135] Bilateral filtering noise reduction is performed on the laser stripe image. An improved Otsu method is used to adaptively select the binarization segmentation threshold for each column of the image and perform image binarization to divide the laser stripe image into stripe region and background region.
[0136] The laser stripe image pixels are segmented by traversing the Otsu method column by column and row by row from left to right and top to bottom. If the pixel value of the current point is 255, the eight-neighbor determination method is used to determine the nature of the current point until the starting point of the starting column of the laser stripe region is located.
[0137] Based on the laser skeleton trend combined with the eight-neighbor determination method, the starting point of the next column of light stripes can be quickly located until the entire image is traversed to obtain the spatial region of the laser stripes.
[0138] In this embodiment, an improved Otsu method is used to adaptively select the binarization segmentation threshold for each column of the image, including:
[0139] The laser stripe image has a pixel length of L, a width of W, and a total number of pixels of L×W; traverse the image pixels and denote the number of pixels with grayscale value i as n. i The probability of a pixel with grayscale value i appearing in the image is p. i ;
[0140] For a laser stripe image, the pixel with the larger grayscale value is the target pixel; choosing a binarization segmentation threshold of t, and letting P0(t) and P1(t) be the probabilities of the background pixel and the target pixel appearing in the image, respectively, then:
[0141]
[0142]
[0143] Where, p i =n i / (L×W);
[0144] Let u(t), u0(t), and u1(t) be the average values of the entire image, the background pixels, and the foreground pixels, respectively. Then:
[0145]
[0146]
[0147]
[0148] The inter-class variance δ was obtained b (t) is:
[0149] δ b (t)=P0(t)[u0(t)-u(t)] 2 +P1(t)[u1(t)-u(t)] 2
[0150] When the binarization segmentation threshold t makes the inter-class variance δ b When (t) is at its maximum, it is denoted as the optimal threshold T.
[0151] In this embodiment, the starting point of the next column of light stripes is quickly located based on the laser skeleton trend combined with the eight-neighbor determination method, including:
[0152] Assuming the spatial gray-scale centroid coordinates of the previous column are (x, y), advance one column along the skeleton direction based on these coordinates, and determine whether the gray value of the pixel (x+1, y) is zero. If it is zero, then traverse the image again in order to find the starting point of the next light bar column.
[0153] If it is not zero, the eight-neighborhood determination method is used to determine whether it meets the requirements of the light stripe starting point; if it does, the pixel bright spots are searched upwards and downwards from this point to expand the target light stripe area of the current column.
[0154] If a point is identified as noise, the image is re-traversed in order.
[0155] In this embodiment, the eight-neighbor determination method is as follows:
[0156] The nature of the current point is determined by counting the number of bright spots in the eight neighboring pixels. Let j be the number of bright spots in the eight neighboring pixels. If j≤5, the current point is determined to be a noise point; if j>5, the point is considered to be the starting point of the light stripe region.
[0157] Based on the coordinates of the starting point of the current column of light stripes, search for pixel highlights upwards and downwards respectively, and expand to obtain the target light stripe region of the starting column of light stripes.
[0158] In the above embodiments, the extraction of the spatial gray-scale centroid of the laser stripe spatial region includes:
[0159] Depending on the number of light stripe regions currently stored, the spatial grayscale centroid method for extracting the center of light stripes falls into the following three categories:
[0160] If both the current column point set current_points and the previous column point set old_points are empty, the gray-scale centroid method is used to extract the gray-scale centroid of the current column light bar for the next column point set next_points region.
[0161] If the current column point set current_points is not empty and the previous column point set old_points is empty, extract the spatial gray-scale centroid of the region between the next column point set next_points and the current column point set current_points.
[0162] If both the current column point set current_points and the previous column point set old_points are not empty, extract the spatial gray-scale centroid for the regions of the next column point set next_points, the current column point set current_points, and the previous column point set old_points.
[0163] In the above embodiments, the 3σ criterion is used to remove abnormal center points in the sub-pixel center coordinates of laser stripes, including:
[0164] The vertical distance between adjacent center point pixels in the laser stripe image is calculated to obtain the distribution of distances between adjacent center point pixels;
[0165] The vertical distance distribution between adjacent pixels in the laser stripe image approximates a normal distribution. Points whose distance between adjacent center pixels is greater than a preset distance are considered as outliers.
[0166] The system provided in this embodiment is used to execute the above-described method embodiments. For specific processes and details, please refer to the above embodiments, which will not be repeated here.
[0167] In one embodiment of the present invention, a computing device is provided, which can be a terminal and may include: a processor, a communication interface, memory, a display screen, and an input device. The processor, communication interface, and memory communicate with each other via a communication bus. The processor provides computing and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system and a computer program. When executed by the processor, the computer program implements a method for extracting the center of a line structured light based on spatial grayscale centroid advancement. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The communication interface is used for wired or wireless communication with external terminals. Wireless communication can be achieved through Wi-Fi, a management network, NFC (Near Field Communication), or other technologies. The display screen can be a liquid crystal display or an e-ink display. The input device can be a touch layer covering the display screen, or buttons, a trackball, or a touchpad mounted on the casing of the computing device, or an external keyboard, touchpad, or mouse. The processor can call logical instructions stored in the memory.
[0168] Furthermore, the logical instructions in the aforementioned memory can be implemented as software functional units and sold or used as independent products, and can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0169] In one embodiment of the present invention, a computer program product is provided, the computer program product including a computer program stored on a non-transitory computer-readable storage medium, the computer program including program instructions, and when the program instructions are executed by a computer, the computer is able to perform the methods provided in the above-described method embodiments.
[0170] In one embodiment of the present invention, a non-transitory computer-readable storage medium is provided, which stores server instructions that cause a computer to perform the methods provided in the above embodiments.
[0171] The computer-readable storage medium provided in the above embodiments has a similar implementation principle and technical effect to the above method embodiments, and will not be described again here.
[0172] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0173] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0174] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0175] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for extracting the center of a line structured light based on spatial gray-weighted centroid propagation, characterized in that, The method comprises the following steps: Positioning the starting point of the laser stripe region in the laser stripe image based on the eight-neighborhood determination method, and combining the trend of the laser skeleton to proceed to select the laser stripe spatial region; Extracting the spatial gray center of the laser stripe spatial region to obtain the laser stripe sub-pixel center coordinates in the laser stripe spatial region; Removing the abnormal center points in the laser stripe sub-pixel center coordinates by adopting the 3σ criterion to obtain the laser center coordinate points; Selecting the laser stripe spatial region, comprising: Performing bilateral filtering denoising processing on the laser stripe image, selecting the adaptive binary threshold value of each column of the image by adopting the improved Otsu method, performing image binarization, and dividing the laser stripe image into a stripe region and a background region; Traversing the laser stripe image pixel points obtained by the Otsu method from left to right and from top to bottom, if the pixel value of the current point is 255, the nature of the current point is determined by adopting the eight-neighborhood determination method, until the starting point of the starting column of the laser stripe region is positioned; Based on the trend of the laser skeleton, the next column of light strip starting point is quickly positioned by adopting the eight-neighborhood determination method, until the complete image is traversed, and the laser stripe spatial region is obtained; Based on the trend of the laser skeleton, the next column of light strip starting point is quickly positioned by adopting the eight-neighborhood determination method, comprising: Assuming that the spatial gray center coordinates of the last column are (x, y), the next column is advanced along the skeleton direction based on the coordinates, and it is judged whether the gray value of the pixel point (x+1, y) is zero, if it is zero, the image is searched again in sequence to find the starting point of the starting column of the next light strip; If it is not zero, it is judged whether it meets the requirements of the light strip starting point by adopting the eight-neighborhood determination method; if it meets the requirements, the current column target light strip region is expanded by searching the pixel bright spots upward and downward respectively with the point as the starting point; if it is judged as a noise point, the image is searched again in sequence; Extracting the spatial gray center of the laser stripe spatial region, comprising: According to the number of the current stored light strip region, the extraction of the light strip center by the spatial gray center method is divided into the following three cases: If the current column point set and the last column point set are both empty, the gray center method is used to extract the current column light strip gray center for the next column point set region; if the current column point set is not empty and the last column point set is empty, the spatial gray center is extracted for the next column point set and the current column point set region; if the current column point set and the last column point set are both not empty, the spatial gray center is extracted for the next column point set, the current column point set and the last column point set region.
2. The method of claim 1, wherein the method is based on spatial gray center of gravity promotion. Selecting the adaptive binary threshold value of each column of the image by adopting the improved Otsu method, comprising: The laser stripe image has a pixel length L, a width W, and a total number of pixels LxW; the image pixels are traversed, and the number of pixel points with a gray value i is denoted as n i , and the probability of the pixel points with the gray value i appearing in the image is denoted as p i . For the laser stripe image, the side with a large gray value is the target pixel; selecting the binary threshold value as t, and P0(t) and P1(t) are the probabilities of the background pixel and the target pixel appearing in the image respectively, then: where p i = n i / (L x W); u(t), u0(t) and u1(t) are the average values of the whole image, the background pixel and the foreground pixel respectively, then: obtaining the interclass variance δ b (t) is: delta b (t) = P0(t) [u0(t) - u(t)] 2 + P1(t) [u1(t) - u(t)] 2 When the binary segmentation threshold t makes the inter-class variance δ b (t) maximum, denoted as the optimal threshold T.
3. The method of claim 1, wherein the method further comprises: The eight-neighborhood determination method is: Statistically determining the nature of the current point by the number of the eight-neighborhood pixel bright points, and j is the number of the eight-neighborhood pixel bright points, if j≤5, the current point is determined as a noise point. If j>5, the point is considered as the starting point of the light bar region; Based on the current column light bar region starting point coordinates, search for pixel bright spots up and down respectively, and expand to obtain the target light bar region of the light bar starting column.
4. The line structured light center extraction method based on spatial gray gravity center propulsion of claim 1, wherein, The 3σ criterion is adopted to eliminate abnormal center points in the laser stripe sub-pixel center coordinates, including: The vertical distance between adjacent center points of the laser stripe image is calculated to obtain the distance distribution of adjacent center points. The vertical distance distribution of adjacent pixel points of the laser stripe image is approximately normally distributed, and for the points with a distance greater than the preset distance, they are considered as abnormal points.
5. A system for extracting the center of a line structured light based on spatial gray center of gravity propulsion, for implementing the method for extracting the center of a line structured light based on spatial gray center of gravity propulsion according to any one of claims 1-4, characterized in that, Including: The first processing module locates the starting point of the laser stripe region in the laser stripe image based on the eight-neighborhood judgment method, and advances in combination with the trend of the laser skeleton to select the laser stripe spatial region; The second processing module extracts the spatial gray center of the laser stripe spatial region to obtain the laser stripe sub-pixel center coordinates in the laser stripe spatial region; The third processing module adopts the 3σ criterion to eliminate abnormal center points in the laser stripe sub-pixel center coordinates to obtain the laser center coordinate point.
6. A computer-readable storage medium storing one or more programs, the one or more programs comprising instructions that when executed by a computer cause the computer to perform a method comprising: The one or more programs include instructions that, when executed by a computing device, cause the computing device to perform any of the methods of claims 1-4.
7. A computing device, comprising: Including: One or more processors, memories, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs include instructions for executing any of the methods of claims 1-4.
Citation Information
Patent Citations
Method for extracting center line of laser stripe
CN104657587A