A laser stripe center extraction method based on gray coefficient binarization
By using a method based on grayscale coefficient binarization, differential threshold segmentation of laser stripes is adaptively generated. Combined with a secondary positioning method based on morphological processing and skeleton constraints, the stability and accuracy problems of laser stripe center extraction in complex industrial environments are solved. This achieves sub-pixel level continuous and smooth centerline extraction, which is suitable for online measurement and real-time applications.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- UNIV OF SHANGHAI FOR SCI & TECH
- Filing Date
- 2026-04-03
- Publication Date
- 2026-06-09
AI Technical Summary
Existing technologies struggle to accurately extract the centers of interconnected laser stripes from laser stripe images with highly unstable grayscale distribution and blurred foreground-background boundaries in complex industrial environments, resulting in insufficient accuracy and robustness in 3D reconstruction.
A method based on grayscale coefficient binarization is adopted to adaptively generate differential thresholds to segment laser stripes. The laser stripe skeleton is extracted by combining morphological processing and Zhang-suan thinning method. Subpixel-level centerline fitting and smoothing are performed using a skeleton-constrained quadratic positioning method and bicubic interpolation method to form a continuous and smooth subpixel-level centerline.
Under complex lighting and industrial site interference conditions, stable and robust extraction of laser stripe centers was achieved, improving the accuracy and consistency of 3D reconstruction, and making it suitable for online measurement and real-time application scenarios.
Smart Images

