Method for detecting rectangular frame in laser ray area
By extracting rows at equal intervals along the column direction from the laser line image to form a thumbnail, calculating the segmentation threshold, and finding the rectangular box boundary, the problems of large computational load and external interference in the prior art are solved, and efficient and accurate laser line detection is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-03-13
- Publication Date
- 2026-04-10
AI Technical Summary
Existing technologies suffer from high computational complexity, low processing efficiency, and susceptibility to external interference during laser line contour extraction, leading to unstable detection results.
By acquiring laser line images, rows are extracted at equal intervals along the column direction to form thumbnails. Image segmentation thresholds are calculated and threshold segmentation is performed. One-dimensional vectors are used to find the boundaries of rectangular boxes, reducing the calculation of irrelevant areas and suppressing the influence of external interference.
It improves the accuracy and processing efficiency of laser line contour extraction, reduces the computational load in irrelevant areas, and suppresses the influence of external interference.
Smart Images

Figure CN121837280A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of image detection, in particular to a method for detecting a rectangular frame of a laser line region. BACKGROUND
[0002] The laser line vision detection technology has been widely applied in the fields of welding tracking, structured light measurement and industrial detection. By processing the laser line image and extracting the laser line contour information, the spatial form or position information of the target object can be obtained, which is an important basis for realizing automatic control and measurement.
[0003] In the prior art, the extraction of the laser line contour is usually based on the pixel-level analysis of the entire image, such as using gray threshold segmentation, center line extraction, edge detection or sub-pixel positioning method to calculate the features of the laser line in the image. Since the area occupied by the laser line in the image is usually small, the above-mentioned methods often need to traverse the entire image pixel by pixel to determine the position and distribution of the laser line center pixel, which results in large amount of calculation and low processing efficiency. Especially in the high-resolution image or real-time processing scene, this problem is likely to become a bottleneck of system performance.
[0004] In addition, in actual industrial applications, the laser line image is often affected by splashes, reflections, arc lights or environmental noise and other interference factors. When the entire image is traversed and processed, the interference information unrelated to the laser line in the image is easily introduced into the contour calculation process, which not only increases the invalid calculation amount, but also may adversely affect the accurate extraction of the laser line contour, reducing the stability and reliability of the detection result.
[0005] Therefore, the prior art generally has the problems of excessive calculation range, low processing efficiency and susceptibility to non-laser region interference in the laser line contour extraction process. SUMMARY
[0006] The purpose of the present application is to provide a method for detecting a rectangular frame of a laser line region, which reduces the calculation amount of irrelevant regions, improves the processing efficiency and suppresses the influence of external interference while ensuring the accuracy of laser line contour extraction.
[0007] To achieve the purpose of the present application, the technical solution adopted is as follows: a method for detecting a rectangular frame of a laser line region, comprising the following steps: Step 1: obtaining a laser line image; Step 2: extracting rows of the laser line image at equal intervals in the column direction of the laser line image to form a thumbnail image; Step 3: calculating the average value of the pixel values around the laser line image, and calculating the image segmentation threshold value; Step four, using the image segmentation threshold calculated in step three to threshold segment the thumbnail in step two, to obtain a binary image; Step five, traversing the binary image by row, and calculating the length of the white continuous region in each row, setting the pixel value of the white continuous region with a length exceeding a preset region length to 0; Step six, summing the binary image processed in step five by column to obtain a one-dimensional vector; Step seven, traversing the one-dimensional vector obtained in step six to find the first position greater than a preset vector segmentation threshold and the last position greater than the preset vector segmentation threshold, and taking the two positions as the left and right boundaries of the rectangular frame; at the same time, taking the first row of the binary image and the last row of the binary image as the upper and lower boundaries of the rectangular frame, to obtain the rectangular frame of the laser region.
[0008] Further, the interval value in step two is a preset value, and the interval value ranges from one-twentieth to one-fiftieth of the height of the laser line image.
[0009] Further, in step three, the image segmentation threshold is 1.5 times the average value of the pixel values around the laser line image.
[0010] Further, in step five, the way to calculate the length of the white continuous region in each row is as follows: In the process of traversing the binary image by row, when it is detected that the current pixel value is 255 and the previous pixel value is 0, or the current pixel is located at the starting position of the row, it is determined that a white continuous region is detected, and the column coordinate of the pixel is recorded as the starting column of the white continuous region; Continuing to traverse the binary image to the right along the row, when it is detected that the pixel value is 0, or the end of the row is reached, it is determined that the white continuous region ends, and the position of the white pixel before the end is recorded as the termination column of the white continuous region; According to the starting column and the termination column, the length of the white continuous region is calculated.
[0011] Further, in the process of calculating the length of the white continuous region in each row in step five, when the length of the white continuous region is greater than the preset region length, the pixel values between the starting point of the row and the termination point of the row are set to 0, and the subsequent pixels in the row are continuously scanned until each row is scanned.
[0012] Further, the preset region length is 15 pixel widths.
[0013] Further, in step seven, the preset vector segmentation threshold is the cumulative sum of 3-5 white pixel values.
[0014] The beneficial effects of the present application are: The present application introduces the influence of interference factors such as splashes, reflections, arc lights or environmental noise on pixels, ensures the accuracy of laser line profile extraction, reduces the calculation amount of irrelevant areas, improves processing efficiency and suppresses the influence of external interference. BRIEF DESCRIPTION OF DRAWINGS
[0015] Figure 1 is a flowchart of detecting a laser line area rectangular frame in the present application. DETAILED DESCRIPTION
[0016] The present application will be further described in detail below in combination with the drawings and embodiments. It can be understood that the specific embodiments described herein are only used to explain the related content, and not to limit the present application. In addition, it should be noted that only the parts related to the present application are shown in the drawings for ease of description.
[0017] It should be noted that the embodiments in the present application and the features in the embodiments can be combined with each other without conflict. The present application will be described in detail below with reference to the drawings and in combination with the embodiments.
[0018] As shown in Figure 1 The present application provides a method for detecting a laser line area rectangular frame, which comprises the following steps: Step one, acquiring a laser line image.
[0019] Step two, according to a preset interval value, extracting image rows at equal intervals in the column direction of the laser line image to form a thumbnail; in this step, in order to reduce the calculation amount while ensuring the stability of recognition, the preset interval value is in the range of one-twentieth to one-fiftieth of the height of the laser line image.
[0020] Step three, calculating the average value of the pixel values of one round of pixels around the laser line image, which can represent the pixel value of the black background noise, and calculating the image segmentation threshold value through the average value; since the pixel value of the black background noise generally fluctuates less, the 1.5 times of the average value can be taken as the image segmentation threshold value when the image segmentation threshold value is calculated through the average value of one round of pixels around the laser line image under the black background noise; at the same time, in the laser line image, only the brightness of the laser, welding splashes, reflections, arc lights and other regions is relatively high, and these regions usually do not appear in the four corners of the laser line image, even if they appear in the four corners of the laser line image, they only account for a small proportion, and the pixel values of one round of pixels around the laser line image can be ignored after averaging.
[0021] Step four, threshold segmentation of the thumbnail in step two is performed by using the image segmentation threshold value calculated in step three to obtain a binary image; in the binary image, the white pixel value is 255 and the black pixel value is 0.
[0022] Step five, traverse the binary image by row, and traverse the pixels in the row in turn along the horizontal direction when traversing any row of the binary image; when detecting that the current pixel value is 255 (white) and the previous pixel value is 0 (black), or the current pixel is located at the starting position of the row, it is determined that a white continuous region is detected, and the column coordinate of the pixel is recorded as the starting column of the white continuous region; then, continue to traverse the pixels along the row to the right, and if the current pixel value remains 255 (white), it is considered that the current pixel is still in the white continuous region; when detecting that the pixel value is 0 (black), or when traversing to the end position of the row, it is determined that the white continuous region ends, and the pixel column coordinate before the end is recorded as the termination column of the white continuous region. According to the starting column and the termination column, the length of the white continuous region is calculated; when the length of the white continuous region is greater than the preset region length, the pixel value between the starting point and the termination point of the row is set to 0, and the subsequent pixels in the row are continuously scanned and processed until each row is processed. In the process of traversing the binary image, the preset region length is the width of the laser line stripe, which is specifically 15 pixel widths.
[0023] Step six, sum the binary image processed in step five by column to obtain a one-dimensional vector. Generally, the column corresponding to the laser line is usually a higher cumulative value; in other columns, since step five excludes the interference of black background noise, the vector values of these columns are generally small or almost 0, and at this time, through a preset vector segmentation threshold, the position of the laser line can be easily screened out. Here, the preset vector segmentation threshold is the cumulative sum of 3-5 white pixel values.
[0024] Step seven, traverse the one-dimensional vector obtained in step six, find the first position greater than the preset vector segmentation threshold and the last position greater than the preset vector segmentation threshold, and take the two positions as the left and right boundaries of the rectangular frame; at the same time, take the first row of the binary image and the last row of the binary image as the upper and lower boundaries of the rectangular frame, so as to obtain the rectangular frame of the laser region.
[0025] Those skilled in the art should understand that the above embodiments are only for clearly illustrating the present application, and do not limit the scope of the present application. Based on the above disclosure, other changes or modifications can also be made by those skilled in the art, and these changes or modifications are still within the scope of the present application.
Claims
1. A method for detecting a rectangular frame of a laser line region, characterized in that, Includes the following steps: Step 1: Acquire the laser line image; Step 2: Extract rows of the laser line image at equal intervals along the column direction to form a thumbnail; Step 3: Calculate the average pixel value around the laser line image and calculate the image segmentation threshold; Step 4: Use the image segmentation threshold calculated in Step 3 to perform threshold segmentation on the thumbnail from Step 2 to obtain a binary image; Step 5: Traverse the binary image row by row and calculate the length of the continuous white region in each row. Set the pixel value of the continuous white region whose length exceeds the preset region length to 0. Step 6: Sum the columns of the binary image processed in Step 5 to obtain a one-dimensional vector; Step 7: Traverse the one-dimensional vector obtained in Step 6, find the first position greater than the preset vector segmentation threshold and the last position greater than the preset vector segmentation threshold, and use these two positions as the left and right boundaries of the rectangle; at the same time, use the first row and the last row of the binary image as the upper and lower boundaries of the rectangle, thus obtaining the rectangle of the laser region.
2. The method for detecting a rectangular frame of a laser line region according to claim 1, characterized in that, The interval value in step two is a preset value, and the range of the interval value is one-twentieth to one-fiftieth of the height of the laser line image.
3. The method for detecting a rectangular frame of a laser line region according to claim 1, characterized in that, In step three, the image segmentation threshold is 1.5 times the average value of the pixels around the laser line image.
4. The method for detecting a rectangular frame of a laser line region according to claim 1, 2, or 3, characterized in that, The method for calculating the length of the continuous white region in each row in step five is as follows: During the process of traversing the binary image row by row, when the current pixel value is 255 and its previous pixel value is 0, or when the current pixel is located at the beginning of the row, it is determined that a white continuous region has been detected, and the column coordinate of the pixel is recorded as the starting column of the white continuous region. Continue traversing the binary image to the right along the row. When a pixel value of 0 is detected, or when the end of the row is reached, the white continuous region is determined to be over, and the position of the white pixel before the end is recorded as the termination column of the white continuous region. The length of the white continuous region is calculated based on the starting and ending columns.
5. The method for detecting a rectangular frame of a laser line region according to claim 4, characterized in that, In step five, when calculating the length of the continuous white region in each row, if the length of the continuous white region is greater than the preset region length, the pixel value between the start point and the end point of the row is set to 0, and the scanning of subsequent pixels in the row continues until each row is scanned.
6. The method for detecting a rectangular frame of a laser line region according to claim 5, characterized in that, The preset area length is 15 pixels wide.
7. The method for detecting a rectangular frame of a laser line region according to claim 1, 2, or 3, characterized in that, In step seven, the preset vector segmentation threshold is the sum of 3 to 5 white pixel values.
Citation Information
Patent Citations
Equally-spaced sampling method for point cloud contour line of line laser 3D camera
CN114119731A
Ray image welding seam segmentation algorithm based on iteration threshold value
CN115984249A
Novel center point extraction method based on line laser welding noise resistance
CN121582189A
System and method for efficient surface measurement using a laser displacement sensor
US20140347473A1
Method and device for automatically drawing structural cracks and precisely measuring widths thereof
US20200364849A1