A light strip extraction method and device based on clustering
Through the cluster-based light bar extraction method, the light bar image is filtered and denoised and segmented, and the center coordinates of the light bar are calculated in combination with the clustering technology, which solves the problems of poor noise resistance and large calculation amount in the existing technology, and achieves a high-precision and fast light bar extraction effect.
Patent Information
- Application Number
- CN202210043195.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-14
- Publication Date
- 2025-04-25
- Estimated Expiration
- 2042-01-14
AI Technical Summary
The existing light bar extraction method has poor noise immunity when processing images with small signal-to-noise ratios and is large in calculation, which cannot meet the real-time online detection requirements.
The cluster-based light bar extraction method is used to filter and denoise and segment the light bar images and cluster single rows or single columns respectively to remove cluttered noise and large spot noise, and calculate the central coordinates of each effective area.
It realizes high accuracy and fast speed of light bar extraction, enhances noise immunity and robustness, and can process data in multiple rows or columns at the same time, suitable for light bar images of any shape.
Smart Images

Figure CN114494165B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a light strip extraction method and device based on clustering. Background Art
[0002] The principle of laser triangulation is to use a laser to project a laser bar of a certain wavelength onto the workpiece to be measured, modulate the laser bar through the workpiece to be measured, and then use a CCD camera to shoot the modulated light bar pattern and combine it with the system conversion relationship to obtain the three-dimensional shape information of the workpiece to be measured. Therefore, in the line structured light three-dimensional measurement system based on triangulation, how to quickly and accurately obtain the center coordinates of the light bar from the light bar image is the key to real-time precision measurement.
[0003] The literature [Yang Jianhua, Yang Xuerong, Cheng Siyuan, et al. A review of light stripe center extraction in line structured light three-dimensional vision measurement [J]. Journal of Guangdong University of Technology, 2014, (1): 74-78.] summarizes that the existing light stripe extraction methods are mainly divided into geometric center extraction method and energy center method. The geometric center method also includes light stripe extraction methods such as edge method and skeleton refinement method. The geometric center method can obtain good light stripe extraction effect when the grayscale distribution of the light stripe cross section is an ideal Gaussian, and the extraction speed is fast, but the noise resistance is poor and it is not suitable for images with low signal-to-noise ratio. The energy center method mainly includes light stripe extraction methods such as directional template method, grayscale centroid method, and Hessian matrix method. Reference [Wu Qingyang, Su Xianyu, Li Jingzhen, et al. A new algorithm for extracting the center of light stripes from line structured light [J]. Journal of Sichuan University (Engineering Science Edition), 2007, 39(4): 151-155.] By using a template with a fixed direction to convolve the image, the extreme point in the image is obtained to obtain the center of the light stripe. Although this method can suppress certain noise, it is time-consuming and can only be used for light stripe patterns with a fixed direction. Reference [Chen Nian, Guo Yangkuan, Zhang Xiaoqing. Extraction of the center of light stripes from line structured light based on the Hessian matrix [J]. Digital Technology and Applications, 2019, 37(03): 126-127.] The Hessain matrix method can achieve sub-pixel light stripe extraction, but the calculation is large and cannot meet the requirements of real-time online detection. The ordinary grayscale centroid method only scans in two directions, cannot process complex light stripe shape images, and is easily affected by noise. Summary of the invention
[0004] The purpose of the present invention is to address the deficiencies of the prior art and propose a light stripe extraction method and device based on clustering, which clusters a single row or a single column to achieve a denoising effect, and can simultaneously process data of multiple rows or columns, thereby ensuring the accuracy of light stripe extraction and improving the speed of light stripe extraction, and having stronger noise resistance and robustness.
[0005] The present invention is achieved through the following technical solutions:
[0006] A light stripe extraction method based on clustering comprises the following steps:
[0007] A. Obtain the grayscale image of the initial light stripe image and perform filtering and denoising on the grayscale image to obtain
[0008] to the light bar image;
[0009] B. Use the Otsu algorithm to segment the light stripe image obtained in step A to obtain the light stripe area and background
[0010] area;
[0011] C. Perform a clustering operation on each row or column of the light bar area to obtain multiple valid areas. The clustering operation on each row or column specifically includes the following steps:
[0012] C1. Define P arry is the set of pixels with a pixel value of 255 in a row or a column in the segmented light strip area, P start , P end are the starting point and the end point in the set respectively, and define P vector is a two-dimensional set, P temp is a one-dimensional set;
[0013] C2, the starting point P start As a seed point, put it into the one-dimensional set P temp middle;
[0014] C3. Judgment set P arry Does the difference between the row coordinates or column coordinates of two adjacent points in the equation satisfy the following formula: i+1 -p i =1; if it meets the requirement, go to step C4, otherwise, go to step C5; p i The initial value of is the one-dimensional set P temp The seed point in i+1 For p i Adjacent points; where two adjacent points have the same column coordinates or the same row coordinates;
[0015] C4, when p i+1 P end When , go to step C6, otherwise, p i+1 Put into set P temp Then go to step C3;
[0016] C5, when p i+1 P end , go to step C6, otherwise, set P temp The points in the set P vector The combination is the set Pvector A subset of temp Clear and set p i+1 As a new seed point, put it into the cleared P temp Then go to step C3;
[0017] C6. Take set P vector The largest subset P in vectormax As the effective area of the light bar area;
[0018] D. Calculate the center coordinates of each effective area obtained in step C respectively, and use the center coordinates as the effective area.
[0019] The center point of the light bar in the effective area;
[0020] E. The set of all light bar center points is the light bar coordinates of the initial light bar image.
[0021] Further, the step D comprises the following steps:
[0022] D1. Determine the subset P vectormax The number of is equal to 1 or greater than 1, if it is equal to 1, go to step D2, otherwise, go to step D3;
[0023] D2, the subset P vectormax Sum the row or column coordinates of each point in the set, and then divide it by the subset P vectormax The number of midpoints is the row coordinate or column coordinate of the center point of the light bar in the effective area corresponding to the subset. The column coordinate or row coordinate of the center point of the light bar is the same as the number of midpoints in the subset P. vectormax The column or row coordinates of the midpoints are the same;
[0024] D3, calculate each subset P according to step D2 vectormax The corresponding effective area light bar center point coordinates P c , the coordinates of all center points P c Form a new set P cvector , proceed to step D4;
[0025] D4. Calculate the set P separately cvector The absolute value of the difference between the row coordinate or column coordinate of each point in the set and the row coordinate or column coordinate of other points in the set, the sum of all the absolute values of the differences is divided by the number of points in the set to obtain the average value of the differences, and then proceed to step D5;
[0026] D5. Set P cvector The row coordinates or column coordinates of each point in the set are compared with the average value of the difference obtained in step D4. When the row coordinates or column coordinates of a point are greater than the average value of the difference, the point is removed from its corresponding subset P. vectormaxEliminate the above mentioned items and proceed to step D6;
[0027] D6, each subset P removed in step D5 vectormax Form a new set P final , the set P final All subsets P in vectormax The sum of the row or column coordinates of the midpoint and all subsets P vectormax The total number of points is divided by the value obtained as the row coordinate or column coordinate of the center point of the effective area light bar, and the column coordinate or row coordinate of the center point of the light bar is the same as the column coordinate or row coordinate of each subset P vectormax The column or row coordinates of the midpoint are the same.
[0028] Furthermore, for step E, the extracted light bar coordinates are [(x1, y1), (x2, y2)…(x m ,y m )], m is the number of rows or columns of the light stripe area obtained after the light stripe image is segmented in step B.
[0029] Furthermore, the step A comprises: assuming that the pixel coordinates of the i-th row and the j-th column in the initial light strip image are (x i ,y j ), the pixel value corresponding to this point is f′(x i ,y j ), the pixel point is filtered by the following formula to obtain the corresponding gray value f(x i ,y j ): w represents the size of the filtering neighborhood, (row, col) represents the pixel coordinates in the neighborhood, and f(x row ,y col ) represents the pixel value corresponding to the pixel coordinate point in the neighborhood.
[0030] Further, the step B comprises:
[0031] B1. Segment the light stripe image obtained after processing in step A into foreground and background according to the segmentation threshold T′, and define the inter-class variance δ between foreground and background: δ 2 =ω0ω1(μ1-μ0) 2 , ω0, ω1 represent the occurrence probability of foreground and background respectively, μ0, μ1 represent the grayscale mean of foreground and background respectively;
[0032] B2. Take the segmentation threshold T′ corresponding to the maximum inter-class variance δ as the optimal global segmentation threshold T, and segment the light stripe image obtained after processing in step A according to the optimal global segmentation threshold T as follows to obtain the light stripe area and the background area: Among them, g(x i ,y j) indicates that the segmented light strip image is at coordinate (x i ,y j ) is the pixel value at .
[0033] Furthermore, in the step A, a red laser with a wavelength of 650 nm is vertically projected onto the workpiece to be measured, and then an image including the intersection line of the red laser and the workpiece to be measured is captured by a camera to obtain the initial light strip image.
[0034] Furthermore, in step C6, for the set P vector Perform a loop to obtain the largest subset P vectormax .
[0035] The present invention is also achieved through the following technical solutions:
[0036] A light strip extraction device based on clustering, comprising:
[0037] Preprocessing module: used to obtain the grayscale image of the initial light stripe image, and perform filtering and denoising on the grayscale image to obtain the light stripe image;
[0038] Segmentation module: used to segment the light stripe image using the Otsu algorithm to obtain the light stripe area and the background area;
[0039] The effective area determination module: performs a clustering operation on each row or column of the light bar area to obtain multiple effective areas. The clustering operation of each row or column specifically includes:
[0040] Definition P arry is the set of pixels with a pixel value of 255 in a row or a column in the segmented light strip area, P start , P end are the starting point and the end point in the set respectively, and define P vector is a two-dimensional set, P temp is a one-dimensional set; the starting point P start As a seed point, put it into the one-dimensional set P temp Middle; judgment set P arry Does the difference between the row coordinates or column coordinates of two adjacent points in the equation satisfy the following formula: i+1 -p i =1; if it meets the requirement, then when p i+1 Not the end point P end When p i+1 Put into set P temp and repeat the process until p i+1 The end point P end If it does not meet the requirements, then when p i+1 Not the end point P end When tempThe points in the set P vector The combination is the set P vector A subset of temp Clear and set p i+1 As a new seed point, put it into the cleared P temp and repeat the process until p i+1 The end point P end , and finally take the set P vector The largest subset P in vectormax As the effective area of the light bar area;
[0041] Light bar center point determination module: used to calculate the center coordinates of each effective area and use the center coordinates as the center point of the light bar of the effective area;
[0042] Light bar acquisition module: used to group the center points of all light bars into a set, which is the light bar coordinates of the initial light bar image.
[0043] The present invention has the following beneficial effects:
[0044] 1. The present invention first filters and denoises the light stripe image, and then uses the Otsu algorithm to adaptively segment the light stripe image to obtain a rough light stripe area. In the processing of the light stripe area, a single row or a single column is clustered to achieve the purpose of removing messy noise points and large light spot noise points (when the light stripe area is a horizontal pattern, a single column is clustered, and when the light stripe area is a vertical pattern, a single row is clustered), so as to quickly and accurately obtain multiple effective areas of the light stripe area, and then for each effective area, the light stripe center point corresponding to each effective area is obtained respectively, and finally the light stripe center point corresponding to each effective area is clustered. The center point of the light strip obtains the coordinates of the light strip to be extracted, which not only ensures the accuracy of the light strip extraction, but also improves the speed of the light strip extraction, and has stronger noise resistance and robustness. In addition, clustering is performed on a single column or a single row, so that each clustering process is independent, so that it is possible to process multiple rows or columns of data at the same time, and the speed of data processing is greatly improved without affecting the denoising effect. Furthermore, because the present invention clusters single rows or columns respectively, it can still be used for curve-type light strip images, that is, the present invention can be applied to light strip images of any shape and has strong adaptability to light strip images.
[0045] 2. The optimal global segmentation threshold T in step B of the present invention is obtained according to the inter-class variance of the foreground and background of the image to be processed. Therefore, for different images, different optimal global segmentation thresholds T can be adaptively obtained, thereby adaptively segmenting the light stripe image.
[0046] 3. In step D of the present invention, the coordinates of the center points of the light strips in each effective area are obtained based on the idea of finding the average value. The calculation is simple, the amount of calculation is small, and the calculation speed is fast. In addition, the object to be measured is made of a material with a reflective surface and is easily affected by external light, resulting in coordinate calculation errors. The method of the present invention can greatly reduce the occurrence of such problems. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] The present invention is further described in detail below with reference to the accompanying drawings.
[0048] Figure 1 It is a flow chart of the present invention.
[0049] Figure 2 Schematic diagram of line structured light measurement based on triangulation method.
[0050] Figure 3 The initial light bar image captured by the camera.
[0051] Figure 4 This is a diagram showing the light strip extraction effect of the present invention.
[0052] Figure 5 This is the effect diagram extracted by ordinary grayscale centroid method.
[0053] Figure 6 This is a diagram of the light strip extraction effect based on the Hessian matrix.
[0054] Among them, 1. camera; 2. laser transmitter; 3. workpiece to be measured; 4. intersection line. DETAILED DESCRIPTION
[0055] like Figure 1 As shown, the light strip extraction method based on clustering includes the following steps:
[0056] A. Obtaining a grayscale image of the initial light stripe image, and performing filtering and denoising processing on the grayscale image to obtain a light stripe image;
[0057] like Figure 2 As shown in FIG. 1 , the process of obtaining the initial light stripe image is as follows: a red laser with a wavelength of 650 nm is vertically projected onto the surface of the workpiece 3 by the laser transmitter 2 to form an intersection line 4 between the red laser and the workpiece 3, and an image including the intersection line 4 is captured by the camera 1, which is the initial light stripe image. Figure 3 As shown, the workpiece 3 to be measured is a white rubber sole model, and the parameters of the camera 1 are: model MER-131-210U3M, resolution 1280X1024, image sensor CMOS, frame rate full frame and up to 210FPS, optical size 1 / 2, weight 57g, lens model Computar M0814-MP2, focal length 8mm, aperture range F1.4-F16C, viewing angle 12.5°×9.3°;
[0058] After obtaining the initial light stripe image, it is filtered and denoised using mean filtering;
[0059] Mean filtering is also called linear filtering. The main method used is the neighborhood averaging method. The basic principle is to replace the pixel values in the original image with the mean value. Specifically:
[0060] Assume that the pixel coordinates of the i-th row and j-th column in the initial light strip image are (x i ,y j ), the pixel value corresponding to this point is f′(x i ,y j ), the pixel point is filtered by the following formula to obtain the corresponding gray value f(x i ,y j ): w represents the size of the filtering neighborhood, (row, col) represents the pixel coordinates in the neighborhood, and f(x row ,y col ) represents the pixel value corresponding to the pixel coordinate point in the neighborhood;
[0061] B. Use the Otsu algorithm to segment the light stripe image obtained in step A to obtain the light stripe area and the background area; specifically:
[0062] B1. Segment the light stripe image obtained after processing in step A into foreground and background according to the segmentation threshold T′, and define the inter-class variance δ between foreground and background: δ 2 =ω0ω1(μ1-μ0) 2 , ω0, ω1 represent the occurrence probability of foreground and background respectively, μ0, μ1 represent the grayscale mean of foreground and background respectively;
[0063] B2. Take the segmentation threshold corresponding to the maximum inter-class variance δ as the optimal global segmentation threshold T, and segment the light stripe image obtained after processing in step A according to the optimal global segmentation threshold T as follows to obtain the light stripe area and the background area: Among them, g(x i ,y j ) indicates that the segmented light strip image is at coordinate (x i ,y j ) at the pixel value;
[0064] C. Perform clustering operation on each row or column of the light bar area to obtain multiple valid areas. In this embodiment, Figure 3 As shown, the initial light stripe image is a horizontal image, so a clustering operation is performed on each column, specifically including the following steps:
[0065] C1. Define P arryis the set of pixels with a pixel value of 255 in each column in the segmented light strip area, P start , P end are the starting point and the end point in the set respectively, and define P vector is a two-dimensional set, P temp is a one-dimensional set;
[0066] C2, the starting point P start As a seed point, put it into the one-dimensional set P temp middle;
[0067] C3. Judgment set P arry Does the difference in column coordinates between two adjacent points in satisfy the following formula: i+1 -p i =1; if it meets the requirement, go to step C4, otherwise, go to step C5; p i The initial value of is the one-dimensional set P temp The seed point in i+1 For p i Adjacent points; where the row coordinates of two adjacent points are the same;
[0068] C4, when p i+1 P end When , go to step C6, otherwise, p i+1 Put into set P temp Then go to step C3;
[0069] C5, when p i+1 P end , go to step C6, otherwise, set P temp The points in the set P vector The combination is the set P vector A subset of temp Clear and set p i+1 As a new seed point, put it into the cleared P temp Then go to step C3;
[0070] C6. For the set P vector Perform a loop to obtain the largest subset P vectormax , and take the set P vector The largest subset P in vectormax As the effective area of the light bar area;
[0071] D. Calculate the center coordinates of each effective area obtained in step C6, and use the center coordinates as the center point of the light strip of the effective area; specifically, the steps include:
[0072] D1. Determine the subset P vectormaxThe number of is equal to 1 or greater than 1, if it is equal to 1, go to step D2, otherwise, go to step D3;
[0073] D2, the subset P vectormax Sum the column coordinates of each point in the set, and then divide by the subset P vectormax The number of midpoints is the column coordinates of the center point of the light bar in the valid area corresponding to the subset, and the row coordinates of the center point of the light bar are the same as the number of midpoints in the subset P. vectormax The row coordinates of the midpoints are the same;
[0074] D3, calculate each subset P according to step D2 vectormax The corresponding effective area light bar center point coordinates P c , the coordinates of all center points P c Form a new set P cvector , proceed to step D4;
[0075] D4. Calculate the set P separately cvector The absolute value of the difference between the column coordinates of each point in the set and the column coordinates of other points in the set, the sum of all the absolute values of the differences is divided by the number of points in the set to obtain the average value of the differences, and then proceed to step D5;
[0076] D5. Set P cvector The column coordinates of each point in the set are compared with the average difference value obtained in step D4. When the column coordinates of a point are greater than the average difference value, the point is removed from its corresponding subset P. vectormax Eliminate the above mentioned items and proceed to step D6;
[0077] D6, each subset P removed in step D5 vectormax Form a new set P final , the set P final All subsets P in vectormax The sum of the column coordinates of the midpoint and all subsets P vectormax The total number of points is divided by the value obtained as the column coordinate of the center point of the effective area light bar, and the row coordinate of the center point of the light bar is the same as that of each subset P vectormax The row coordinates of the midpoints are the same;
[0078] E. The set of all light bar center points is the light bar coordinates of the initial light bar image, such as Figure 4 As shown, the light bar coordinates are [(x1,y1),(x2,y2)…(x m ,y m )], m is the number of columns of the light stripe area obtained after the light stripe image is segmented in step B.
[0079] A light strip extraction device based on clustering, comprising:
[0080] Preprocessing module: used to obtain the grayscale image of the initial light stripe image, and perform filtering and denoising on the grayscale image to obtain the light stripe image;
[0081] Segmentation module: used to segment the light stripe image using the Otsu algorithm to obtain the light stripe area and the background area;
[0082] The effective area determination module: performs a clustering operation on each column of the light bar area to obtain multiple effective areas. The clustering operation of each column specifically includes:
[0083] Definition P arry is the set of pixels with a pixel value of 255 in a column in the segmented light strip area, P start , P end are the starting point and the end point in the set respectively, and define P vector is a two-dimensional set, P temp is a one-dimensional set; the starting point P start As a seed point, put it into the one-dimensional set P temp Middle; judgment set P arry Does the difference in column coordinates between two adjacent points in satisfy the following formula: i+1 -p i =1; if it meets the requirement, then when p i+1 Not the end point P end When p i+1 Put into set P temp and repeat the process until p i+1 The end point P end If it does not meet the requirements, then when p i+1 Not the end point P end When temp The points in the set P vector The combination is the set P vector A subset of temp Clear and set p i+1 As a new seed point, put it into the cleared P temp and repeat the process until p i+1 The end point P end , and finally take the set P vector The largest subset P in vectormax As the effective area of the light bar area;
[0084] Light bar center point determination module: used to calculate the center coordinates of each effective area and use the center coordinates as the center point of the light bar of the effective area;
[0085] Light bar acquisition module: used to group the center points of all light bars into a set, which is the light bar coordinates of the initial light bar image.
[0086] Figure 4 This is a light strip effect diagram obtained by using the light strip extraction method of the present invention. Figure 5 and Figure 6 This is the light strip effect diagram obtained by using the ordinary grayscale centroid method and Hessian matrix. It can be seen that Figure 4 The light bar in the middle works best.
[0087] The above description is only a preferred embodiment of the present invention, and therefore cannot be used to limit the scope of implementation of the present invention. That is, equivalent changes and modifications made according to the scope of the patent application of the present invention and the contents of the specification should still fall within the scope covered by the patent of the present invention.
Claims
1. A light stripe extraction method based on clustering, characterized in that: The steps include: A. Obtaining a grayscale image of the initial light stripe image, and performing filtering and denoising processing on the grayscale image to obtain a light stripe image; B. Use the Otsu algorithm to segment the light stripe image obtained in step A to obtain the light stripe area and the background area; C. Perform a clustering operation on each row or column of the light bar area to obtain multiple valid areas. The clustering operation on each row or column specifically includes the following steps: C1. Define P arry is the set of pixels with a pixel value of 255 in a row or a column in the segmented light strip area, P start , P end are the starting point and the end point in the set respectively, and define P vector is a two-dimensional set, P temp is a one-dimensional set; C2, the starting point P start As a seed point, put it into the one-dimensional set P temp middle; C3. Judgment set P arry Does the difference between the row coordinates or column coordinates of two adjacent points in the equation satisfy the following formula: i+1 -p i =1; If it is true, go to step C4, otherwise go to step C5; i The initial value of is the one-dimensional set P temp The seed point in i+1 For p i Adjacent points; where two adjacent points have the same column coordinates or the same row coordinates; C4, when p i+1 P end When , go to step C6, otherwise, p i+1 Put into set P temp Then go to step C3; C5, when p i+1 P end , go to step C6, otherwise, set P temp The points in the set P vector The combination is the set P vector A subset of temp Clear and set p i+1 As a new seed point, put it into the cleared P temp Then go to step C3; C6. Take set P vector The largest subset P in vectormax As the effective area of the light bar area; D. Calculate the center coordinates of each effective area obtained in step C respectively, and use the center coordinates as the center point of the light bar of the effective area; E. The set of all light strip center points is the light strip coordinates of the initial light strip image; The step D comprises the following steps: D1. Determine the subset P vectormax The number of is equal to 1 or greater than 1, if it is equal to 1, go to step D2, otherwise, go to step D3; D2, the subset P vectormax Sum the row or column coordinates of each point in the set, and then divide it by the subset P vectormax The number of midpoints is the row coordinate or column coordinate of the center point of the light bar in the effective area corresponding to the subset. The column coordinate or row coordinate of the center point of the light bar is the same as the number of midpoints in the subset P. vectormax The column or row coordinates of the midpoints are the same; D3, calculate each subset P separately in the same way as step D2 vectormax The corresponding effective area light bar center point coordinates P c , the coordinates of all center points P c Form a new set P cvector , proceed to step D4; D4. Calculate the set P separately cvector The absolute value of the difference between the row coordinate or column coordinate of each point in the set and the row coordinate or column coordinate of other points in the set, the sum of all the absolute values of the differences is divided by the number of points in the set to obtain the average value of the differences, and then proceed to step D5; D5. Set P cvector The row coordinates or column coordinates of each point in the set are compared with the average value of the difference obtained in step D4. When the row coordinates or column coordinates of a point are greater than the average value of the difference, the point is removed from its corresponding subset P. vectormax Remove the , and go to step D6; D6, each subset P removed in step D5 vectormax Form a new set P final , the set P final All subsets P in vectormax The sum of the row or column coordinates of the midpoint and all subsets P vectormax The total number of points is divided by the value obtained as the row coordinate or column coordinate of the center point of the effective area light bar, and the column coordinate or row coordinate of the center point of the light bar is the same as the column coordinate or row coordinate of each subset P vectormax The column or row coordinates of the midpoint are the same.
2. The light stripe extraction method based on clustering according to claim 1, characterized in that: For step E, the extracted light bar coordinates are [(x1,y1),(x2,y2)…(x m ,y m )], m is the number of rows or columns of the light stripe area obtained after the light stripe image is segmented in step B.
3. The light stripe extraction method based on clustering according to claim 1, characterized in that: Step A Including: Assume that the pixel coordinates of the i-th row and j-th column in the initial light strip image are (x i ,y j ), the pixel value corresponding to this point is f′(x i ,y j ), the pixel point is filtered by the following formula to obtain the corresponding gray value f(x i ,y j ): w represents the size of the filtering neighborhood, (row, col) represents the pixel coordinates in the neighborhood, and f′(x row ,y col ) represents the pixel value corresponding to the pixel coordinate point in the neighborhood.
4. A light stripe extraction method based on clustering according to claim 1, 2 or 3, characterized in that: The step B comprises: B1. Segment the light stripe image obtained after processing in step A into foreground and background according to the segmentation threshold T′, and define the inter-class variance δ between foreground and background: δ 2 =ω0ω1(μ1-μ0) 2 , ω0, ω1 represent the occurrence probability of foreground and background respectively, μ0, μ1 represent the grayscale mean of foreground and background respectively; B2. Take the segmentation threshold T′ corresponding to the maximum inter-class variance δ as the optimal global segmentation threshold T, and segment the light stripe image obtained after processing in step A according to the optimal global segmentation threshold T as follows to obtain the light stripe area and the background area: Among them, g(x i ,y j ) indicates that the segmented light strip image is at coordinate (x i ,y j ) is the pixel value at .
5. A light stripe extraction method based on clustering according to claim 1, 2 or 3, characterized in that: In the step A, a red laser with a wavelength of 650 nm is vertically projected onto the workpiece to be measured, and then an image including the intersection line of the red laser and the workpiece to be measured is captured by a camera to obtain the initial light strip image.
6. A light stripe extraction method based on clustering according to claim 1, 2 or 3, characterized in that: In step C6, for the set P vector Perform a loop to obtain the largest subset P vectormax .
7. A light stripe extraction device based on clustering, characterized in that: include: Preprocessing module: used to obtain the grayscale image of the initial light stripe image, and perform filtering and denoising on the grayscale image to obtain the light stripe image; Segmentation module: used to segment the light stripe image using the Otsu algorithm to obtain the light stripe area and the background area; The effective area determination module: performs a clustering operation on each row or column of the light bar area to obtain multiple effective areas. The clustering operation of each row or column specifically includes: Define P arry is the set of pixels with a pixel value of 255 in a row or a column in the segmented light strip area, P start , P end are the starting point and the end point in the set respectively, and define P vector is a two-dimensional set, P temp is a one-dimensional set; the starting point P start As a seed point, put it into the one-dimensional set P temp Middle; judgment set P arry Does the difference between the row coordinates or column coordinates of two adjacent points in the equation satisfy the following formula: i+1 -p i =1; if it meets the requirement, then when p i+1 Not the end point P end When p i+1 Put into set P temp and repeat the process until p i+1 The end point P end If it does not meet the requirements, then when p i+1 Not the end point P end When temp The points in the set P vector The combination is the set P vector A subset of temp Clear and set p i+1 As a new seed point, put it into the cleared P temp and repeat the process until p i+1 The end point P end , and finally take the set P vector The largest subset P in vectormax As the effective area of the light bar area; Light bar center point determination module: used to calculate the center coordinates of each effective area and use the center coordinates as the center point of the light bar of the effective area; specifically includes: Judgment subset P vectormax The number of is equal to 1 or greater than 1. If it is equal to 1, then the subset P vectormax Sum the row or column coordinates of each point in the set, and then divide it by the subset P vectormax The number of midpoints is the row coordinate or column coordinate of the center point of the light bar in the effective area corresponding to the subset. The column coordinate or row coordinate of the center point of the light bar is the same as the number of midpoints in the subset P. vectormax The column coordinates or row coordinates of the midpoints are the same, otherwise, calculate each subset P separately vectormax The corresponding effective area light bar center point coordinates P c , the coordinates of all center points P c Form a new set P cvector ; Calculate the set P separately cvector The absolute value of the difference between the row coordinate or column coordinate of each point in the set and the row coordinate or column coordinate of other points in the set, the sum of all the absolute values of the differences is divided by the number of points in the set to obtain the average value of the differences; the set P cvector The row coordinates or column coordinates of each point in the set are compared with the average value of the difference obtained in step D4. When the row coordinates or column coordinates of a point are greater than the average value of the difference, the point is removed from its corresponding subset P. vectormax Eliminate; After the elimination, each subset P vectormax Form a new set P final , the set P final All subsets P in vectormax The sum of the row or column coordinates of the midpoint and all subsets P vectormax The total number of points is divided by the value obtained as the row coordinate or column coordinate of the center point of the effective area light bar, and the column coordinate or row coordinate of the center point of the light bar is the same as the column coordinate or row coordinate of each subset P vectormax The column or row coordinates of the midpoints are the same; Light bar acquisition module: used to group the center points of all light bars into a set, which is the light bar coordinates of the initial light bar image.
Citation Information
Patent Citations
Color structured light strip detection method based on hierarchical clustering and belief propagation
CN111325831A
Image reconstruction method, device and equipment
CN112669438A