Anti-noise interference laser stripe center line extraction method
Through the combination of threshold filtering, ROI cutting, adaptive convolution filtering and grayscale center of gravity method, the problem of low efficiency of laser stripe centerline extraction in complex industrial environments is solved, and high-precision and fast laser stripe centerline extraction is achieved to meet the real-time needs of industrial applications.
Patent Information
- Application Number
- CN202411681588.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-22
- Publication Date
- 2025-04-25
AI Technical Summary
The prior art is difficult to accurately and quickly extract the laser stripe centerline in complex industrial environments, and the calculation amount is large, making it difficult to meet the real-time requirements of industrial applications.
Threshold filtering is used to remove background noise, crop ROI images to reduce the calculation amount, design an adaptive convolution kernel for convolution filtering, restore the symmetrical morphology of laser stripes, and extract the subpixel center point of the laser stripes using the grayscale center of gravity method.
It effectively improves the extraction accuracy of the laser stripe centerline, reduces calculation time, and meets the requirements of precision and real-time in industrial applications.
Smart Images

Figure CN119887619A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of machine vision measurement, and in particular to a laser stripe center line extraction method that is resistant to noise interference. Background Art
[0002] Line structured light technology is a machine vision technology widely used in quality control and inspection of industrial precision parts. Its basic principle is to project laser stripes onto the surface of the workpiece through a laser, use a camera to capture the laser stripe image on the workpiece surface, and then use an image processing algorithm to calculate the pixel coordinates of the center line of the laser stripe for three-dimensional reconstruction of the workpiece surface. The extraction accuracy and speed of the center line of the laser stripe directly affect the accuracy and speed of the workpiece surface reconstruction, and then affect the accuracy and speed of the workpiece quality inspection. It is an important part of the entire workpiece quality inspection process. In actual application scenarios, due to the complex industrial environment containing various noise interferences, it is very difficult to quickly extract the accurate center line of the laser stripe, which hinders the application of line structured light technology in workpiece quality inspection.
[0003] Traditional algorithms for extracting the centerline of laser stripes include extreme value method, grayscale centroid method, edge method, geometric center method, refinement method, Steger algorithm, and directional template method. The extreme value method and grayscale centroid method are ideal when the grayscale distribution of the laser stripes is close to a symmetrical Gaussian distribution, but they have poor noise resistance. The edge method, geometric center method, and refinement method have the advantages of fast processing speed, but low accuracy and are easily affected by noise. The Steger algorithm and directional template rule provide higher accuracy, but the computational complexity is large and the extraction time is long, so it is difficult to meet the real-time application of industrial measurement. Under the interference of complex industrial environments, these methods cannot accurately extract the centerline of laser stripes, and noise filtering must be performed first.
[0004] Patent CN115953459A discloses a method for extracting the center line of laser stripes under complex lighting conditions. First, edge detection and top-hat operation are performed on the collected original laser stripe image, and then the light stripe image after the top-hat operation is binarized and contour detected. Then, the center point of the laser stripe is roughly extracted and the key area of the laser stripe is cropped. Finally, the sub-pixel center point of the laser stripe is extracted by Rosenfeld refinement method and Hessian matrix method. This method uses median filtering and Gaussian filtering for noise removal, but the median filtering and Gaussian filtering have poor ability to retain image details, resulting in blurred and distorted edges and details in the image, and the symmetry of the light stripe morphology cannot be guaranteed, thereby affecting the accuracy of center line extraction. In addition, this method requires three preprocessing steps: edge detection, top-hat operation, and contour detection. When calculating the center point of the laser stripe, two Rosenfeld refinement methods and Hessian matrix methods are combined, resulting in a large amount of calculation, which is difficult to meet the real-time requirements of industrial applications. Summary of the invention
[0005] The purpose of the present invention is to provide a method for extracting the center line of a laser stripe which is resistant to noise interference, aiming to solve the problem of low efficiency of the existing extraction methods.
[0006] To achieve the above object, the present invention provides a method for extracting the center line of a laser stripe with noise resistance, comprising the following steps:
[0007] Perform background noise filtering on the collected laser stripe image;
[0008] Crop ROI image;
[0009] Calculate the adaptive convolution filter kernel;
[0010] Perform adaptive convolution filtering on the ROI image;
[0011] Calculate the center point of the laser stripe.
[0012] Among them, in "filtering background noise of the collected laser stripe image", the specific steps are: setting a threshold T1, using the image data pointer to traverse the collected laser stripe image to filter out background pixels, and obtaining a laser stripe image that does not contain background noise after traversing the image.
[0013] The "cropping ROI image" includes the following steps:
[0014] Calculate the region of interest of the laser stripe image excluding background noise;
[0015] The laser stripe image excluding background noise is cropped to obtain the ROI image.
[0016] Among them, in "calculating adaptive convolution filter kernel", the following steps are included:
[0017] Calculate the histogram of the ROI image, and count the M pixels with the largest grayscale value in the ROI image according to the histogram and calculate the average grayscale value T2 of the M pixels;
[0018] Count the number of pixels with grayscale values greater than 0.75T2 in each column of the ROI image, calculate the average value m for the columns where the number of statistical pixels is not 0, then round m up and determine whether it is an odd number. If it is not an odd number, add 1 to make it an odd number;
[0019] The adaptive convolution kernel is designed to be (m+s)×n.
[0020] Among them, in “Designing the adaptive convolution kernel as (m+s)×n”, the convolution kernel’s Go to The weight of the row elements is set to λ, and the weights of the rows 1 to 2 are Row, No. The weights of the elements from the m+sth row to the m+sth row are set to β, where s is an even number greater than or equal to 4, and n is an odd number greater than or equal to 3.
[0021] The invention discloses a method for extracting the center line of a laser stripe with noise resistance, comprising the following steps: filtering the background noise of a collected laser stripe image; cutting a ROI image; calculating an adaptive convolution filter kernel; performing adaptive convolution filtering on the ROI image; and calculating the center point of the laser stripe. The invention proposes to first remove the background noise of the collected laser stripe image by means of threshold filtering, and adopting an image data pointer when traversing the image by the threshold filtering, thereby greatly improving the access speed of a large number of image pixels; on the basis of the threshold filtering, the calculation amount of the subsequent image processing steps is reduced by calculating the ROI of the laser stripe image, thereby accelerating the entire center line extraction process; an adaptive convolution kernel is designed according to the distribution characteristics of the laser stripes, and convolution filtering of the laser stripe image by the adaptive convolution kernel can remove the interference of complex noise on the laser stripes, and restore the symmetrical shape of the laser stripes, thereby improving the extraction accuracy of the center line of the laser stripe by the grayscale centroid method based on the assumption of laser stripe symmetry; on the basis of restoring the symmetry of the laser stripes, the sub-pixel center point of the laser stripe is extracted by using the grayscale centroid method, thereby ensuring the center line extraction accuracy while reducing the calculation time. Aiming at the situation that the center line of laser stripes is difficult to extract accurately and quickly under the noise interference of complex industrial environments, this method adopts adaptive convolution filtering to remove noise interference, which can effectively improve the extraction accuracy of the center line of laser stripes. At the same time, image data pointer access pixels, ROI calculation and grayscale centroid method are used to accelerate the center line calculation process, thereby realizing accurate and fast extraction of laser stripe center line, meeting the requirements of industrial applications for laser stripe center line extraction accuracy and real-time performance, thereby solving the problem of low efficiency of existing extraction methods. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0023] Figure 1 It is a flow chart of a laser stripe centerline extraction method resistant to noise interference provided by the present invention.
[0024] Figure 2 is the original image of the laser stripes collected by the camera.
[0025] Figure 3 It is the gray value distribution map of the local area of the original image of the laser stripe collected by the camera.
[0026] Figure 4 It is the gray value distribution map of the local area of the laser stripe image without background noise.
[0027] Figure 5 It is the ROI image of the laser stripe image without background noise.
[0028] Figure 6 is the filtered ROI image of the laser stripe image without background noise.
[0029] Figure 7 It is the gray value distribution map of the local area of the filtered ROI image.
[0030] Figure 8 This is the effect diagram of extracting the center line of the laser stripes in the local area of the laser stripe image.
[0031] Fig. 9 This is a flowchart for cutting ROI images.
[0032] Fig.10 It is a flowchart for calculating the adaptive convolution filter kernel. DETAILED DESCRIPTION
[0033] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present invention, and should not be construed as limiting the present invention.
[0034] See also Figures 1 to 10 The present invention provides a method for extracting the center line of a laser stripe with noise resistance, comprising the following steps:
[0035] S1 filters the background noise of the collected laser stripe image;
[0036] The threshold T1 is set, and the image data pointer is used to traverse the collected laser stripe image to filter out the background pixels. After traversing the image, a laser stripe image without background noise is obtained.
[0037] Specifically, the original laser stripe image collected by the camera is as follows: Figure 2 As shown, Figure 3 for Figure 2The grayscale value distribution of the local area of the laser stripes in the middle part shows that there are many non-zero background noise pixels outside the light stripes, and the existence of these pixels is not conducive to the subsequent image processing steps. By setting the threshold T1, the image data pointer is used to traverse the collected laser stripe image pixels, and the grayscale value of the pixel below T1 is set to 0, otherwise it remains unchanged. After traversing the image, a laser stripe image without background noise is obtained, and its local image is shown in the figure below. Figure 4 As shown in the figure, we can see that the background pixels are filtered out and set to 0, and the threshold T1 can be adjusted according to the usage scenario and remain unchanged. Since the number of image pixels is in the millions, the fixed-point access to pixels is very time-consuming. The method of traversing the image using the image data pointer can achieve fast pixel access through pointer shifting.
[0038] S2 cuts the ROI image;
[0039] S21 calculates the region of interest of the laser stripe image excluding background noise;
[0040] Specifically, first use the image data pointer to traverse the laser stripe image without background noise from the first row, find the first non-zero pixel, and record the row where the pixel is located as y top ;
[0041] S22 crops the laser stripe image that does not contain background noise to obtain a ROI image.
[0042] Specifically, the image data pointer is then used to traverse the laser stripe image without background noise from the last row, find the first non-zero pixel, and record the row where the pixel is located as y bottom ; Finally, according to y top ,y bottom The image obtained in step 1 is cropped with ROI and image width w. The size of the ROI image obtained after cropping is (y bottom -y top )×w, such as Figure 5 This step can greatly reduce the number of image pixels that need to be processed in subsequent image processing steps by cropping out the ROI image.
[0043] S3 calculates the adaptive convolution filter kernel;
[0044] S31 calculates the histogram of the ROI image, and counts the M pixels with the largest grayscale value in the ROI image according to the histogram and calculates the average grayscale value T2 of the M pixels;
[0045] Specifically, first, the histogram of the ROI image is calculated, and the M pixels with the largest grayscale values in the image are counted according to the histogram, and the average grayscale value T2 of the M pixels is calculated.
[0046] S32 counts the number of pixels with grayscale values greater than 0.75T2 in each column of the ROI image, calculates the average value m for the columns whose number of counted pixels is not 0, then rounds m up and determines whether it is an odd number, and if it is not an odd number, adds 1 to make it an odd number;
[0047] Specifically, then, use the image data pointer to traverse the ROI image, count the number of pixels in each column of the image whose grayscale value is greater than 0.75T2, calculate the average value m for the columns whose number of counted pixels is not 0, then round m up and determine whether it is an odd number, if not an odd number, add 1 to make it an odd number.
[0048] S33 designs the adaptive convolution kernel as (m+s)×n.
[0049] The convolution kernel Go to The weight of the row elements is set to λ, and the weights of the rows 1 to 2 are OK, The weights of the elements up to the m+sth row are set to β, where s is an even number greater than or equal to 4, and n is an odd number greater than or equal to 3.
[0050] Specifically, a convolution kernel of size (m+s)×n is calculated, where s is an even number greater than or equal to 4, and n is an odd number greater than or equal to 3. The specific values of s and n can be adjusted according to the application scenario and remain unchanged. The weight distribution of the convolution kernel is calculated based on the one-dimensional symmetrical distribution characteristics of the laser stripes in the width direction, which are stepped.
[0051] Specifically, for the convolution kernel Go to The weight λ of the row elements is calculated according to formula (1). OK, The weight β of the elements in the m+sth row is calculated according to formula (2), where w c and w o is the weight distribution coefficient of the convolution kernel. The sum of the two coefficients should be 1 and w c Should be greater than 0.6.
[0052]
[0053] This step realizes the adaptive calculation of the m pixels closest to the center of the laser stripe by means of the image histogram, and then calculates the size and weight distribution of the adaptive convolution kernel based on the distribution characteristics of the laser stripes, so that the subsequent convolution filtering step can remove the interference of complex industrial environment noise on the laser stripes and restore the symmetry of the laser stripes, thereby improving the extraction accuracy of the center line of the laser stripe.
[0054] S4 performs adaptive convolution filtering on the ROI image;
[0055] Specifically, the adaptive convolution kernel calculated by S33 is used to perform convolution filtering on the entire ROI image, and the convolution filtering is performed according to formula (3):
[0056]
[0057] Among them, I(x+i,y+j) is the pixel value of the original image, K(i,j) is the weight coefficient in the convolution kernel, the convolution kernel size is (2l+1)×(2k+1), in this embodiment (2l+1)=m+s, (2k+1)=n, and O(x,y) is the filtered pixel obtained after convolution filtering. Figure 6 The filtered ROI image is obtained after convolution filtering. Figure 7 This is a local gray value distribution diagram of the filtered ROI image. It can be seen that the present disclosure can remove the interference of complex industrial environment noise on the laser stripes and ensure the symmetry of the laser stripe morphology.
[0058] S5 calculates the center point of the laser stripe.
[0059] Specifically, for a laser light stripe, its grayscale value distribution presents a symmetrical Gaussian distribution. The grayscale centroid method uses this symmetry assumption to calculate the weighted average of the grayscale values of all pixels in the area to obtain the precise coordinates of the center position. In the filtered ROI image obtained in S104, the laser stripe has restored a good symmetrical distribution, so the grayscale centroid method can be used to achieve high-precision extraction of the center point of the laser stripe. Specifically, for each column x in the filtered ROI image, the y coordinate of the center point is calculated using formula (4): c :
[0060]
[0061] Where h is the height of the filtered ROI image. Therefore, the coordinates of the center point of each column are (x,y c ), calculate the center points of all columns to complete the extraction of the sub-pixel center line of the laser stripe. Figure 8 This is a rendering of the center line extraction of laser stripes in a local area of a laser stripe image. It can be seen that the present invention can accurately extract the center line of laser stripes that are interfered by noise in a complex industrial environment.
[0062] Beneficial effects:
[0063] 1. Compared with the prior art which only uses general median filtering and Gaussian filtering algorithms to remove noise interference in complex industrial environments, the present invention proposes to first use threshold filtering to remove background noise from the collected laser stripe image, and the image data pointer is used when the threshold filtering traverses the image, which greatly improves the access speed of massive image pixels;
[0064] Second, by calculating the ROI of the laser stripe image on the basis of threshold filtering, the amount of calculation in the subsequent image processing steps is reduced, thereby accelerating the entire centerline extraction process;
[0065] Third, an adaptive convolution kernel is designed according to the distribution characteristics of laser stripes. The convolution filtering of the laser stripe image by the adaptive convolution kernel can remove the interference of complex noise on the laser stripes and restore the symmetrical shape of the laser stripes, thereby improving the extraction accuracy of the center line of the laser stripes by the grayscale centroid method based on the assumption of laser stripe symmetry;
[0066] Fourth, on the basis of restoring the symmetry of the laser stripes, the grayscale centroid method is used to extract the sub-pixel center point of the laser stripes, which ensures the accuracy of center line extraction while reducing the calculation time.
[0067] 5. Aiming at the situation that the center line of laser stripes is difficult to extract accurately and quickly under the noise interference of complex industrial environments, this method adopts adaptive convolution filtering to remove noise interference, which can effectively improve the extraction accuracy of the center line of laser stripes. At the same time, image data pointer access to pixels, ROI calculation and grayscale centroid method are used to accelerate the center line calculation process, thereby realizing accurate and fast extraction of the center line of laser stripes, meeting the requirements of industrial applications for accuracy and real-time extraction of the center line of laser stripes.
[0068] The above disclosure is only a preferred embodiment of a method for extracting the center line of a laser stripe that is resistant to noise interference of the present invention. Of course, this cannot be used to limit the scope of rights of the present invention. Ordinary technicians in this field can understand that all or part of the processes of the above embodiments and equivalent changes made according to the claims of the present invention still fall within the scope of the invention.
Claims
1. A method for extracting the center line of a laser stripe with noise immunity, characterized in that: The following steps are involved: Perform background noise filtering on the collected laser stripe image; Crop ROI image; Calculate the adaptive convolution filter kernel; Perform adaptive convolution filtering on the ROI image; Calculate the center point of the laser stripe.
2. The method for extracting the center line of a laser stripe with noise immunity as claimed in claim 1, characterized in that: In "Filtering background noise of the acquired laser stripe image", the specific steps are: setting the threshold T1, using the image data pointer to traverse the acquired laser stripe image to filter out background pixels, and obtaining a laser stripe image without background noise after traversing the image.
3. The method for extracting the center line of a laser stripe with noise immunity as claimed in claim 2, characterized in that: In "Crop ROI Image", include the following steps: Calculate the region of interest of the laser stripe image excluding background noise; The laser stripe image excluding background noise is cropped to obtain the ROI image.
4. The method for extracting the center line of a laser stripe with noise immunity as claimed in claim 3, characterized in that: In "Calculating Adaptive Convolution Filter Kernel", the following steps are included: Calculate the histogram of the ROI image, and count the M pixels with the largest grayscale value in the ROI image according to the histogram and calculate the average grayscale value T2 of the M pixels; Count the number of pixels with grayscale values greater than 0.75T2 in each column of the ROI image, calculate the average value m for the columns where the number of statistical pixels is not 0, then round m up and determine whether it is an odd number. If it is not an odd number, add 1 to make it an odd number; The adaptive convolution kernel is designed to be (m+s)×n.
5. The method for extracting the center line of a laser stripe with noise immunity as claimed in claim 4, characterized in that: In "Designing the Adaptive Convolution Kernel as (m+s)×n", the convolution kernel's Go to The weight of the row elements is set to λ, and the weights of the rows 1 to 2 are Row, No. The weights of the elements from the m+sth row to the m+sth row are set to β, where s is an even number greater than or equal to 4, and n is an odd number greater than or equal to 3.
Citation Information
Cited By
Real-time detection method for straightening super-long linear guide rail based on machine vision
CN120747106A