Laser stripe centerline extraction method based on adaptive exposure and pixel neighborhood
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2026-08-11
AI Technical Summary
[0006]综上所述,第一,目前的主流方法一方面仅考虑单个像素的灰度,容易受到异常值的影响;第二,现有的激光条纹中心线提取方法在高质量图像的采集方法上考虑不足,手动选择相机曝光人因误差大、效率较低、难以应对非结构化场景;第三,图像预处理是条纹中心线提取的首要步骤,当前的方法准确性和鲁棒性也存在不足
[0057]本申请不仅在图像采集层面采用自适应曝光调控方法,提高了线激光图像采集的质量,而且通过基于像素邻域信息的线激光细化方法,提高了激光条纹中心线的提取精度,更重要是从图像获取和图像处理层面综合优化,提高了激光条纹中心线提取的提取准确性和鲁棒性。
Smart Images

Figure CN119919477B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of optical three-dimensional measurement technology, and in particular relates to a method for extracting the center line of laser stripes based on adaptive exposure and pixel neighborhood. Background Technology
[0002] In industrial sectors such as automotive, aerospace, and nuclear power, optical 3D measurement is widely used for critical dimension inspection and morphology measurement of components. This method utilizes line lasers to construct active features, analyzes laser stripe images captured by a camera, and then reconstructs the 3D morphology of the component for further dimensional measurement and analysis. Line laser 3D measurement technology offers advantages such as non-contact operation, high precision, and high efficiency, making it irreplaceable in product manufacturing, quality assessment, and in-service inspection. Extraction of the laser stripe centerline is one of the most critical techniques. However, due to the influence of specific environments and operating conditions, laser stripe images may exhibit excessive noise, uneven brightness, and laser stripe breaks. Therefore, a robust, high-precision, and efficient laser stripe centerline extraction method can significantly improve the measurement quality of components.
[0003] Currently, the mainstream methods for extracting the center line of laser stripes include traditional methods and deep learning-based methods.
[0004] Traditional methods include the extremum method, the gray-level centroid method, the directional template method, and the Steger method. The extremum method and the gray-level centroid method extract the stripe centerline by analyzing pixel gradient changes and gray-level distribution, respectively. These methods have high computational efficiency but low extraction accuracy and are sensitive to stripe orientation. The directional template method pre-creates templates adapted to different orientations and then performs correlation analysis, effectively solving the problem of sensitivity to changes in the laser stripe normal. However, it suffers from limitations in template selection and low accuracy. The Steger algorithm analyzes the image to obtain the Hessian matrix, acquires the orientation information at each point of the stripe, and then finds the point of minimum gradient along the normal. This method can adapt to cases with large stripe curvature, offering higher accuracy and wider adaptability. However, because it requires calculating the Hessian matrix of the entire image, its extraction efficiency is relatively low.
[0005] The key to deep learning-based extraction methods lies in the preparation of training data. High-precision centerline extraction results need to be used as training and testing sets in advance. The weight information of the convolution kernel is obtained by training the global image or region of interest for actual extraction. This type of method has not yet been maturely applied in this field, and its stability, accuracy and efficiency need to be verified.
[0006] In summary, firstly, current mainstream methods only consider the grayscale of a single pixel, making them susceptible to outliers; secondly, existing laser stripe centerline extraction methods are insufficient in terms of high-quality image acquisition, and manual camera exposure selection suffers from large human-caused errors, low efficiency, and difficulty in handling unstructured scenes; thirdly, image preprocessing is the primary step in stripe centerline extraction, and current methods also have shortcomings in accuracy and robustness. Summary of the Invention
[0007] The purpose of this application is to provide a method for extracting the center line of laser stripes based on adaptive exposure and pixel neighborhood, thereby overcoming the shortcomings of the prior art and ensuring the accuracy and robustness of the adaptive extraction of the center line of laser stripes.
[0008] To achieve the above objectives, this application provides the following technical solution:
[0009] A method for extracting the center line of laser stripes based on adaptive exposure and pixel neighborhood includes:
[0010] S1. The camera acquires a stripe image at the initial exposure time, and the acquired image is preprocessed.
[0011] S2. For the stripe image after contour extraction in S1, calculate the adaptive exposure time based on stripe width and grayscale cost, and repeat S1 with the adaptive exposure time to obtain the optimal laser stripe image.
[0012] S3. For the optimal laser stripe image obtained in S2, refine the stripe image;
[0013] S4. Based on the refined stripe image obtained in S3, extract the center line of the laser stripes.
[0014] According to one embodiment of this application, S1 includes stripe image adaptive binarization and stripe contour extraction.
[0015] According to one embodiment of this application, the image adaptive binarization step includes:
[0016] Divide the image into a grid;
[0017] The OTSU adaptive binarization algorithm is applied to each block to adapt to uneven lighting and background in different areas.
[0018] According to one embodiment of this application, the stripe contour extraction step includes:
[0019] Connected component extraction is performed on the binarized image to extract the contours of all connected components containing stripes and other noise.
[0020] The coarsely extracted contours are filtered using contour area and aspect ratio of the smallest envelope rectangle to obtain all stripe contours and remove noise areas.
[0021] According to one embodiment of this application, S2 includes:
[0022] S2.1: Calculate the cost of the striped image after preliminary preprocessing;
[0023] S2.2: Iteratively update the exposure value based on minimizing the cost.
[0024] According to one embodiment of this application, the cost function for adaptive exposure control is expressed in the following form:
[0025]
[0026]
[0027] In the formula, C(S) is the cost value corresponding to the set S of all laser stripe pixels in the image. k S is a subset of laser stripe pixels. k The corresponding cost is determined by the width cost C. h (S k ) and grayscale cost C g (S k The weighted fusion is composed of λ, where λ is the weight coefficient of the two, and α(p) ij ) represents the width cost adaptive weighting factor, β(p) ij h(p) is the adaptive weighting factor for grayscale cost. ij ) represents pixel p ij The corresponding stripe width at point g(p) ij ) represents pixel p ij The corresponding pixel grayscale value, For p ij The middle column of the row of pixels, |·| is the absolute value, max(·) is the maximum value, h0 is the reference width, and g0 is the gray level. The adaptive weighting factor α(p) is... ij ), β(p ij This reflects the differences in width and grayscale distribution of line laser stripes. Considering that if a line laser is projected onto a curved surface, the stripe width varies with the number of pixels, the weight α(p) for pixels with rapidly changing stripe widths is adjusted accordingly. ij The smaller the value of β(p), the more significant the change in grayscale. Furthermore, considering that stripes typically consist of a central and high-brightness region and gradient regions on both sides, the closer the stripes are to the pixels on either side, the greater their weight β(p) becomes due to the abrupt change in grayscale. ij It will also decrease.
[0028] According to one embodiment of this application, S2.2 includes:
[0029] Given an upper and lower limit of an exposure range (e min ,e max ), using equal step size δ=(e max -e min The cost is calculated within the exposure range using the method of ) / 20, and the exposure value is updated until the exposure value that minimizes the cost is found.
[0030] The neighborhood of the exposure value (e i -δ,e i A random search is performed within the range +δ). An exposure value is randomly generated within this neighborhood. If the new exposure value is smaller than the current exposure value, the new exposure value is set as the current exposure value, and the neighborhood is updated to half the original neighborhood. This process is repeated multiple times until the change in exposure value e is reached. i-1 -e i <ε;
[0031] The final stable exposure value is selected as the exposure value used for acquiring line laser stripe images, thus achieving adaptive exposure control.
[0032] According to one embodiment of this application, morphological operations are employed in step S3. First, an erosion operation is performed on the stripe region to remove fine noise and burrs. Then, a dilation operation is performed on the stripe region to coarsen the stripe target, restoring its original size and smoothing the boundary region. A mask is generated based on the extracted stripe contour. The mask ensures that when extracting the center line, the pixel grayscale inside the contour is the original grayscale, while the pixel grayscale outside the mask is set to 0. Using the extracted stripe region as the mask, Gaussian filtering is applied to the original pixels covered by the mask.
[0033] According to one embodiment of this application, in step S3, the regions of interest for the stripes are segmented. For the selected stripe contours, their smallest envelope rectangle is taken as the region of interest, and all regions of interest are segmented from an image.
[0034] According to one embodiment of this application, in S4, the coarsely extracted grayscale centroid coordinates of the laser stripe are calculated using all points within the neighborhood of a single point. The calculation formula is as follows:
[0035]
[0036] In the formula, w0 is the width of the neighborhood, and h0 is the height of the neighborhood. To round down, g(i,j) is the pixel grayscale value of the point in the i-th row and j-th column of the image, u i Let x be the x-coordinate of the center point of the i-th row of the laser stripe.
[0037] According to one embodiment of this application, the fringe normal calculation includes:
[0038] The normal at each point is calculated using the coarsely extracted initial neighborhood gray-level centroid set Ω1;
[0039] The normal at each point is calculated from the three adjacent points, where the normal at point i is P. i Normal n at the location i By P i-1 ,P i ,P i+1 The calculations for the three points are as follows:
[0040] n i =k i / ||k i ||
[0041]
[0042] i = 2, 3, 4, ..., n-1
[0043] In the formula, k i Let P be the i-th point i Curvature at that point;
[0044] The first point P1 and the last point P n The normal directions at each location are:
[0045] n1=(-τ 1y ,τ 1x )
[0046] n n =(-τ) ny ,τ nx )
[0047] In the formula, τ n =(τ nx ,τ ny ) and τ1=(τ 1x ,τ 1y Let ) represent the tangent at the two points, and the calculation formula is as follows:
[0048]
[0049]
[0050] Find the normals of all points in the initial neighborhood gray-level centroid set extracted by coarse extraction, denoted as N1={n1,n2,n3,...,n n}
[0051] According to one embodiment of this application, after coarse extraction and normal calculation, the neighborhood gray-level centroid is refined along the normal direction, and the neighborhood information of a point is used to replace the single-point information. Let the centroid of the i-th point P be... i Normal n at the location iTake a total of m points p1(x1,y1), p2(x2,y2), ..., p m (x m ,y m If P, then i grayscale center of gravity Q i (q ix ,q iy ) Calculated using the following formula:
[0052]
[0053]
[0054] In the formula, w0 is the width of the neighborhood, and h0 is the height of the neighborhood. To round down, g(y) i ,x i Let p be a point. i The pixel grayscale value;
[0055] The centroid of the refined neighborhood grayscale of the laser stripe is calculated and denoted as Ω2={Q1,Q2,Q3,...,Q n}
[0056] Compared with existing technologies, the laser stripe centerline extraction method based on adaptive exposure and pixel neighborhood provided in this application has the following advantages:
[0057] This application not only adopts an adaptive exposure control method at the image acquisition level to improve the quality of line laser image acquisition, but also improves the extraction accuracy of the laser stripe center line through a line laser thinning method based on pixel neighborhood information. More importantly, it comprehensively optimizes the image acquisition and image processing levels to improve the extraction accuracy and robustness of the laser stripe center line.
[0058] This application proposes an adaptive exposure control method for online laser stripe image acquisition. It constructs a cost function that fuses width cost and grayscale cost, and provides exposure update methods that fuse equal-step search and random search. This avoids the disadvantages of large human error and low efficiency in manually setting exposure, and obtains high-quality original images of line laser stripes.
[0059] This application proposes a laser stripe centerline extraction algorithm that comprehensively considers pixel neighborhood information, stripe energy information, and stripe normal information. It uses a sliding window to sample the neighborhood of a single pixel, fully utilizing the neighborhood grayscale information, and performs secondary extraction along the normal direction, ensuring efficiency while improving extraction accuracy.
[0060] In this application, the image processing is divided into two steps: image preprocessing and stripe image thinning. The former is embedded in the exposure adaptive control module, and the latter is embedded in the center line extraction module. A laser stripe image processing method considering block binarization, stripe contour adaptive screening, morphological filtering, etc., is proposed to ensure the accuracy and robustness of stripe center line extraction. Attached Figure Description
[0061] To more clearly illustrate the technical solution of this application, the accompanying drawings used in the technical description will be briefly introduced below.
[0062] Figure 1 A flowchart of the laser stripe centerline extraction method based on adaptive exposure and pixel neighborhood provided in this application;
[0063] Figure 2 This is a schematic diagram of the overall algorithm flow provided for an embodiment of this application;
[0064] Figure 3 This is a schematic diagram illustrating the binarized effect provided in an embodiment of this application.
[0065] Figure 4 This is a schematic diagram illustrating the effect of morphological operations provided in the embodiments of this application;
[0066] Figure 5 This is an example diagram showing the results before connected component filtering provided in an embodiment of this application;
[0067] Figure 6 Example diagram of the results after connected component filtering provided in the embodiments of this application;
[0068] Figure 7 This is a schematic diagram illustrating the effect of adaptive exposure control provided in an embodiment of this application;
[0069] Figure 8 A schematic diagram of the laser stripe centerline extraction method provided in the embodiments of this application;
[0070] Figure 9 An image showing the extraction effect of the center line of the laser stripe provided in an embodiment of this application. Detailed Implementation
[0071] The following detailed description provides further details on specific implementation methods.
[0072] like Figure 1 As shown, this application provides a method for extracting the center line of laser stripes based on adaptive exposure and pixel neighborhood, including:
[0073] S1: The camera acquires a stripe image at the initial exposure time, and the acquired image is preprocessed;
[0074] S2: For the stripe image after contour extraction in S1, calculate the adaptive exposure time based on stripe width and grayscale cost, and repeat S1 with the adaptive exposure time to obtain the optimal laser stripe image; taking vertically distributed stripes as an example, the optimal laser stripe image is: the width of the bright area in the middle (grayscale value 255) is about 3 pixels, and the grayscale of the pixels on both sides is gradually changing, corresponding to the reference grayscale and reference width respectively.
[0075] S3: Refine the stripe image based on the optimal laser stripe image obtained in S2;
[0076] S4: Based on the refined stripe image obtained in S3, the center line of the laser stripe is extracted using the neighborhood-based secondary gray-level centroid method, taking into account pixel neighborhood information, stripe energy information and stripe normal information.
[0077] In S1, the preprocessing of the acquired stripe image includes adaptive image binarization and stripe contour extraction.
[0078] Specifically, the image adaptive binarization step includes:
[0079] Divide the image into a grid;
[0080] The OTSU adaptive binarization algorithm is applied to each block separately, collectively referred to as the block OTSU algorithm, to adapt to uneven lighting and background in different regions.
[0081] Specifically, the stripe contour extraction steps include:
[0082] Connected component extraction is performed on the binarized image to extract the contours of all connected components containing stripes and other noise.
[0083] The coarsely extracted contours are filtered using contour area and aspect ratio of the smallest envelope rectangle to obtain all stripe contours and remove noise areas.
[0084] In S2, adaptive exposure calculation includes the following two steps:
[0085] S2.1: Calculate the cost of the striped image after preliminary preprocessing;
[0086] S2.2: Iteratively update the exposure value based on minimizing the cost.
[0087] In S2.1, the cost calculation of adaptive exposure control is a comprehensive cost calculation that considers both stripe width and grayscale. The core of the grayscale centroid method is to utilize the energy distribution of the stripes, and energy is reflected in the grayscale value in the image. Therefore, calculating the grayscale cost is part of the comprehensive cost. Stripe width is also an important indicator. If the stripe width is too small, the grayscale gradient will be too extreme. If the stripe width is too wide, the proportion of high-energy pixels will be too high, and the grayscale change will not be obvious. Both will deteriorate the extraction of the laser stripe center line.
[0088] Taking the longitudinal distribution of laser stripes as an example (a similar cost function can be derived from the transverse distribution of stripes), the cost function for adaptive exposure control can be expressed as follows:
[0089]
[0090]
[0091] In the formula, C(S) is the cost value corresponding to the set S of all laser stripe pixels in the image. k S is a subset of laser stripe pixels. k The corresponding cost is determined by the width cost C. h (S k ) and grayscale cost C g (S k The weighted fusion is used to construct the weighted coefficients, where λ is the weighting coefficient for both. Considering the anisotropy of the width with respect to the coordinates and the grayscale distribution of the fringes when projected onto the curved surface, adaptive weighting factors α(p) are constructed for the width cost and grayscale cost, respectively. ij ) and β(p ij It corresponds to pixel p in the i-th row and j-th column. ij To accommodate variations in width and grayscale. h(p) ij ) and g(p ij ) represent pixel p respectively ij The corresponding stripe width and pixel grayscale value. p ij The middle column of the row of pixels, |·| represents the absolute value, max(·) represents the maximum value, h0 and g0 are the reference width and grayscale. The adaptive weighting factor α(p ij ), β(p ij This reflects the differences in width and grayscale distribution of line laser stripes. Considering that if a line laser is projected onto a curved surface, the stripe width varies with the number of pixels, the weight α(p) for pixels with rapidly changing stripe widths is adjusted accordingly. ij The smaller the value, the better. Furthermore, considering that stripes typically consist of a central and high-brightness area and gradient areas on both sides, the closer the stripes are to the pixels on either side, the greater their weight β(p) becomes due to the abrupt change in grayscale. ijThe smaller the value, the better. Based on this, the comprehensive cost corresponding to the linear laser stripe image can be calculated, providing a basis for the iterative update of the exposure value.
[0092] In S2.2, the iterative update of adaptive exposure control first gives an upper and lower limit (e) of the exposure range. min ,e max First, use equal step size δ = (e max -e min The cost is calculated within the exposure range using the method of ) / 20, and the exposure value is updated until the exposure value that minimizes the cost is found. Within the neighborhood of that exposure value (e... i -δ,e i A random search is performed within the range +δ). An exposure value is randomly generated within this neighborhood. If the new exposure value is smaller than the current exposure value, the new exposure value is set as the current exposure value, and the neighborhood is updated to half the original neighborhood. This process is repeated multiple times until the change in exposure value e is reached. i-1 -e i <ε. The final stabilized exposure value is selected as the exposure value used for acquiring the line laser stripe image, achieving adaptive exposure control.
[0093] In S3, stripe image thinning includes stripe mask generation, region of interest segmentation, morphological operations, and Gaussian filtering.
[0094] In S3, mask generation involves generating a mask from the extracted stripe contours to provide pixel regions for subsequent laser stripe centerline extraction. The mask ensures that subsequent laser stripe extraction only considers pixels inside the mask, while pixels outside the mask are set to 0.
[0095] In S3, the segmentation of the stripe region of interest (ROI) is performed by taking the smallest envelope rectangle of the selected stripe contour as the ROI and segmenting all ROIs from an image to prepare for subsequent centerline extraction.
[0096] In S3, the image morphological operations employ an opening operation. First, an erosion operation is performed on the stripe region to remove minor noise and burrs. Then, a dilation operation is performed on the stripe region to coarsen the target stripes, restoring their original size and smoothing the boundaries. Finally, a Gaussian filter is applied to the stripe image, using the extracted stripe region as a mask to apply Gaussian filtering to the original pixels covered by the mask.
[0097] In S4, a neighborhood-based secondary gray-level centroid method is used to extract the center line of the laser stripes, simultaneously considering pixel neighborhood information, stripe energy information, and stripe normal information. For pixel sampling, a sliding window is used to sample the neighborhood of each pixel, fully utilizing all pixels within the neighborhood. Since the energy distribution of the stripes is reflected in the gray-level distribution, the gray-level centroid method is still used. Extracting the gray-level centroid alone can only be done along the horizontal or vertical direction. Based on the initially extracted gray-level centroid point set, the gray-level centroid points are further refined along the normal of each point to improve extraction accuracy.
[0098] The technical solution of this application abandons the traditional idea of sampling single-point grayscale, and instead uses a sliding window to sample the neighborhood of each pixel on the stripe. The traditional grayscale centroid is improved to a neighborhood grayscale centroid, which is calculated along the horizontal direction (assuming the stripe is vertical; if the stripe is horizontal, then the vertical direction is chosen here). However, instead of directly using the pixel value of a single point, the average pixel value of all points in the neighborhood of that single point is used. The specific calculation method is as follows:
[0099]
[0100] In the formula, w0 and h0 are the width and height of the neighborhood (taking odd numbers). This indicates rounding down, where g(i,j) represents the pixel grayscale value of the point in the i-th row and j-th column of the image, and u... i Let x be the x-coordinate of the center point of the i-th row of the laser stripe.
[0101] Simultaneously considering the normal information of the stripes, based on the point set calculated from the initial neighborhood gray-level centroid, the curvature at each point is calculated, and then the normal at each point is calculated. The gray-level centroid of the refined neighborhood is then calculated along the normal of the initial centerline point set, obtaining the second refined point set as the laser stripe centerline. The extraction of the second refined neighborhood gray-level centroid still follows the same formula, simply changing the direction of the sliding window sampling to the normal.
[0102] Example
[0103] like Figures 2 to 8 As shown, this embodiment employs a laser stripe centerline extraction method based on adaptive exposure and pixel neighborhood. This method includes image preprocessing, adaptive exposure control, stripe image thinning, and laser stripe centerline extraction. The first two steps are iterated continuously until the laser stripe image under optimal exposure is found, and then the latter two steps are implemented. The specific implementation steps of this method include:
[0104] Step 1: Stripe image processing.
[0105] (1) Image binarization
[0106] The original image is binarized, classifying pixels into two classes: 0 and 255. This facilitates subsequent morphological operations and connected component analysis. The binarization employs a block-based OTSU strategy, dividing the image into different regions and performing OTSU binarization on each region separately, using the most suitable binarization threshold for each region. This effectively handles interference from uneven lighting and background, resulting in stronger binarization robustness.
[0107] (2) Stripe contour extraction
[0108] For the binarized image, connected component extraction is performed first. For each extracted connected component, its area and minimum envelope rectangle are calculated. Striped connected components are obtained through two-layer filtering, thereby identifying noise and other objects. The filtering criteria are as follows:
[0109] S>S0
[0110] H / W > σ
[0111] In the formula, S is the area of the connected component, S0 is a pre-defined area threshold, H and W are the height and width of the minimum envelope rectangle of the connected component, and σ is a pre-defined aspect ratio.
[0112] The first layer of filtering primarily targets small, noisy connected regions. Since these typically occupy a small number of pixels, they can be filtered out based on area. The second layer of filtering is based on the aspect ratio of the minimum envelope rectangle. Since the stripes are assumed to be vertical, their aspect ratio is usually large, allowing the second layer to remove other objects while preserving the stripe connected regions. Note that if the stripes are horizontal, the second layer of filtering should be adjusted to W / H > σ, i.e., filtering based on aspect ratio.
[0113] Examples of results before filtering Figure 5 As shown, examples of the filtered results are as follows. Figure 6 As shown, the filtering process removes blocky and dotted noise around the line laser stripes.
[0114] (3) Stripe mask generation
[0115] The stripe contour extracted in the previous step is used to create a mask, so that the pixels inside the stripe contour retain their original grayscale, while the pixels outside the stripe contour are set to 0. This ensures that subsequent image morphology operations, filtering, and laser stripe centerline extraction are not affected by noise and foreign objects outside the stripe contour.
[0116] (4) Region of Interest Segmentation
[0117] Based on the minimum envelope rectangle of the fringe connected region, expand outward by several pixels to ensure that the original fringe is completely contained, and segment out several regions of interest for the fringe, which are then used for the subsequent extraction of the laser fringe center line.
[0118] (5) Morphological filtering
[0119] For the selected fringe connected regions, morphological operations are performed first, followed by Gaussian filtering.
[0120] In this embodiment, the image morphological operation selected is the opening operation. First, the image is eroded to remove small noise points and lines, reducing and thinning the fringe connected regions. Then, the image is dilated to enlarge and coarsen the fringe connected regions. After the opening operation, burrs around the fringe connected regions are removed, and the boundary areas are smooth, which is more conducive to the accurate extraction of the laser fringe center line.
[0121] Gaussian filtering is not performed on the binarized image. Instead, it uses the extracted fringe connected regions as a mask and performs Gaussian filtering on the pixel gray values of the original image in the area covered by the connected regions to prepare for centerline extraction.
[0122] Step 2: Adaptive exposure bar adjustment.
[0123] (1) Cost function calculation
[0124] The cost calculation for adaptive exposure control is a comprehensive cost calculation that takes into account both stripe width and grayscale. The core of the grayscale centroid method is to utilize the energy distribution of the stripes, and energy is reflected in the grayscale value in the image. Therefore, calculating the grayscale cost is part of the comprehensive cost. Stripe width is also an important indicator. If the stripe width is too small, the grayscale gradient will be too extreme. If the stripe width is too wide, the proportion of high-energy pixels will be too high, and the grayscale change will not be obvious. Both will deteriorate the extraction of the laser stripe center line.
[0125] Taking the longitudinal distribution of laser stripes as an example (a similar cost function can be derived from the transverse distribution of stripes), the cost function for adaptive exposure control can be expressed as follows:
[0126]
[0127] in,
[0128]
[0129] In the formula, C(S) is the cost value corresponding to the set S of all laser stripe pixels in the image. k S is a subset of laser stripe pixels. k The corresponding cost is determined by the width cost C. h (S k ) and grayscale cost C g (S kThe weighted fusion is used to construct the weighted coefficients, where λ is the weighting coefficient for both. Considering the anisotropy of the width with respect to the coordinates and the grayscale distribution of the fringes when projected onto the curved surface, adaptive weighting factors α(p) are constructed for the width cost and grayscale cost, respectively. ij ) and β(p ij It corresponds to pixel p in the i-th row and j-th column. ij To accommodate variations in width and grayscale. h(p) ij ) and g(p ij ) represent pixel p respectively ij The corresponding stripe width and pixel grayscale value. p ij The middle column of the row of pixels, |·| represents the absolute value, max(·) represents the maximum value, and h0 and g0 are the reference width and grayscale. Based on this, the comprehensive cost corresponding to the linear laser stripe image can be calculated, providing a basis for the iterative update of the exposure value.
[0130] (2) Exposure Update
[0131] First, define an upper and lower limit for the exposure range (e). min ,e max First, use equal step size δ = (e max -e min The cost is calculated within the exposure range using the method of ) / 20, and the exposure value is updated until the exposure value that minimizes the cost is found. Within the neighborhood of that exposure value (e... i -δ,e i A random search is performed within the range +δ). An exposure value is randomly generated within this neighborhood. If the new exposure value is smaller than the current exposure value, the new exposure value is set as the current exposure value, and the neighborhood is updated to half the original neighborhood. This process is repeated multiple times until the change in exposure value e is reached. i-1 -e i <ε. The final stabilized exposure value is selected as the exposure value used for acquiring the line laser stripe image, achieving adaptive exposure control.
[0132] Step 3: Extract the center line of the laser stripe.
[0133] (1) Gray-level centroid calculation based on neighborhood information
[0134] Simultaneously considering pixel neighborhood information, stripe energy information, and stripe normal information, this embodiment abandons the traditional idea of sampling single-point grayscale, and instead uses a sliding window to sample the neighborhood of each pixel on the stripe. The traditional grayscale centroid is improved to a neighborhood grayscale centroid, which is calculated along the horizontal direction (assuming the stripes are vertical; if the stripes are horizontal, then the vertical direction is chosen here). However, instead of directly using the pixel value of a single point, the average pixel value of all points in the neighborhood of that single point is used. The specific calculation method is as follows:
[0135]
[0136] In the formula, w0 and h0 are the width and height of the neighborhood (taking odd numbers). This indicates rounding down, where g(i,j) represents the pixel grayscale value of the point in the i-th row and j-th column of the image, and u... i Let x be the x-coordinate of the center point of the i-th row of the laser stripe.
[0137] Final point P i (u i Let Ω1 = {P1, P2, P3, ..., Pi} be the initial neighborhood gray-level centroid of the i-th row of the stripe. All gray-level centroids on this stripe constitute the coarsely extracted initial neighborhood gray-level centroid point set, denoted as Ω1 = {P1, P2, P3, ..., Pi}. n There are n points in total. Using neighborhood information instead of single-point information can maximize the use of the group information of the neighborhood rather than the individual information of a single point, which significantly improves accuracy compared to the traditional gray-scale centroid method.
[0138] (2) Calculation of fringe normal
[0139] The normal at each point is calculated using the coarsely extracted initial neighborhood gray-level centroid set Ω1. Specifically, the normal at each point is calculated from the three adjacent points, where the normal at the i-th point P is calculated from the three adjacent points P. i Normal n at the location i By P i-1 ,P i ,P i+1 The calculations for the three points are as follows:
[0140] n i =k i / ||k i ||
[0141]
[0142] i = 2, 3, 4, ..., n-1
[0143] In the formula, k i Let P be the i-th point i The curvature at that point.
[0144] The first point P1 and the last point P n The normal at the point is calculated as follows. The normals of both are as follows:
[0145] n1=(-τ 1y ,τ 1x )
[0146] n n =(-τ) ny ,τ nx )
[0147] In the formula, τ n =(τ nx ,τ ny ) and τ1=(τ 1x ,τ 1y Let ) be the tangent at the two points, which can be calculated as follows:
[0148]
[0149]
[0150] At this point, the normals of all points in the initial neighborhood gray-level centroid set extracted by coarse extraction have been obtained, denoted as N1={n1,n2,n3,...,n n}
[0151] Step 4: Refine the grayscale centroid along the normal direction.
[0152] After coarse extraction and normal calculation, the neighborhood gray-level centroid can be refined along the normal direction. The neighborhood information of the point is still used instead of the single-point information. Let the centroid be along the i-th point P. i Normal n at the location i Take a total of m points. Then P i grayscale center of gravity Q i (q ix ,q iy It can be calculated using the following formula:
[0153]
[0154]
[0155] In the formula, w0 and h0 are the width and height of the neighborhood (taking odd numbers). This indicates rounding down from ·, g(y) i ,x i ) represents point p i The pixel grayscale values. At this point, the grayscale centroids of the refined neighborhood of the laser stripes have all been calculated, denoted as Ω2={Q1,Q2,Q3,...,Q...} n This point set serves as the final extracted laser stripe centerline point set, and the extraction result is as follows: Figure 9 As shown.
[0156] The above description is only a specific embodiment of this application, but the protection scope of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the protection scope of this application.
Claims
1. A method for extracting the center line of laser stripes based on adaptive exposure and pixel neighborhood, characterized in that, include: S1. The camera acquires a stripe image at the initial exposure time, and preprocesses the acquired image, including adaptive binarization of the stripe image and contour extraction. S2. For the stripe image after contour extraction in S1, calculate the adaptive exposure time based on stripe width and grayscale cost, and repeat S1 with the adaptive exposure time to obtain the optimal laser stripe image. S3. For the optimal laser stripe image obtained in S2, refine the stripe image; S4. Based on the refined stripe image obtained in S3, the center line of the laser stripes is extracted. Extracting the center line includes calculating the stripe normal, specifically: Use the coarsely extracted initial neighborhood gray-level centroid set Calculate the normal at each point; The normal vector at each point is calculated from the three adjacent points, the first... Points The direction of the place Depend on The calculations for the three points are as follows: In the formula, For the first Points Curvature at that point; First point and the last point The normal directions at each location are: In the formula, and The tangent at the two points is calculated using the following formula: Find the normals of all points in the initial neighborhood gray-level centroid set extracted coarsely, denoted as .
2. The laser stripe centerline extraction method based on adaptive exposure and pixel neighborhood according to claim 1, characterized in that, S1 includes: (1) Adaptive binarization of stripe images Divide the image into a grid; The OTSU adaptive binarization algorithm is applied to each block to adapt to uneven lighting and background in different areas; (2) Stripe contour extraction Connected component extraction is performed on the adaptively binarized image to extract the contours of all connected components containing stripes and other noise. The coarsely extracted contours are filtered using contour area and aspect ratio of the smallest envelope rectangle to obtain all stripe contours and remove noise areas.
3. The laser stripe centerline extraction method based on adaptive exposure and pixel neighborhood according to claim 1, characterized in that, S2 include: S2.1: Calculate the cost of the striped image after preliminary preprocessing; S2.2: Iteratively update the exposure value based on minimizing the cost.
4. The laser stripe centerline extraction method based on adaptive exposure and pixel neighborhood according to claim 3, characterized in that, In S2.1, the cost function for adaptive exposure control is expressed in the following form: In the formula, For the set of all laser stripe pixels in the image The corresponding cost, For a subset of laser stripe pixels The corresponding cost is determined by the width cost. and the cost of grayscale Weighted fusion constitutes, These are the weighting coefficients for the two. For width cost adaptive weighting factor, The grayscale cost adaptive weighting factor, For pixels The corresponding stripe width, For pixels The corresponding pixel grayscale value, for The middle column of the row of pixels, For absolute values, The maximum value, For reference width, It is in grayscale.
5. The laser stripe centerline extraction method based on adaptive exposure and pixel neighborhood according to claim 3, characterized in that, S2.2 includes: Given an upper and lower limit of the exposure range Use equal step size The method calculates the cost within the exposure range and updates the exposure value until an exposure value that minimizes the cost is found. The neighborhood of the exposure value A random search is performed within the neighborhood, generating a random exposure value. If the new exposure value is smaller than the current exposure value, the new exposure value is set as the current exposure value, and the neighborhood is updated to half of the original neighborhood. This process is repeated multiple times until the change in exposure value is reached. ; The final stable exposure value is selected as the exposure value used for acquiring line laser stripe images, thus achieving adaptive exposure control.
6. The laser stripe centerline extraction method based on adaptive exposure and pixel neighborhood according to claim 1, characterized in that, In S3, morphological operations are used. First, the striped area is eroded to remove small noise and burrs. Then, the striped area is dilated to coarsen the striped target and restore its original size, and the boundary area is smoothed. The extracted striped area is used as a mask to perform Gaussian filtering on the original pixels covered by the mask.
7. The laser stripe centerline extraction method based on adaptive exposure and pixel neighborhood according to claim 1, characterized in that, In S3, stripe image thinning involves segmenting the stripe regions of interest (ROIs). For the selected stripe contours, the smallest envelope rectangle is taken as the ROI, and all ROIs are segmented from a single image.
8. The laser stripe centerline extraction method based on adaptive exposure and pixel neighborhood according to claim 1, characterized in that, In S4, the centroid coordinates of the coarsely extracted laser stripe grayscale are calculated using the following formula: In the formula, For the width of the neighborhood, For the high of the neighborhood, To Round down to the nearest integer. For the first one in the picture Line 1 The pixel grayscale values of the points in the column. For the laser stripe number center point of the row coordinate.
9. The laser stripe centerline extraction method based on adaptive exposure and pixel neighborhood according to claim 1, characterized in that, After coarse extraction and normal calculation, the neighborhood gray-level centroid is refined along the normal direction. The neighborhood information of a point is used to replace the single-point information. Let the centroid be along the normal direction. Points The direction of the place Take both front and back Points ,but grayscale center of gravity Calculated using the following formula: In the formula, For the width of the neighborhood, For the high of the neighborhood, To Round down to the nearest integer. For point The pixel grayscale value; The gray-level centroid of the refined neighborhood of the laser stripe is calculated and denoted as . .
Citation Information
Patent Citations
Turbine blade surface line laser stripe center extraction method
CN118279379A