Figure CN121962237B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of visual measurement technology, and specifically to a method for extracting the center of laser stripes based on grayscale coefficient binarization. Background Technology
[0002] Structured light measurement technology, as a non-contact precision measurement method based on the principle of laser triangulation, plays an irreplaceable role in key technology fields such as modern intelligent manufacturing, aerospace assembly, industrial precision inspection, and automatic weld seam tracking. In the standard measurement process, the system projects laser stripes of a specific wavelength onto the surface of the workpiece being measured through a laser projection device. An industrial camera captures the stripe image, which is deformed by the surface contour modulation of the object. Subsequently, a rigorous coordinate system transformation and geometric reconstruction algorithm is used to recover the three-dimensional spatial information of the object. Because the laser beam has a certain divergence and width in physical space, the laser stripes acquired by the camera appear as a light band with a width of multiple pixels in the image space. Therefore, how to accurately extract the center coordinates of the laser stripes from the complex image background not only directly determines the lower limit of the error of the entire measurement system, but is also the core underlying link to achieve sub-pixel-level high-precision three-dimensional reconstruction.
[0003] Within the existing technological framework, a series of classic algorithmic models have been developed for extracting the center of laser stripes, mainly including the gray-scale centroid method, the extremum method, and the Steger method based on the Hessian matrix. These methods are typically designed based on idealized optical assumptions, namely, that the gray-scale distribution of the laser stripe cross-section conforms to a strict Gaussian distribution or is approximately symmetrical, and that the image has an extremely high signal-to-noise ratio. In laboratory environments or specific scenarios with highly controlled operating conditions, these schemes have demonstrated good effectiveness. For example, the gray-scale centroid method determines the center position by weighted averaging of pixel gray levels within the stripe cross-section; its algorithmic structure is simple and can meet the real-time processing requirements at extremely high frame rates. Meanwhile, partial differential equation algorithms, represented by the Steger method, locate the center by extracting the second derivative of the image and finding the location of the maximum eigenvalue of the Hessian matrix, achieving extremely high sub-pixel positioning accuracy. These schemes, in specific historical periods and single application scenarios, laid an important foundation for the engineering application of structured light measurement technology.
[0004] However, with the continuous development of related technologies and the increasingly stringent performance requirements of industrial applications, some inherent characteristics of the aforementioned technical solutions at the principle level have gradually revealed profound technical contradictions when dealing with the challenges of complex production environments. Specifically, the actual working conditions in industrial settings are extremely complex. Affected by factors such as the surface roughness of the workpiece, the anisotropy of the material's reflectivity, stray light interference from the environment, and the speckle noise of the laser itself, the acquired laser stripe images are often in a severely suboptimal state. The reason for this is that traditional extraction algorithms are usually highly dependent on the grayscale continuity and symmetry of the light stripes. However, in real-world scenarios, stripes often exhibit drastic width fluctuations, local brightness saturation, or weak grayscale contrast due to differences in material absorptivity. Especially for workpieces with highly reflective metal surfaces or abrupt geometric changes, laser stripes often appear as discontinuous states with extremely uneven grayscale in the image. At this point, if traditional global fixed threshold segmentation (such as Otsu's method) is used, oversegmentation may occur in areas with strong illumination, leading to distortion of the stripe shape; while in areas with low light or extremely low contrast, the stripe features may be misjudged as background noise and completely lost. This lack of physical information directly causes a logical break in the centerline extraction, resulting in irreparable geometric holes in subsequent 3D modeling.
[0005] Further examination reveals an irreconcilable trade-off between improving positioning accuracy and enhancing environmental robustness in existing technologies. On one hand, while the simple binarization centroid method is fast, it is highly sensitive to threshold parameters; even slight threshold perturbations can cause drastic jumps in center coordinates or false detections. On the other hand, high-precision fitting or feature extraction methods, although theoretically more robust to noise, place extremely high prior requirements on the quality of the initial seed point and the connectivity of the light stripe region during numerical computation. When faced with low-quality images exhibiting local adhesion, background texture interference, or significant speckle grains, these complex mathematical models are prone to getting trapped in local optima, leading to instability in the fitting process. Furthermore, the high computational cost often fails to meet the production cycle requirements for large-scale real-time measurement tasks. This "stability trap," caused by the lack of adaptability of the underlying algorithm to local illumination, has become a core bottleneck restricting the migration of line structured light measurement technology to broader and more complex operating conditions.
[0006] In summary, in dynamic and complex industrial inspection scenarios, robustly separating interconnected laser stripes from raw images with highly unstable grayscale distributions and blurred foreground-background boundaries, while overcoming the impact of physical degradation on center positioning accuracy, has become a deep-seated technical challenge that urgently needs to be overcome in the field of visual measurement. Therefore, constructing a centerline extraction scheme that can adaptively perceive changes in local lighting features, dynamically adjust the segmentation threshold, and achieve continuous, smooth, and sub-pixel accuracy while ensuring real-time algorithm performance has become a key challenge for those skilled in the art. Summary of the Invention
[0007] This invention is made to solve the above-mentioned problems, and aims to provide a method for extracting the center of laser stripes based on grayscale coefficient binarization.
[0008] This invention provides a method for extracting the center of laser stripes based on grayscale coefficient binarization, characterized by the following steps: Step 1: Acquire images using a line structured light camera, and improve the image quality of the laser stripes using grayscale conversion and image filtering methods; Step 2: Segment the laser stripe image using a grayscale coefficient binarization method, and process the segmented laser stripes using morphological methods; Step 3: Initially extract the laser stripe skeleton using the Zhang-suan thinning method, and extract the sub-pixel-level center points of the laser stripes using a skeleton constraint-based secondary positioning method; Step 4: Fit the extracted sub-pixel-level center points using bicubic interpolation to form a sub-pixel-level center line, and smooth the fitted sub-pixel-level center line using a smoothing spline method to obtain the sub-pixel laser stripe center line.
[0009] The laser stripe center extraction method based on grayscale coefficient binarization provided by this invention may also have the following features: Step 1 includes the following sub-steps: Step 1.1: Adjust the position of the line structured light camera, the laser, and the position of the workpiece under test, and set the shooting parameters of the structured light camera; Step 1.2: Use the line structured light camera to acquire data from the workpiece under test, emit a laser line onto the surface of the workpiece under test through the laser, and capture the reflected light; Step 1.3: Perform grayscale processing on the acquired laser stripe image; Step 1.4: Perform median filtering and Gaussian filtering on the grayscale processed laser stripe image to remove noise and improve the quality of the laser stripe image.
[0010] The laser stripe center extraction method based on grayscale coefficient binarization provided by the present invention may also have the following features: wherein, in step 2, the laser stripe image is segmented using the grayscale coefficient binarization method and the segmented laser stripes are processed using morphological methods, including the following steps: segmenting the laser stripe image using the grayscale coefficient binarization method; and processing the segmented laser stripes using erosion and closing operations.
[0011] The laser stripe center extraction method based on grayscale coefficient binarization provided by this invention may also have the following feature: wherein, in step 2, segmenting the laser stripe image using the grayscale coefficient binarization method includes the following steps:
[0012] The OTSU method is used to calculate the threshold of laser stripes in the filtered image, and the global OTSU threshold is calculated. :
[0013]
[0014] In the formula, The proportion of foreground pixels is less than the threshold. ; The percentage of background pixels is greater than the threshold. ; The average gray level of the foreground pixels; The average gray level of the background pixels.
[0015] Iterate through the threshold values of each column in the filtered laser stripe image and calculate the maximum grayscale value for each column. Compared with the average gray level , represented as:
[0016]
[0017]
[0018] In the formula, =1,2,.......,W; =1,2,...... ; The laser stripe image after image filtering is located at... grayscale value at that location
[0019] Calculate the baseline of the global column average grayscale threshold , represented as:
[0020]
[0021] Define the grayscale adjustment factor as , represented as:
[0022]
[0023] In the formula, Indicates the first Column grayscale relative to global column average grayscale threshold baseline The degree of deviation is used to proportionally amplify or reduce the reference grayscale value to adapt to the effects of uneven lighting; if If the value is greater than 1, it means that the gray level of this column is higher than the average gray level of the entire column, making it brighter; if... If <1, it means the gray level of this column is lower than the average gray level of the entire column, making it darker; if =1 indicates that the gray level of this column is consistent with the average gray level of the entire column;
[0024] Introducing peak variation coefficient As an adaptive threshold refer to;
[0025] Calculate the binarization segmentation threshold , represented as:
[0026]
[0027] when When applying the global OTSU threshold ;when hour, An adaptive threshold is used to calculate the low-light column. Grayscale coefficient An upper bound is applied to the threshold to prevent it from becoming too large;
[0028] Binarization segmentation is performed, and the binarization segmentation result is obtained. Represented as:
[0029] .
[0030] The laser stripe center extraction method based on grayscale coefficient binarization provided by this invention may also have the following features: In step 3, the preliminary extraction of the laser stripe skeleton by the Zhang-suan thinning method includes the following steps: The Zhang-suan thinning method relies on eight-neighbor information to classify each foreground pixel according to the role of "internal point", "external point" or "skeleton endpoint", and then completes the removal through two rounds of iteration to obtain the laser stripe skeleton.
[0031] The laser stripe center extraction method based on grayscale coefficient binarization provided by this invention may also have the following feature: wherein, in step 3, the method for obtaining the laser stripe skeleton is as follows:
[0032] Let any foreground pixel in the image to be refined be... The neighboring pixels are { , , };
[0033] Calculate two measures:
[0034]
[0035]
[0036] In the formula, This represents the number of neighboring foreground pixels, used to exclude isolated noise (M < 2) and points within the region M (> 6). Indicates the number of "background-foreground" transitions, only when In this case, deleting the center pixel is necessary to prevent the connected branches from being broken;
[0037] like And satisfy the following , , and If the condition is met, then mark it. Points to be deleted:
[0038]
[0039]
[0040]
[0041]
[0042] After completing the first iteration, repeat the above calculation on the updated image to perform the second iteration. Pixels that meet the above conditions are marked as points to be deleted. After two iterations, all marks are deleted. If there are no new marks, the algorithm converges and outputs a single-pixel skeleton.
[0043] The laser stripe center extraction method based on grayscale coefficient binarization provided by this invention may also have the following feature: wherein, in step 3, extracting the sub-pixel-level center point of the laser stripe using a skeleton constraint-based secondary positioning method includes the following steps:
[0044] The calculation is performed column-wise on the skeleton stripe image, and is represented as follows:
[0045]
[0046] In the formula, The image obtained from the skeleton has a pixel value of 0 or 1, where 0 represents the background and 1 represents the skeleton.
[0047] If set If not empty, then the center point of the column is... Defined as the arithmetic mean of the row coordinates of all skeleton pixels , represented as:
[0048] If set If the column is empty, skip it and do not generate a center point. After calculating all columns containing skeleton pixels, obtain the discrete point set:
[0049]
[0050] In the formula, For a finite number of columns, Index for integer columns, The center coordinates are obtained from the statistics of the skeleton column;
[0051] Binarized stripes are introduced to perform secondary localization of the center position. Let the laser stripe image after binarization segmentation be: Where 1 represents the laser stripe foreground and 0 represents the laser stripe background; for the x-th column, define the set of row coordinates of the foreground pixels in that column. for:
[0052]
[0053] Utilizing the coarse center of the skeleton Constructing a local constraint window , represented as:
[0054]
[0055] In the formula, The window width is set to half the width of the fringe, slightly larger than the half width of the fringe to ensure coverage of the effective cross section of the fringe; the window constraint is applied to the fringe foreground set to obtain the effective set participating in the secondary positioning. :
[0056]
[0057] like Then the sub-pixel center of that column is defined as the arithmetic mean of the effective foreground row coordinates:
[0058]
[0059] Otherwise, skip that column, do not generate a center point, and calculate for all valid columns to obtain the final set of centerline points. , represented as:
[0060]
[0061] In the formula, This represents the number of valid columns retained after secondary positioning.
[0062] The laser stripe center extraction method based on grayscale coefficient binarization provided by this invention may also have the following feature: In step 4, the extracted sub-pixel-level center points are fitted using bicubic interpolation to form a sub-pixel-level center line, and the fitted sub-pixel-level center line is smoothed using a smoothing spline method to obtain the sub-pixel laser stripe center line, including the following steps:
[0063] A subpixel-level centerline is formed using bicubic interpolation, and the formula is as follows:
[0064]
[0065] In the formula, At the target point The pixel grayscale value at that location; Corresponding to target points The integer part at the specified position, rounded to the left and up; , These are the offsets relative to the base pixel; , This is the index offset; for The grayscale value at that location; These are the weight coefficients of the cubic convolution kernel, used to calculate the contribution of each pixel to the interpolation point;
[0066] The fitted subpixel-level centerline is smoothed using the smoothing spline method; a smoothing spline function is defined. The subpixel laser stripe centerline is obtained by minimizing the functional of the following formula:
[0067]
[0068] In the formula, To ensure the fitting error Close to the observation point; Smoothing penalty is used to measure the curvature of a curve; This is a smoothing parameter, with a value ranging from 0.0003 to 0.0007.
[0069] Compared with the prior art, the present invention has the following advantages:
[0070] This invention achieves dynamic segmentation of laser stripe regions by constructing grayscale coefficients and adaptively generating differentiated thresholds. In low-light and low-contrast regions, the threshold is automatically lowered to enhance the connectivity and integrity of the laser stripes. In areas with strong reflection or noise interference, a reasonable threshold is maintained to avoid over-segmentation. Furthermore, a peak outlier discrimination mechanism is introduced to suppress abnormal peaks caused by reflective saturation, isolated bright spots, or random noise, reducing their destructive impact on threshold estimation and thus improving the stability and robustness of the algorithm under complex lighting and industrial site interference conditions. Based on the stripe skeleton extraction results, this invention combines a secondary positioning method with skeleton constraints, interpolation, and fitting methods to perform continuous and smoothing processing on the centerline. This results in a stable output of continuous, smooth, sub-pixel-level centerline results, providing more consistent data support for subsequent 3D reconstruction and dimensional measurement, and is suitable for online measurement and real-time application scenarios. Attached Figure Description
[0071] Figure 1 This is a flowchart of a laser stripe center extraction method based on grayscale coefficient binarization.
[0072] Figure 2 This is a schematic diagram of the image filtering results of a laser stripe center extraction method based on grayscale coefficient binarization.
[0073] Figure 3 This is a schematic diagram of the binarization result of the laser stripe center extraction method based on grayscale coefficient binarization.
[0074] Figure 4 This is a schematic diagram of the morphological processing results of a laser stripe center extraction method based on grayscale coefficient binarization.
[0075] Figure 5 This is a schematic diagram of the pixel eight-neighbor numbering method for the thinning method of laser stripe center extraction based on grayscale coefficient binarization.
[0076] Figure 6 This is a schematic diagram of the preliminary laser stripe center extraction result using the thinning method of the laser stripe center extraction method based on grayscale coefficient binarization.
[0077] Figure 7 This is a schematic diagram of the secondary localization result of the laser stripe center extraction method based on grayscale coefficient binarization.
[0078] Figure 8 This is a schematic diagram of the fitted smooth sub-pixel laser stripe center result of the laser stripe center extraction method based on grayscale coefficient binarization.
[0079] Figure 9 This is a comparison chart of threshold segmentation methods based on the laser stripe center extraction method using grayscale coefficient binarization.
[0080] Figure 10 A line graph comparing threshold segmentation methods based on the laser stripe center extraction method using grayscale coefficient binarization.
[0081] Figure 11 This is a schematic diagram of laser stripe center extraction for different shapes and exposure times based on a method for extracting the center of laser stripes using grayscale binarization. Detailed Implementation
[0082] To make the technical means, creative features, objectives and effects of this invention easy to understand, the following embodiments, in conjunction with the accompanying drawings, specifically illustrate the laser stripe center extraction method based on grayscale coefficient binarization of this invention.
[0083] This embodiment provides a method for extracting the center of laser stripes based on grayscale coefficient binarization, including the following steps:
[0084] Figure 1 This is a flowchart of a laser stripe center extraction method based on grayscale coefficient binarization.
[0085] Step 1: Acquire images using a line structured light camera, and improve the image quality of laser stripes using grayscale conversion and image filtering methods, including the following sub-steps:
[0086] Step 1.1: Adjust the positions of the line structured light camera, laser, and test object to ensure that the test object is within the field of view of the line structured light camera, and set the shooting parameters of the structured light camera until a clear image can be formed.
[0087] Step 1.2: Use a line structured light camera to collect data on the test piece. A laser line is emitted onto the surface of the test piece by a laser and the reflected light is captured.
[0088] In this embodiment, the entire data acquisition system includes:
[0089] Hardware equipment: Robot: JAKAZu series robot; Line structured light camera: Hikvision CH series CMOS industrial camera MV-CH120-60UM; Lens: Hikvision 16mm lens, model MVL-KF1624M-25MP; Laser: Zhuhai Maizhi 405nm, 100mw blue linear laser emitter, model AJHC540520L30; Computer: 24GB laptop; Workpiece testing platform, including the workpiece under test and flexible support.
[0090] Software environment: The compiled language is Python.
[0091] Specifically, when using a shooting platform built with a robot and a line structured light camera, the position of the test object is fixed according to the parameters of the line structured light camera. The line structured light camera is fixed on the robot through a mounting plate. The robot is controlled to move, find a clear position in the image, and capture the reflected laser stripes.
[0092] Figure 2 This is a schematic diagram of the image filtering results of a laser stripe center extraction method based on grayscale coefficient binarization.
[0093] Step 1.3: Perform grayscale processing on the acquired laser stripe image, the result is as follows. Figure 2 As shown.
[0094] Step 1.4: Perform median filtering and Gaussian filtering on the grayscale laser stripe image to remove noise and improve the quality of the laser stripe image.
[0095] Step 2: Segment the laser stripe image using a grayscale coefficient binarization method, and then process the segmented laser stripes using morphological methods. Specifically:
[0096] The OTSU method is used to calculate the threshold of laser stripes in the filtered image, and the global OTSU threshold is calculated. :
[0097]
[0098] In the formula, Foreground pixel ratio (less than a threshold) ); Background pixel percentage (greater than the threshold) ); The average gray level of the foreground pixels; This represents the average gray level of the background pixels.
[0099] By applying the statistical principles of grayscale coefficients and peak variability, the maximum grayscale value of each column is calculated by iterating through the threshold values of each column in the filtered laser stripe image. Compared with the average gray level , represented as:
[0100]
[0101]
[0102] In the formula, =1,2,.......,W; =1,2,...... ; The laser stripe image after image filtering is located at... The grayscale value at that location.
[0103] Calculate the baseline of the global column average grayscale threshold , represented as:
[0104]
[0105] Define the grayscale adjustment factor as , represented as:
[0106]
[0107] In the formula, Indicates the first Column grayscale relative to global column average grayscale threshold baseline The degree of deviation is used to proportionally amplify or reduce the reference grayscale value to adapt to the effects of uneven lighting. If If the value is greater than 1, it means that the gray level of this column is higher than the average gray level of the entire column, making it brighter; if... If <1, it means the gray level of this column is lower than the average gray level of the entire column, making it darker; if =1 indicates that the gray level of this column is consistent with the average gray level of the global columns.
[0108] Introducing peak variation coefficient As an adaptive threshold For reference, the specific steps are as follows:
[0109] Calculate the set of maximum gray values average with standard deviation ;
[0110]
[0111]
[0112] Define peak variation coefficient ;
[0113]
[0114] In the formula, This indicates the relative dispersion of the maximum grayscale values in each column, reflecting the consistency of the stripes.
[0115] Set judgment threshold :
[0116]
[0117] Calculate peak ratio :
[0118]
[0119] In the formula, This represents the maximum gray value in the stripes.
[0120] according to and Size selection of grayscale threshold :
[0121]
[0122] when If the maximum grayscale value is within the normal fluctuation range, it can be adjusted using the maximum grayscale threshold in this column in conjunction with the grayscale coefficient.
[0123] when If the value is too high, it indicates that there is a significant difference in this column. Adjust the average grayscale threshold and grayscale coefficient accordingly.
[0124] Based on the grayscale threshold determined above Calculate the binarization segmentation threshold , represented as:
[0125]
[0126] when When applying the global OTSU threshold ;when hour, An adaptive threshold is used to calculate the low-light column. Grayscale coefficient An upper bound is applied to the threshold to prevent it from becoming too large.
[0127] Binarization segmentation is performed, and the binarization segmentation result is obtained. Represented as:
[0128]
[0129] Normalization generates correction coefficients This method proportionally amplifies the grayscale of low-light areas while maintaining the original grayscale values of high-light areas, achieving a balance between addressing uneven illumination and suppressing noise interference. Furthermore, based on the peak variation coefficient... The maximum grayscale threshold and the average threshold used as a reference are dynamically switched to identify and suppress typical peaks and outlier noise.
[0130] Figure 3 This is a schematic diagram of the binarization result of the laser stripe center extraction method based on grayscale coefficient binarization. Figure 4 This is a schematic diagram of the morphological processing results of a laser stripe center extraction method based on grayscale coefficient binarization.
[0131] In summary, the above formula can be viewed as a one-dimensional statistical model constructed along the column direction of the image. The mean and standard deviation of the peak sequence formed by the maximum gray levels of each column describe the overall brightness level and its fluctuations, respectively. Peak variation coefficient A dimensionless relative dispersion index is given, while the normalized peak ratio is... Then depict the first Is the column a normal peak value or an abnormal deviation? Determine the threshold. Will and Combined, this forms a judgment that adaptively switches between the maximum peak value and the average peak value. Simultaneously, a global OTSU threshold is established. As an upper bound, the adaptive threshold should be kept from being too large. It is important to emphasize that the grayscale coefficient... Only participate in column threshold The calculation does not directly amplify the original grayscale, thus achieving a balance between enhancing weak stripe extraction and suppressing noise. This is achieved by thresholding each column. The pixels in this column are used as the segmentation threshold for binarization. Different thresholds are used for different columns, taking into account areas with darker gray values to avoid stripe breaks caused by a high global threshold. The segmentation result is as follows. Figure 3 As shown in the figure. For the binarized image, morphological processing using erosion and closing operations is applied to smooth the stripe edges, laying the foundation for subsequent centerline extraction. The morphological processing results are shown in the figure. Figure 4 As shown.
[0132] Step 3: The laser stripe skeleton is initially extracted using the Zhang-suan thinning method, and the sub-pixel-level center points of the laser stripes are extracted using a secondary positioning method based on skeleton constraints. Specifically:
[0133] Figure 5 This is a schematic diagram of the pixel eight-neighbor numbering method for the thinning method of laser stripe center extraction based on grayscale coefficient binarization.
[0134] When implementing the Zhang-suan thinning method, each foreground pixel is classified according to its role as an "internal point," "external point," or "skeleton endpoint" based on eight-neighbor information. This classification is then completed through two iterations to remove the interference, resulting in the laser stripe skeleton. This process effectively removes peripheral interference while preserving the connectivity of the original region. Let any foreground pixel in the image to be thinned be... The neighboring pixels are { , , }, neighborhood numbering as Figure 5 As shown.
[0135] The entire refinement process follows these steps:
[0136] Calculate two measures:
[0137]
[0138]
[0139] In the formula, This represents the number of neighboring foreground pixels, used to exclude isolated noise (M < 2) and points within the region M (> 6). Indicates the number of "background-foreground" transitions, only when In this case, deleting the center pixel is necessary to prevent the connected branches from being broken.
[0140] Figure 6 This is a schematic diagram of the preliminary laser stripe center extraction result using the thinning method of the laser stripe center extraction method based on grayscale coefficient binarization.
[0141] like And satisfy the following , , and If the condition is met, then mark it. Points to be deleted:
[0142]
[0143]
[0144]
[0145]
[0146] After the first iteration, the above calculation is repeated on the updated image for the second iteration. Pixels that meet the above conditions are marked as points to be deleted. After two iterations, all marks are deleted. If no new marks are added, the algorithm converges and outputs a single-pixel skeleton, as shown in the figure. Figure 6 As shown.
[0147] While thinning methods can compress the stripe area into a skeleton approximately the width of a single pixel, the thinning result may still retain a small number of misidentified skeleton pixels when there is weak contrast, reflective saturation, local noise, or preprocessing residue at the edges of the stripes. Examples of misidentified skeleton pixels include edge burrs and short branches. Figure 6 The rightmost edge burr is shown in the image.
[0148] To compensate for the limitations of the thinning algorithm in edge regions, the skeleton stripe image is first calculated column by column, as follows:
[0149]
[0150] In the formula, The image obtained from the skeleton has a pixel value of 0 or 1, where 0 represents the background and 1 represents the skeleton.
[0151] If set If not empty, then the center point of the column is... Defined as the arithmetic mean of the row coordinates of all skeleton pixels , represented as:
[0152] If set If the column is empty, skip it and do not generate a center point. After calculating all columns containing skeleton pixels, obtain the discrete point set:
[0153]
[0154] In the formula, For a finite number of columns, Index for integer columns, The center coordinates are obtained from the statistics of the skeleton column.
[0155] To avoid centerline shifts due to edge misjudgment, the center position is re-statistically located using binarized segmented stripes. Let the binarized laser stripe image be: Where 1 represents the laser stripe foreground and 0 represents the laser stripe background. For the x-th column, define the set of row coordinates of the foreground pixels in that column. for:
[0156]
[0157] Since binarized stripes may be affected by local noise or interference from adjacent structures, this method utilizes a coarse center in the skeleton to avoid introducing non-striped pixels across the entire column. Constructing a local constraint window , represented as:
[0158]
[0159] In the formula, The window width is half the width of the fringe, typically slightly larger than the half width of the fringe to ensure coverage of the effective fringe cross-section. Applying the window constraint to the fringe foreground set yields the effective set participating in the secondary localization. :
[0160]
[0161] like Then the sub-pixel center of that column is defined as the arithmetic mean of the effective foreground row coordinates:
[0162]
[0163] Otherwise, skip that column and do not generate a center point. After calculating for all valid columns, the final set of centerline points is obtained. , represented as:
[0164]
[0165] In the formula, This represents the number of valid columns retained after secondary positioning.
[0166] Figure 7 This is a schematic diagram of the secondary localization result of the laser stripe center extraction method based on grayscale coefficient binarization.
[0167] The final extraction result is as follows Figure 7 As shown.
[0168] Step 4: Fit the extracted sub-pixel-level center points using bicubic interpolation to form a sub-pixel-level center line, and then smooth the fitted sub-pixel-level center line using a smoothing spline method to obtain the sub-pixel laser stripe center line, specifically:
[0169] A subpixel-level centerline is formed using bicubic interpolation, and the formula is as follows:
[0170]
[0171] In the formula, At the target point The pixel grayscale value at that location; Corresponding to target points The integer part at the specified position, rounded to the left and up; , These are the offsets relative to the base pixel; , This is the index offset; for The grayscale value at that location; These are the weight coefficients of the cubic convolution kernel, used to calculate the contribution of each pixel to the interpolation point.
[0172] The convolution kernel weight coefficient function is:
[0173]
[0174] In the formula, The kernel is the independent variable, and the offset is the input. These are the convolution kernel parameters, typically =-0.5.
[0175] The fitted subpixel-level centerline is smoothed using the smoothing spline method; a smoothing spline function is defined. The minimum solution for the functional of the following formula is:
[0176]
[0177] In the formula, To ensure the fitting error Close to the observation point; Smoothing penalty is used to measure the curvature of a curve; The smoothing parameter is empirically set to 0.0005.
[0178] Figure 8 This is a schematic diagram of the fitted smooth sub-pixel laser stripe center result of the laser stripe center extraction method based on grayscale coefficient binarization.
[0179] The final fitting result is as follows Figure 8 As shown, the center line of the subpixel laser stripe is obtained.
[0180] In summary, by constructing grayscale coefficients and adaptively generating differentiated thresholds, dynamic segmentation of the laser stripe region is achieved. In low-light and low-contrast regions, the threshold can be automatically reduced to enhance the connectivity and integrity of the laser stripes, while in areas with strong reflection or noise interference, a reasonable threshold is maintained to avoid over-segmentation. Furthermore, a peak outlier discrimination mechanism is introduced to suppress abnormal peaks caused by reflective saturation, isolated bright spots, or random noise, weakening their destructive impact on threshold estimation and thus improving the stability and robustness of the algorithm under complex lighting and industrial site interference conditions. Based on the stripe skeleton extraction results, combined with the skeleton constraint secondary positioning method, interpolation, and fitting methods, the centerline is made continuous and smooth, stably outputting continuous and smooth sub-pixel-level centerline results. This provides more consistent data support for subsequent 3D reconstruction and dimensional measurement, and is suitable for online measurement and real-time application scenarios.
[0181] This embodiment also provides a computer device suitable for laser stripe center extraction methods based on grayscale binarization, including a memory and a processor. The memory stores computer-executable instructions, and the processor executes these instructions to implement the laser stripe center extraction method based on grayscale binarization as described in the above embodiment.
[0182] The computer device can be a terminal, comprising a processor, memory, communication interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, carrier networks, NFC (Near Field Communication), or other technologies. The display screen can be an LCD screen or an e-ink screen. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad on the computer device's casing, or an external keyboard, touchpad, or mouse.
[0183] This embodiment also provides a storage medium storing a computer program that, when executed by a processor, implements the laser stripe center extraction method based on grayscale coefficient binarization as proposed in the above embodiments.
[0184] The storage medium proposed in this embodiment and the data storage method proposed in the above embodiments belong to the same inventive concept. Technical details not described in detail in this embodiment can be found in the above embodiments, and this embodiment has the same beneficial effects as the above embodiments.
[0185] To verify the beneficial effects of the present invention, the laser stripe center extraction method based on grayscale coefficient binarization of the present invention was scientifically demonstrated through economic benefit calculations and simulation experiments.
[0186] Three binarization segmentation methods—the extreme value method, the Otsu method, and the local adaptive thresholding method—were selected and compared with the method presented in this paper.
[0187] Figure 9 This is a comparison chart of threshold segmentation methods based on the laser stripe center extraction method using grayscale coefficient binarization. Figure 10 A line graph comparing threshold segmentation methods based on the laser stripe center extraction method using grayscale coefficient binarization.
[0188] To verify the effectiveness of image preprocessing in the method of this invention on laser stripes with uneven brightness distribution, the following was performed: Figure 2 The original laser stripe image was subjected to median filtering and Gaussian filtering, and then processed using the extremum method, Otsu's method, local adaptive thresholding method, and our proposed method, respectively. The results of the four different binarization segmentation methods are shown below. Figure 9 As shown. To more intuitively display the comparison of the four different binarization segmentation methods, a line graph comparing the four thresholds with the maximum grayscale value in each column (represented by a solid green line) is output for the filtered image, as shown. Figure 10 As shown.
[0189] Depend on Figure 10 As can be seen, the orange discontinuous lines represent the extreme value threshold, which is based on 90% of the global maximum gray value for threshold segmentation, making it difficult to retain laser stripes with low gray values. The Otsu method threshold is represented by the blue dashed line, which is affected by the global gray value, leading to an excessively large threshold selection and easy deletion of key parts with low gray values at corners. The local adaptive threshold method is represented by the purple solid line. For images with insufficient gray-level contrast, if the gray values inside the laser stripes are close to the background, the local threshold may not segment correctly, requiring manual setting of the neighborhood size and the constant C. Inappropriate selection may result in over-extraction. The segmentation results of the method in this paper are represented by the red solid line. Considering the different gray value distributions of the light stripes, the threshold is adaptively adjusted based on the gray coefficient of each column. The segmentation threshold is reduced for areas with low gray values, avoiding the drawbacks of the traditional Otsu method using a fixed threshold segmentation. Therefore, it can completely segment the laser stripes with better results.
[0190] Figure 11 This is a schematic diagram of laser stripe center extraction for different shapes and exposure times based on a method for extracting the center of laser stripes using grayscale binarization.
[0191] To verify the algorithm's versatility and stability, centerline extraction experiments were conducted using laser stripe images of four shapes—straight lines, broken lines, arcs, and a combination of arcs and straight lines—under low, medium, and high brightness conditions. The results are as follows: Figure 11 As shown.
[0192] To verify the accuracy of the laser stripe center extraction method based on grayscale coefficient binarization, experiments were conducted to compare it with the grayscale centroid method, the improved grayscale centroid method, and the Steger method. A laser stripe image with a height of 960 pixels and a width of 1280 pixels was generated by computer. The laser stripe line width was 3 pixels, the center coordinate was 480, and the grayscale values of the laser stripe cross-section exhibited a Gaussian distribution. Gaussian noise with a standard deviation of σ (0.1~1, step size 0.1) and salt-and-pepper noise with a noise probability of 0.05 were added. The root mean square error (RMSE) and running time of the four algorithms for extracting the laser stripe center from the standard center are shown in Table 1. All methods used the image preprocessing steps described in this paper during the experiments.
[0193] Table 1 Comparison of extraction results from different algorithms
[0194]
[0195] As shown in Table 1, the extraction error of the gray-scale centroid method gradually increases with the increase of the noise standard deviation, reaching an average RMSE of 0.124 pixels. Although the average running time is 0.103 s, it is extremely sensitive to noise and has the worst accuracy. The improved gray-scale centroid method has smaller error fluctuations, with an average RMSE of about 0.096 pixels and an average running time of about 0.114 s. Compared with the gray-scale centroid method, it has improved accuracy and a similar running time. The Steger method shows good stability, with an average RMSE of about 0.023 pixels, but the average running time is about 0.361 s, which is nearly three times that of the first two methods. Although the running time of the proposed method is about 0.03 s slower than the first two methods, it maintains high stability under different standard deviations, with an average RMSE of about 0.016 pixels, the best extraction accuracy, and a running time of 0.147 s still meets the requirements of real-time online measurement. It should be noted that the data in Table 1 are based on simulation results of Gaussian noise superposition only once for each noise level. Since synthetic images are generated by adding random noise, the reported error itself contains a certain degree of random fluctuation.
[0196] The role and effect of the embodiments
[0197] The laser stripe center extraction method based on grayscale coefficient binarization according to the present invention has the following beneficial effects:
[0198] In step 2 of this invention, a binarization method based on grayscale coefficients is proposed. By calculating the maximum and average grayscale values column by column, a global column average grayscale threshold baseline is constructed. And introduce grayscale coefficient This method enables dynamic adjustment of the segmentation threshold for each column. In low-light and low-contrast regions, the threshold is automatically lowered to enhance the connectivity and integrity of the laser stripes, while in areas with strong reflection or noise interference, a reasonable threshold is maintained to avoid over-segmentation. This method overcomes the shortcomings of traditional global threshold segmentation (such as the Otsu method) which is prone to over-segmentation or stripe breakage under uneven illumination conditions, significantly improving the integrity and connectivity of laser stripe segmentation.
[0199] This invention further introduces a peak outlier detection mechanism, namely, the peak variation coefficient. As an adaptive threshold By calculating the mean and standard deviation of the maximum grayscale values in each column, the system dynamically determines and suppresses any abnormal peaks caused by reflective saturation, isolated bright spots, or random noise, thereby reducing their destructive impact on threshold estimation. This mechanism improves the stability and robustness of the method under complex lighting and industrial site interference conditions.
[0200] In step 3 of this invention, based on the laser stripe skeleton extracted by the thinning method, binarized stripe information is introduced for secondary localization. A local constraint window is constructed to limit the candidate pixel range, avoiding the influence of edge burrs or noise interference on center localization. This method achieves accurate sub-pixel-level center point extraction while maintaining skeleton connectivity, overcoming the shortcomings of traditional thinning methods that are prone to offset in edge regions, and improving the positioning accuracy and continuity of the center line.
[0201] In step 4 of this invention, bicubic interpolation is used to fit the sub-pixel-level center point, and smoothing spline method is combined to smooth the fitted sub-pixel-level center line, effectively suppressing local jitter and noise disturbance, and finally outputting a continuous and smooth sub-pixel-level laser stripe center line. This processing method provides high-quality data support for subsequent 3D reconstruction and dimensional measurement, meeting the dual requirements of real-time performance and stability for online measurement.
[0202] Experimental results show that the method of this invention can stably extract complete and continuous laser stripe center lines under different noise levels, different laser stripe shapes (straight lines, broken lines, arcs, etc.), and different exposure conditions. Compared with existing methods such as the extreme value method, Otsu's method, local adaptive thresholding method, and Steger method, the method of this invention exhibits superior positioning accuracy and robustness, and its processing efficiency meets the requirements of real-time measurement. It is suitable for various engineering applications such as intelligent manufacturing, industrial inspection, and weld seam tracking.
[0203] Those skilled in the art should understand that this invention is not limited to the above embodiments. The embodiments and descriptions in the specification are merely illustrative of the principles of the invention. Various changes and modifications can be made to this invention without departing from its spirit and scope, and all such changes and modifications fall within the scope of the invention as claimed. The scope of protection of this invention is defined by the appended claims and their equivalents.
Claims
1. A method for extracting the center of laser stripes based on grayscale coefficient binarization, characterized in that, Includes the following steps: Step 1: Acquire images using a line structured light camera, and improve the quality of the laser stripe image using grayscale conversion and image filtering methods; Step 2: Segment the laser stripe image using a grayscale coefficient binarization method, and process the segmented laser stripes using morphological methods; Step 3: The laser stripe skeleton is initially extracted using the Zhang-suan thinning method, and the sub-pixel-level center point of the laser stripe is extracted using a secondary positioning method based on skeleton constraints. Step 4: Fit the extracted sub-pixel-level center points using bicubic interpolation to form a sub-pixel-level center line, and then smooth the fitted sub-pixel-level center line using a smoothing spline method to obtain the sub-pixel laser stripe center line. In step 2, segmenting the laser stripe image using a grayscale coefficient binarization method and processing the segmented laser stripes using morphological methods includes the following steps: The laser stripe image is segmented using a grayscale coefficient-based binarization method; the segmented laser stripes are then processed using erosion and closing operations. Step 2, segmenting the laser stripe image using a grayscale coefficient binarization method, includes the following steps: The OTSU method is used to calculate the threshold of laser stripes in the filtered image, and the global OTSU threshold is calculated. : , In the formula, The proportion of foreground pixels is less than the threshold. ; The percentage of background pixels is greater than the threshold. ; The average gray level of the foreground pixels; The average gray level of the background pixels. Iterate through the threshold values of each column in the filtered laser stripe image and calculate the maximum grayscale value for each column. Compared with the average gray level , represented as: , , In the formula, =1,2,.......,W; =1,2,...... ; The laser stripe image after image filtering is located at... grayscale value at that location Calculate the baseline of the global column average grayscale threshold , represented as: , Define the grayscale adjustment factor as , represented as: , In the formula, Indicates the first Column grayscale relative to global column average grayscale threshold baseline The degree of deviation is used to proportionally amplify or reduce the reference grayscale value to adapt to the effects of uneven lighting; if If the value is greater than 1, it means that the gray level of this column is higher than the average gray level of the entire column, making it brighter; if... If <1, it means the gray level of this column is lower than the average gray level of the entire column, making it darker; if =1 indicates that the gray level of this column is consistent with the average gray level of the entire column; Introducing peak variation coefficient As an adaptive threshold refer to; Calculate the binarization segmentation threshold , represented as: , when When using the global OTSU threshold ;when hour, An adaptive threshold is used to calculate the low-light column. Grayscale coefficient An upper bound is applied to the threshold to prevent it from becoming too large. Binarization segmentation is performed, and the binarization segmentation result is obtained. Represented as: 。 2. The laser stripe center extraction method based on grayscale coefficient binarization according to claim 1, characterized in that: in, Step 1 includes the following sub-steps: Step 1.1: Adjust the positions of the line structured light camera, laser, and test piece, and set the shooting parameters of the structured light camera; Step 1.2: Use a line structured light camera to collect data on the test piece. A laser line is emitted onto the surface of the test piece by a laser and the reflected light is captured. Step 1.3: Perform grayscale processing on the acquired laser stripe image; Step 1.4: Perform median filtering and Gaussian filtering on the grayscale laser stripe image to remove noise and improve the quality of the laser stripe image.
3. The laser stripe center extraction method based on grayscale coefficient binarization according to claim 1, characterized in that: in, Step 3, which involves the preliminary extraction of the laser stripe skeleton using the Zhang-suan refinement method, includes the following steps: The Zhang-suan thinning method relies on eight-neighbor information to classify each foreground pixel according to its role as an "internal point", "external point" or "skeleton endpoint", and then completes the removal through two rounds of iteration to obtain the laser stripe skeleton.
4. The laser stripe center extraction method based on grayscale coefficient binarization according to claim 3, Its features are: in, In step 3, the method for obtaining the laser stripe skeleton is as follows: Let any foreground pixel in the image to be refined be... The neighboring pixels are { , , }; Calculate two measures: , , In the formula, This represents the number of neighboring foreground pixels, used to exclude isolated noise (M < 2) and points within the region M (> 6). Indicates the number of "background-foreground" transitions, only when In this case, deleting the center pixel is necessary to prevent the connected branches from being broken; like And satisfy the following , , and If the condition is met, then mark it. Points to be deleted: , , , , After completing the first iteration, repeat the above calculation on the updated image to perform the second iteration. Pixels that meet the above conditions are marked as points to be deleted. After two iterations, all marks are deleted. If no new markers are added, the algorithm converges and outputs a single-pixel skeleton.
5. The laser stripe center extraction method based on grayscale coefficient binarization according to claim 1, characterized in that: in, Step 3, extracting the sub-pixel-level center point of the laser stripe using a skeleton-constrained secondary positioning method, includes the following steps: The calculation is performed column-wise on the skeleton stripe image, and is represented as follows: , In the formula, The image obtained from the skeleton has a pixel value of 0 or 1, where 0 represents the background and 1 represents the skeleton. If set If not empty, then the center point of the column is... Defined as the arithmetic mean of the row coordinates of all skeleton pixels , represented as: , If set If the column is empty, skip it and do not generate a center point. After calculating all columns containing skeleton pixels, obtain the discrete point set: , In the formula, For a finite number of columns, Index for integer columns, The center coordinates are obtained from the statistics of the skeleton column; Binarized stripes are introduced to perform secondary localization of the center position. Let the laser stripe image after binarization segmentation be: Where 1 represents the laser stripe foreground and 0 represents the laser stripe background; for the x-th column, define the set of row coordinates of the stripe foreground pixels in that column. for: , Utilizing the coarse center of the skeleton Constructing a local constraint window , represented as: , In the formula, The window width is set to half the width of the fringe, slightly larger than the half width of the fringe to ensure coverage of the effective cross section of the fringe; the window constraint is applied to the fringe foreground set to obtain the effective set participating in the secondary positioning. : , like Then the sub-pixel center of that column is defined as the arithmetic mean of the effective foreground row coordinates: , Otherwise, skip that column, do not generate a center point, and calculate for all valid columns to obtain the final set of centerline points. , represented as: , In the formula, This represents the number of valid columns retained after secondary positioning.
6. The laser stripe center extraction method based on grayscale coefficient binarization according to claim 1, characterized in that: in, In step 4, the extracted sub-pixel-level center points are fitted using bicubic interpolation to form a sub-pixel-level center line, and the fitted sub-pixel-level center line is smoothed using a smoothing spline method to obtain the sub-pixel laser stripe center line. This includes the following steps: A subpixel-level centerline is formed using bicubic interpolation, and the formula is as follows: , In the formula, At the target point The pixel grayscale value at that location; Corresponding to target points The integer part at the specified position, rounded to the left and up; , These are the offsets relative to the base pixel; , This is the index offset; for The grayscale value at that location; These are the weight coefficients of the cubic convolution kernel, used to calculate the contribution of each pixel to the interpolation point; The fitted subpixel-level centerline is smoothed using the smoothing spline method; a smoothing spline function is defined. The subpixel laser stripe centerline is obtained by minimizing the functional of the following formula: , In the formula, To ensure the fitting error Minimizes the deviation from the observation point; Smoothing penalty is used to measure the curvature of a curve; This is a smoothing parameter, with a value ranging from 0.0003 to 0.0007.