Method and device for selecting and positioning a laser welding machine
Patent Information
- Application Number
- CN202611037765.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-13
- Publication Date
- 2026-10-09
AI Technical Summary
由于二向色镜仅基于波长进行分光,无法区分信号光(反映工件纹理、边缘特征的有效图像信息)与噪声光(强镜面反射光),导致采集到的图像中信噪比极低,工件表面的微观特征(如焊缝起始点的微小缺口、标记点边缘)被强光淹没
[0010]本发明实施例提供的激光焊接机选点定位方法,基于偏振分光组件将工件表面反射光束分解为振动方向相互垂直的第一线偏振光束和第二线偏振光束,并通过两个独立成像通道分别生成第一偏振图像和第二偏振图像,得到包含不同偏振维度的工件表面成像数据,实现对金属表面有效纹理特征反射光与强镜面反射噪声光的偏振维度分离。基于两幅不同偏振特性的图像结果,依托两幅图像预设背景区域的灰度分布比例完成对第二偏振图像的灰度层级映射,生成灰度尺度匹配的匹配偏振图像,消除双偏振图像灰度基准差异带来的数据偏差。基于校准匹配后的匹配偏振图像与第一偏振图像,提取二者对应像素点的灰度差异并生成偏振差分图像,精准剥离两幅图像中重合的强镜面反射高亮噪声区域,保留被强光淹没的工件微观特征有效像素信息,提升图像信噪比、还原清晰的焊缝点位特征。基于降噪后特征清晰的偏振差分图像,筛选出灰度值区别于背景区域的各连通域并计算其几何中心坐标,得到精准的目标执行坐标序列,最后按照预设工艺路径顺序确定首个作业坐标对应的物理位置并驱动激光焊接头完成对位移动,基于最终精准匹配工艺路径的目标对位坐标结果,提高了激光焊接机在高反光金属表面作业时选点定位的准确性。
Smart Images

Figure CN122887822A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of laser processing and machine vision inspection technology, and in particular to a method and apparatus for selecting and positioning laser welding machines. Background Technology
[0002] In precision laser welding, high-precision visual positioning of the welding points before welding is a crucial step in ensuring welding quality. Currently, the industry widely uses coaxial vision systems for welding point identification and positioning. These systems typically integrate a dichroic mirror into the laser beam path. Utilizing the dichroic mirror's high reflectivity for specific wavelengths of laser light and its high transmittance for visible light, the visible light used for illumination and imaging is combined or split with the high-power welding laser, allowing observation of the molten pool or the area to be welded through the same optical lens.
[0003] However, the surfaces of workpieces to be welded (such as aluminum alloys, stainless steel, and other metal sheets) often have high specular reflection characteristics. When a coaxial light source is used for illumination, the illumination light hitting the smooth metal surface produces strong specular reflection light. This reflected light directly enters the camera sensor, forming bright spots or overexposed areas. Since dichroic mirrors only perform spectral splitting based on wavelength, they cannot distinguish between signal light (effective image information reflecting workpiece texture and edge features) and noise light (strong specular reflection light), resulting in an extremely low signal-to-noise ratio in the acquired image. The microscopic features of the workpiece surface (such as tiny notches at the weld initiation point and the edges of marker points) are overwhelmed by the strong light. Therefore, strong reflection interference directly leads to the blurring or even loss of features extracted from the welding point, thereby increasing the deviation in point selection and positioning. In other words, in the background technology, existing methods reduce the accuracy of welding machine point selection and positioning because they cannot effectively suppress strong reflection noise in the coaxial optical path. Summary of the Invention
[0004] This invention provides a method and apparatus for selecting and positioning laser welding machines, aiming to improve the accuracy of point selection and positioning when laser welding machines operate on highly reflective metal surfaces.
[0005] In a first aspect, the present invention provides a laser welding machine point selection and positioning method, comprising: The polarization beam splitting component based on the laser welding head decomposes the reflected beam from the workpiece surface into a first linearly polarized beam and a second linearly polarized beam with mutually perpendicular vibration directions. These beams are then transmitted to the imaging plane via the first imaging channel and the second imaging channel, respectively, to generate a first polarization image and a second polarization image. Based on the grayscale distribution ratio of the first polarization image and the second polarization image in a preset background region, the grayscale levels of the second polarization image are mapped to generate a matching polarization image. A polarization difference image is generated based on the grayscale difference of corresponding pixels in the first polarization image and the matched polarization image; Based on the geometric center coordinates of each connected domain in the polarization difference image whose gray values differ from the background region, a target execution coordinate sequence is generated, and the motion mechanism of the laser welding head is driven to move to the physical position corresponding to the first coordinate point in the target execution coordinate sequence that conforms to the preset process path order.
[0006] In a second aspect, the present invention also provides a laser welding machine point selection and positioning system for implementing the laser welding machine point selection and positioning method as described in the first aspect; the laser welding machine point selection and positioning system includes: The polarization image generation module is used in the polarization beam splitting component based on the laser welding head to decompose the reflected beam on the workpiece surface into a first linearly polarized beam and a second linearly polarized beam with mutually perpendicular vibration directions. The beams are transmitted to the imaging plane through the first imaging channel and the second imaging channel, respectively, to generate a first polarization image and a second polarization image. The grayscale level mapping module is used to map the grayscale level of the second polarization image based on the grayscale distribution ratio of the first polarization image and the second polarization image in a preset background area, so as to generate a matching polarization image. The polarization grayscale difference analysis module is used to generate a polarization difference image based on the grayscale difference of corresponding pixels in the first polarization image and the matched polarization image; The machine-selected point positioning module is used to generate a target execution coordinate sequence based on the geometric center coordinates of each connected domain in the polarization difference image whose gray values differ from the background region, and drive the motion mechanism of the laser welding head to move to the physical position corresponding to the first coordinate point in the target execution coordinate sequence that conforms to the preset process path order.
[0007] Thirdly, the present invention also provides an electronic device, comprising: a memory for storing a computer program; and a processor for reading and executing the computer program, thereby realizing the laser welding machine point selection and positioning method as described above.
[0008] Fourthly, the present invention also provides a non-transitory computer-readable storage medium storing a computer program, which, when executed by a processor, implements the laser welding machine point selection and positioning method as described above.
[0009] Fifthly, the present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the laser welding machine point selection and positioning method as described above.
[0010] The laser welding machine point selection and positioning method provided in this invention decomposes the reflected light beam from the workpiece surface into a first linearly polarized beam and a second linearly polarized beam with mutually perpendicular vibration directions using a polarization beam splitter. Two independent imaging channels are then used to generate a first polarization image and a second polarization image, respectively, resulting in workpiece surface imaging data containing different polarization dimensions. This achieves polarization dimension separation between the reflected light of effective texture features on the metal surface and the noise light of strong specular reflection. Based on the results of two images with different polarization characteristics, the grayscale level of the second polarization image is mapped according to the grayscale distribution ratio of the preset background area in the two images, generating a matched polarization image with grayscale matching, eliminating data deviation caused by the difference in grayscale reference between the two polarization images. Based on the calibrated and matched polarization image and the first polarization image, the grayscale difference of corresponding pixels is extracted and a polarization difference image is generated. This accurately removes the overlapping high-brightness noise areas of strong specular reflection in the two images, retaining the effective pixel information of the workpiece's microscopic features that are submerged by strong light, improving the image signal-to-noise ratio, and restoring clear weld seam point features. Based on the polarization difference image with clear features after noise reduction, each connected region whose gray value is different from the background region is selected and its geometric center coordinates are calculated to obtain a precise target execution coordinate sequence. Finally, the physical position corresponding to the first operation coordinate is determined according to the preset process path sequence and the laser welding head is driven to complete the alignment movement. Based on the final accurate matching process path target alignment coordinate result, the accuracy of point selection and positioning of the laser welding machine when operating on highly reflective metal surfaces is improved. Attached Figure Description
[0011] Figure 1 This is a flowchart illustrating the laser welding machine point selection and positioning method provided in an embodiment of the present invention; Figure 2 This is a schematic diagram of the laser welding machine point selection and positioning system provided in an embodiment of the present invention; Figure 3 An embodiment diagram of the electronic device provided in this invention; Figure 4 An embodiment diagram of a computer-readable storage medium provided in accordance with the present invention. Detailed Implementation
[0012] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, every other embodiment obtained by those skilled in the art without creative effort falls within the scope of protection of the present invention.
[0013] In the description of this invention, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the stated features. In the description of this invention, "a plurality of" means two or more, unless otherwise explicitly specified.
[0014] In the description of this invention, the term "for example" is used to mean "used as an example, illustration, or description." Any embodiment described as "for example" in this invention is not necessarily to be construed as being more preferred or advantageous than other embodiments. The following description is provided to enable any person skilled in the art to make and use the invention. Details are set forth in the following description for purposes of explanation. It should be understood that those skilled in the art will recognize that the invention can be made without using these specific details. In other instances, well-known structures and processes will not be described in detail to avoid obscuring the description of the invention with unnecessary detail. Therefore, the invention is not intended to be limited to the embodiments shown, but is consistent with the broadest scope of the principles and features disclosed herein.
[0015] Optionally, see Figure 1 , Figure 1 This is a flowchart illustrating the laser welding machine point selection and positioning method provided by the present invention. In this embodiment of the invention, the executing entity of the laser welding machine point selection and positioning method is the point selection and positioning system. Therefore, the laser welding machine point selection and positioning method includes: Step 10: Based on the polarization beam splitting component of the laser welding head, the reflected beam from the workpiece surface is decomposed into a first linearly polarized beam and a second linearly polarized beam with mutually perpendicular vibration directions. These beams are then transmitted to the imaging plane via the first imaging channel and the second imaging channel, respectively, to generate a first polarization image and a second polarization image.
[0016] Optionally, before the laser welding head performs welding operations on the workpiece, the point positioning system controls the illumination source to emit illumination light onto the surface of the workpiece. After the illumination light shines on the surface of the workpiece, the surface of the workpiece reflects the illumination light to form a reflected beam.
[0017] Because the surface of the workpiece to be welded (such as the surface of aluminum alloy, stainless steel, and other metal sheets) has high specular reflection characteristics, the reflected light beam contains both specular reflection and diffuse reflection components. The specular reflection component originates from the direct reflection of the illumination light by smooth areas of the workpiece surface, while the diffuse reflection component originates from the scattering of the illumination light by microscopic feature areas of the workpiece surface (such as notches at the weld initiation point, edges of marking points, and other areas with surface morphology variations).
[0018] The reflected beam enters the optical acquisition path of the laser welding head along the normal direction of the workpiece surface and reaches the polarization beam splitter. The polarization beam splitter includes a polarization beam splitter prism. After receiving the reflected beam, the polarization beam splitter prism, based on the principle of polarization beam splitting, decomposes the reflected beam into a first linearly polarized beam and a second linearly polarized beam with mutually perpendicular vibration directions. The angle between the polarization vibration directions of the first and second linearly polarized beams is 90 degrees. Specifically, the specular reflection component and the diffuse reflection component contained in the reflected beam have different polarization characteristics. After being reflected by the surface of the workpiece, the specular reflection component maintains a polarization state basically consistent with the incident illumination light and has a high degree of polarization. After being scattered in multiple directions by the microscopic feature regions of the workpiece surface, the diffuse reflection component undergoes a randomized change in polarization state, its degree of polarization decreases, and it exhibits a partially polarized or unpolarized state. Therefore, when a polarizing beam splitter decomposes a reflected beam into a first linearly polarized beam and a second linearly polarized beam, the energy distribution ratio of the specular reflected light component in the first and second linearly polarized beams is different from that of the diffuse reflected light component.
[0019] A first linearly polarized beam exits from the first exit surface of a polarizing beam splitter and enters a first imaging channel. The first imaging channel includes a first imaging lens group. After being focused and imaged by the first imaging lens group, the first linearly polarized beam is transmitted to a first image sensor positioned on the imaging plane. The first image sensor converts the received optical signal of the first linearly polarized beam into an electrical signal, generating a first polarized image. The first polarized image is a digital image represented in the form of a pixel matrix. Each pixel in the first polarized image corresponds to a grayscale value, with the grayscale value ranging from 0 to 255, where 0 represents pure black and 255 represents pure white.
[0020] The second linearly polarized beam exits from the second exit surface of the polarizing beam splitter and enters the second imaging channel. The second imaging channel includes a second imaging lens group. After the second linearly polarized beam is focused and imaged by the second imaging lens group, it is transmitted to a second image sensor set on the imaging plane. The second image sensor converts the optical signal of the received second linearly polarized beam into an electrical signal to generate a second polarized image.
[0021] The second polarization image is a digital image represented in the form of a pixel matrix. Each pixel in the second polarization image corresponds to a gray value, and the gray value ranges from 0 to 255.
[0022] Since the optical axes of the first imaging channel and the second imaging channel are parallel and their fields of view coincide, the first polarization image and the second polarization image image the same area on the surface of the workpiece to be welded. Each pixel in the first polarization image and its corresponding pixel in the second polarization image point to the same physical location on the surface of the workpiece to be welded. The first polarization image and the second polarization image have the same pixel matrix size, the same number of rows and columns in the pixel matrix of the first polarization image and the second polarization image.
[0023] Step 20: Map the gray levels of the second polarization image to the gray level distribution ratio of the first polarization image and the second polarization image in the preset background area to generate a matched polarization image.
[0024] Optionally, the preset background region is the image region of the smooth, featureless area on the surface of the workpiece to be welded, corresponding to the first polarization image and the second polarization image. The first grayscale distribution ratio is the proportion of the number of pixels at each grayscale level in the preset background region of the first polarization image to the total number of pixels in the preset background region. The second grayscale distribution ratio is the proportion of the number of pixels at each grayscale level in the preset background region of the second polarization image to the total number of pixels in the preset background region. The point selection and positioning system maps the grayscale levels of the second polarization image based on the grayscale distribution ratio of the first polarization image and the second polarization image in the preset background region to generate a matching polarization image, specifically as described in steps 201 to 204. The pixel matrix size of the matching polarization image is the same as that of the second polarization image, and the position of each pixel in the matching polarization image corresponds one-to-one with the position of the corresponding pixel in the second polarization image.
[0025] Step 30: Generate a polarization difference image based on the grayscale difference of corresponding pixels in the first polarization image and the matched polarization image.
[0026] Optionally, the corresponding pixel is the pixel in the first polarization image and the pixel in the matched polarization image that is at the same pixel matrix position (i.e., the same row number and the same column number). The grayscale difference is the numerical difference between the grayscale value of the pixel in the first polarization image and the grayscale value of the corresponding pixel in the matched polarization image. The point selection and positioning system generates a polarization difference image based on the grayscale difference of the corresponding pixels in the first polarization image and the matched polarization image, specifically as in steps 301 to 304. The grayscale value of the background region in the polarization difference image is zero, the grayscale value of the feature region is different from that of the background region, and the grayscale value reflects the degree of difference in polarization response. The pixel matrix size of the polarization difference image is the same as that of the pixel matrix size of the first polarization image. The background region is the image region in the polarization difference image corresponding to the smooth, featureless surface of the workpiece to be welded. The feature region is the image region in the polarization difference image corresponding to the microscopic feature region (such as the notch at the weld start point, the edge of the marker point, etc.) on the surface of the workpiece to be welded. Approaching zero indicates that the grayscale value of the pixel in the background region of the polarization difference image is 0 or close to 0. The difference between the gray values of pixels in the feature region and those in the background region is that there is a distinguishable numerical difference.
[0027] Step 40: Based on the geometric center coordinates of each connected region in the polarization difference image whose gray values differ from the background region, generate a target execution coordinate sequence and drive the motion mechanism of the laser welding head to move to the physical position corresponding to the first coordinate point in the target execution coordinate sequence that conforms to the preset process path order.
[0028] Optionally, the point selection and positioning system performs connected component analysis on the polarization difference image to identify each connected component in the polarization difference image whose grayscale value differs from the background region. A connected component is a continuous region in the polarization difference image composed of adjacent pixels whose grayscale value differs from the background region. Adjacent pixels are pixels that are vertically or horizontally adjacent in the pixel matrix. The geometric center coordinates of each connected component are calculated. Based on the geometric center coordinates of each connected component, a target execution coordinate sequence is generated, as detailed in steps 401 to 404. Each coordinate point in the target execution coordinate sequence corresponds to a welding point on the surface of the workpiece to be welded.
[0029] The preset process path sequence is the execution order of each welding point pre-defined according to the welding process requirements. The point selection and positioning system selects the first coordinate point from the target execution coordinate sequence that conforms to the preset process path sequence as the current target coordinate point. The coordinates of the current target coordinate point are sent to the motion controller of the motion mechanism. The motion controller generates motion control commands based on the coordinates of the current target coordinate point. These commands drive the motion axes of the motion mechanism to move according to the coordinates of the current target coordinate point, causing the laser welding head to move to the physical position corresponding to the current target coordinate point. Once the laser welding head reaches the physical position corresponding to the current target coordinate point, the motion mechanism sends a positioning signal to the point selection and positioning system. The system confirms that the laser welding head is in place, and the laser welding machine performs the welding operation at the current welding point.
[0030] This embodiment improves the accuracy of point selection and positioning when the laser welding machine is operating on highly reflective metal surfaces.
[0031] Optionally, the processes of steps 201 to 204 include: Step 201: Traverse each pixel of the second polarization image, count the number of pixels corresponding to each gray level, and obtain the number of pixels for each gray level in the second polarization image.
[0032] Optionally, the second polarization image is a digital image represented as a pixel matrix. The pixel matrix of the second polarization image has M rows and N columns, where M is the number of rows and N is the number of columns, and both M and N are positive integers. Each pixel in the second polarization image corresponds to a grayscale value, with the grayscale value ranging from 0 to 255, for a total of 256 grayscale levels, where 0 represents pure black and 255 represents pure white. The point selection and positioning system initializes an array containing 256 counting units. The k-th counting unit of the array is used to record the number of pixels with grayscale level k, where k is an integer ranging from 0 to 255. Following a row-by-row and column-by-column traversal order, the grayscale value of the pixel in the i-th row and j-th column of the pixel matrix of the second polarization image is read sequentially, where i is an integer ranging from 1 to M and j is an integer ranging from 1 to N.
[0033] After reading the grayscale value of each pixel, the point selection and positioning system increments the value of the corresponding counting unit by 1. After traversing all M*N pixels in the second polarization image, the 256 counting units in the array store the number of pixels at the corresponding grayscale level. The point selection and positioning system records the value of the k-th counting unit in the array as the number of pixels at grayscale level k in the second polarization image, denoted as C2(k), where k is an integer from 0 to 255. Thus, the number of pixels corresponding to each of the 256 grayscale levels in the second polarization image is obtained as C2(0), C2(1), C2(2)...C2(255).
[0034] Step 202: Based on the number of pixels at each gray level in the second polarization image, the pixels are accumulated in ascending order of gray level and divided by the total number of pixels in the second polarization image to obtain the actual cumulative background ratio of each gray level in the second polarization image.
[0035] Optionally, the point selection and localization system, based on the number of pixels C2(k) at each gray level in the second polarization image, accumulates the number of pixels level by level according to the increasing order of gray level k from 0 to 255, and calculates the accumulated value when the gray level is k. The accumulated value is the sum of the number of pixels from gray level 0 to gray level k, i.e., C2(0) + C2(1) + C2(2) + ... + C2(k). The point selection and localization system divides the accumulated value by the total number of pixels S2 in the second polarization image, where S2 = M*N, to obtain the actual background cumulative proportion A2(k) at gray level k in the second polarization image. The calculation process of the actual background cumulative proportion A2(k) is as follows: divide the sum of C2(0) + C2(1) + C2(2) + ... + C2(k) by S2.
[0036] According to the above calculation process, the point selection and positioning system calculates the actual background cumulative proportion A2(0), A2(1), A2(2)...A2(255) for each gray level from k to 255.
[0037] The actual cumulative background percentage for each gray level represents the proportion of pixels less than or equal to the current gray level in the second polarization image. When k=255, the value of A2(255) is 1, indicating that the gray values of all pixels in the second polarization image are less than or equal to 255.
[0038] Step 203: Based on the first grayscale distribution ratio and the second grayscale distribution ratio, the grayscale levels are accumulated in ascending order to obtain the first background cumulative ratio and the second background cumulative ratio for each grayscale level corresponding to the background distribution.
[0039] Optionally, the point positioning system acquires a first grayscale distribution ratio and a second grayscale distribution ratio. In the first grayscale distribution ratio, the proportion of pixels with grayscale level k in a preset background region of the first polarized image to the total number of pixels in the preset background region is denoted as P1(k), where k is an integer from 0 to 255. In the second grayscale distribution ratio, the proportion of pixels with grayscale level k in a preset background region of the second polarized image to the total number of pixels in the preset background region is denoted as P2(k), where k is an integer from 0 to 255.
[0040] The point selection and positioning system accumulates the first gray-level distribution ratio P1(k) step by step according to the increasing order of gray-level k from 0 to 255, and calculates the first background cumulative proportion when the gray-level is k, denoted as B1(k). The calculation process of the first background cumulative proportion B1(k) is as follows: the sum of P1(0) + P1(1) + P1(2) + ... + P1(k) is taken as the value of B1(k). The first background cumulative proportion B1(k) represents the proportion of pixels less than or equal to gray-level k in the preset background area of the first polarization image. According to the above calculation process, the point selection and positioning system calculates the first background cumulative proportion B1(0), B1(1), B1(2) ... B1(255) corresponding to each gray-level from k to 255. When k = 255, the value of B1(255) is 1.
[0041] The point selection and positioning system accumulates the second grayscale distribution ratio P2(k) step by step according to the increasing order of grayscale level k from 0 to 255, and calculates the second background cumulative proportion when the grayscale level is k, denoted as B2(k). The calculation process of the second background cumulative proportion B2(k) is as follows: the sum of P2(0) + P2(1) + P2(2) + ... + P2(k) is taken as the value of B2(k). The second background cumulative proportion B2(k) represents the proportion of pixels less than or equal to grayscale level k in the preset background area of the second polarization image. According to the above calculation process, the point selection and positioning system calculates the second background cumulative proportion B2(0), B2(1), B2(2) ... B2(255) corresponding to each grayscale level from k to 255 one by one. When k=255, the value of B2(255) is 1.
[0042] Step 204: Map the gray levels of the second polarization image based on the actual cumulative ratio, the first background cumulative ratio, and the second background cumulative ratio to generate a matched polarization image.
[0043] Optionally, the point selection and positioning system maps the grayscale levels of the second polarization image based on the actual cumulative ratio, the first background cumulative ratio, and the second background cumulative ratio to generate a matching polarization image, as described in steps 2041 to 2043.
[0044] In this embodiment of the invention, the gray-scale cumulative distribution of the matched polarization image in the background region tends to align with the gray-scale cumulative distribution of the first polarization image in the background region, eliminating the systematic gray-scale deviation between the two imaging channels. This allows the gray-scale values in the background region to be effectively canceled out and approach zero when the first polarization image and the matched polarization image are subsequently differentially analyzed. The feature region retains gray-scale differences due to the energy distribution differences between the specular reflection light component and the diffuse reflection light component in the two polarization directions. Ultimately, this improves the contrast between the feature region and the background region in the polarization difference image, thereby improving the accuracy of point selection and positioning when the laser welding machine operates on highly reflective metal surfaces.
[0045] Optionally, the processes of steps 2041 to 2043 include: Step 2041: Determine the common linear mapping grayscale range based on the grayscale levels in the first background cumulative proportion and the second background cumulative proportion that are both within the middle preset proportion range.
[0046] Optionally, the intermediate preset ratio range is the cumulative ratio value range, the lower limit of the intermediate preset ratio range is the first ratio threshold, the upper limit is the second ratio threshold, the first ratio threshold is less than the second ratio threshold, and both the first ratio threshold and the second ratio threshold are values greater than 0 and less than 1.
[0047] The point selection and positioning system searches for the gray level corresponding to the first lower limit gray level when the value first exceeds or equals the first proportion threshold in the first background cumulative proportions B1(0), B1(1), B1(2), ..., B1(255). This gray level is denoted as k. 1-I0 w; Among the 256 cumulative proportions of the first background B1(0), B1(1), B1(2)...B1(255), find the gray level corresponding to the first time the value is greater than or equal to the second proportion threshold, and record this gray level as the first upper limit gray level, denoted as k. 1-hi g h Therefore, the gray levels within the middle preset ratio range of the first background cumulative proportion are from k. 1-I0 w to k 1-hi g h A series of consecutive integer gray levels.
[0048] The point selection and positioning system searches for the gray level corresponding to the first proportion threshold value when the cumulative proportion of the second background B2(0), B2(1), B2(2)...B2(255) is first greater than or equal to the first proportion threshold. This gray level is denoted as the second lower limit gray level and k. 2-I0 w; Among the 256 cumulative proportions of the second background B2(0), B2(1), B2(2)...B2(255), find the gray level corresponding to the first time the value is greater than or equal to the second proportion threshold, and record this gray level as the second upper limit gray level, denoted as k.2-h ig h Therefore, the gray levels within the middle preset ratio range of the second background cumulative proportion are from k. 2-I0 w to k 2-hi g h A series of consecutive integer gray levels.
[0049] The point selection and positioning system will k 1-I0 w and k 2-I0 The larger value in w is determined as the common lower limit gray level, and k 1-hi g h With k 2-hi g h The smaller value in the range is determined as the common upper limit gray level, and the consecutive integer gray levels from the common lower limit gray level to the common upper limit gray level are determined as the common linear mapping gray range.
[0050] The common linear mapping grayscale range is a continuous interval formed by grayscale levels where the cumulative proportion of the first background and the cumulative proportion of the second background are both within the middle preset proportion range. Each grayscale level within the common linear mapping grayscale range has an effective cumulative proportion distribution in the preset background region of the first polarization image and the preset background region of the second polarization image.
[0051] Step 2042: Within the common linear mapping grayscale range, for each grayscale level, find the grayscale level whose first background cumulative proportion of each grayscale level corresponding to the background distribution is closest to the actual cumulative proportion of each grayscale level in the second polarization image, establish the correspondence between the two grayscale levels, and obtain the grayscale correspondence of the common linear mapping grayscale range.
[0052] Optionally, the point selection and positioning system performs the following search process for each gray level k within the common linear mapping gray range to read the actual cumulative background proportion A2(k) corresponding to gray level k.
[0053] The point selection and positioning system calculates the absolute difference between each of the first background cumulative proportions B1(m), B1(1), B1(2)...B1(255), and the actual background cumulative proportion A2(k). The absolute difference is the absolute value of the difference obtained by subtracting A2(k) from B1(m), where m is an integer from 0 to 255. The point selection and positioning system searches for the smallest absolute difference among the 256 absolute differences and records the gray level m corresponding to the smallest absolute difference as the mapped gray level k, denoted as k'. If there are two or more gray levels m with the same absolute difference and both being the minimum value, the gray level m with the smallest value is selected as the mapped gray level k'. The point selection and positioning system establishes a correspondence between gray level k and mapped gray level k', and records the correspondence as ordered pairs (k, k'). The above search process is performed on each gray level k within the common linear mapping gray range to obtain the mapped gray level k' corresponding to each gray level within the common linear mapping gray range. The set of all ordered pairs (k, k') is taken as the gray correspondence within the common linear mapping gray range.
[0054] Step 2043: Traverse each pixel of the second polarization image. If the gray level of the pixel is within the common linear mapping gray level range, replace the pixel's gray level with the corresponding mapped gray level based on the gray level correspondence of the common linear mapping gray level range. If the gray level of the pixel is not within the common linear mapping gray level range, keep the pixel's original gray level unchanged to obtain the matched polarization image.
[0055] Optionally, the point positioning system creates a blank image with the same pixel matrix size as the second polarization image as the image to be filled. The pixel matrix of the image to be filled has M rows and N columns. The initial gray value of each pixel in the image to be filled is 0. The gray value of the pixel in the i-th row and j-th column of the pixel matrix of the second polarization image is read sequentially according to the traversal order of row by row and column by column. The gray value is recorded as the current gray level kᵢⱼ, where the value of i is an integer from 1 to M and the value of j is an integer from 1 to N.
[0056] The point selection and positioning system determines whether the current gray level kᵢⱼ is within the common linear mapping gray level range determined in step 2041. Specifically, it determines whether the current gray level kᵢⱼ is greater than or equal to the common lower limit gray level and less than or equal to the common upper limit gray level. If the current gray level kᵢⱼ is greater than or equal to the common lower limit gray level and less than or equal to the common upper limit gray level, then the mapping gray level k'ᵢⱼ corresponding to the current gray level kᵢⱼ is searched in the gray level correspondence obtained in step 2042, and the gray level of the pixel in the i-th row and j-th column of the image to be filled is set as the mapping gray level k'ᵢⱼ. If the current gray level kᵢⱼ is less than the common lower limit gray level or greater than the common upper limit gray level, then the gray value of the pixel in the i-th row and j-th column of the image to be filled is set to the current gray level kᵢⱼ, that is, the original gray level of the pixel is kept unchanged.
[0057] After traversing all pixels in the second polarization image, the grayscale value of each pixel in the image to be filled has been assigned. The point selection and localization system determines the image to be filled after the assignment as the matching polarization image. The pixel matrix size of the matching polarization image is the same as that of the second polarization image, and the position of each pixel in the matching polarization image corresponds to the position of the corresponding pixel in the second polarization image.
[0058] In this embodiment of the invention, pixels within the common linear mapping grayscale range are replaced according to their grayscale correspondence, while pixels outside the common linear mapping grayscale range retain their original grayscale values. This ensures the effectiveness of grayscale alignment in the background region and avoids the image quality degradation caused by unreliable mapping in the tail region. As a result, the grayscale distribution in the background region of the final generated matched polarization image tends to be consistent with the grayscale distribution in the background region of the first polarization image. This allows the grayscale values in the background region to be effectively canceled out and approach zero when the first polarization image and the matched polarization image are subsequently differentially analyzed. The feature region retains its grayscale difference due to the energy distribution difference between the specular reflection light component and the diffuse reflection light component in the two polarization directions, thereby improving the contrast between the feature region and the background region in the polarization difference image and thus improving the accuracy of point selection and positioning when the laser welding machine is operating on a highly reflective metal surface.
[0059] Optionally, the processes of steps 301 to 304 include: Step 301: Traverse each pixel in the first polarization image and the matching polarization image that has the same spatial position, and obtain the original gray level difference of each pixel based on the difference between the gray level of the current pixel in the first polarization image and the gray level of the corresponding pixel in the matching polarization image.
[0060] Optionally, the point positioning system creates a difference matrix with M rows and N columns. The difference matrix stores the original grayscale difference values of each pixel, and the initial value of each element in the difference matrix is 0. Pixels with the same spatial position in the first polarization image and the matched polarization image are processed sequentially, row by row and column by column. For the pixel in the i-th row and j-th column, the grayscale value of the pixel in the i-th row and j-th column of the first polarization image is read and denoted as the first grayscale value G1(i, j). At the same time, the grayscale value of the pixel in the i-th row and j-th column of the matched polarization image is read and denoted as the second grayscale value G2(i, j), where i is an integer from 1 to M and j is an integer from 1 to N. The point selection and positioning system calculates the difference between the first gray value G1(i,j) and the second gray value G2(i,j). The difference is the value obtained by subtracting the second gray value G2(i,j) from the first gray value G1(i,j). This difference is recorded as the original gray value difference of the pixel in the i-th row and j-th column, denoted as D(i,j). The original gray value difference D(i,j) ranges from -255 to an integer between 255 and 255.
[0061] The point selection and localization system stores the original grayscale difference D(i,j) in the i-th row and j-th column of the difference matrix. After traversing all M*N pixels, each element in the difference matrix stores the original grayscale difference of the corresponding pixel. The point selection and localization system uses the set of all M*N original grayscale differences in the difference matrix as the original grayscale difference of each pixel.
[0062] Step 302: Take the absolute value of the original grayscale difference of each pixel to obtain the absolute grayscale difference of each pixel, and iterate through the absolute grayscale difference of each pixel to count the number of pixels corresponding to each difference level to obtain the frequency distribution of the absolute grayscale difference.
[0063] Optionally, the point selection and positioning system takes the absolute value of the original grayscale difference D(i,j) of each element in the difference matrix. The absolute value is equal to D(i,j) itself when D(i,j) is greater than or equal to 0; and equal to D(i,j) multiplied by -1 when D(i,j) is less than 0. The point selection and positioning system records the value obtained after taking the absolute value as the absolute grayscale difference of the pixel in the i-th row and j-th column, denoted as |D(i,j)|. The absolute grayscale difference |D(i,j)| ranges from 0 to 255.
[0064] The point selection and positioning system initializes a difference frequency array containing 256 counting units. The d-th counting unit of the difference frequency array records the number of pixels with an absolute grayscale difference of d, where d is an integer ranging from 0 to 255. The initial value of each counting unit in the difference frequency array is 0. Following a row-by-row, column-by-column traversal order, the absolute grayscale difference |D(i,j)| of each element in the difference matrix is read sequentially. After reading each absolute grayscale difference, the value of the corresponding counting unit in the difference frequency array is incremented by 1. After traversing all M*N absolute grayscale differences, the 256 counting units of the difference frequency array store the number of pixels at the corresponding difference level.
[0065] The point selection and positioning system records the value of the d-th counting unit in the difference frequency array as the number of pixels corresponding to the difference level d, denoted as F(d), where d is an integer from 0 to 255. Thus, the number of pixels corresponding to each of the 256 difference levels is obtained as F(0), F(1), F(2)...F(255).
[0066] The point selection and localization system determines the sequence F(0), F(1), F(2)...F(255) as the absolute gray-level difference frequency distribution. The absolute gray-level difference frequency distribution reflects the distribution of the number of pixels in the difference between the first polarization image and the matched polarization image at each difference level.
[0067] Step 303: In the frequency distribution of absolute gray-level differences, select the continuous difference level with the most pixels and determine it as the difference threshold level dominated by background noise. Then, perform a mapping judgment based on each difference level and the difference threshold level in the absolute gray-level differences to obtain the mapping judgment result.
[0068] Optionally, the point selection and positioning system searches for the difference level with the largest number of pixels F(d) in the frequency distribution of absolute gray-level differences F(0), F(1), F(2)...F(255), and records the difference level with the largest number of pixels as the peak difference level, denoted as dp. The peak difference level dp is the d value corresponding to the maximum value of F(d). If there are two or more difference levels d with the same F(d) and both being the maximum value, then the difference level d with the smallest value is selected as the peak difference level dp.
[0069] The point selection and localization system starts from the peak difference level dp and checks the number of pixels in each adjacent difference level in the direction of increasing difference levels. Specifically, it checks if F(dp+1) is greater than 0. If F(dp+1) is greater than 0, it continues to check if F(dp+2) is greater than 0, and so on, until a difference level dmax is found such that F(dmax) is greater than 0 and F(dmax+1) is equal to 0, or dmax is equal to 255. The point selection and localization system determines dmax as the upper limit value of continuous difference levels.
[0070] The point selection localization system starts from the peak difference level dp and checks the number of pixels in adjacent difference levels one by one in the direction of decreasing difference levels. Specifically, the system checks if F(dp-1) is greater than 0. If F(dp-1) is greater than 0, it checks if F(dp-2) is greater than 0, and so on, until a difference level dmin is found such that F(dmin) is greater than 0 and F(dmin-1) is equal to 0, or dmin is equal to 0. The system then determines dmin as the lower limit of the continuous difference levels.
[0071] The point selection and positioning system determines the continuous integer difference level from dmin to dmax as the continuous difference level with the most pixels. The system then determines dmax as the difference threshold level dominated by background noise, denoted as Tn. The difference threshold level Tn represents the maximum boundary value of the absolute gray-level difference generated by the residual gray-level deviation of the background region in the frequency distribution of absolute gray-level differences. That is, pixels with an absolute gray-level difference less than or equal to Tn are mainly contributed by the residual gray-level deviation of the background region, while pixels with an absolute gray-level difference greater than Tn are mainly contributed by the polarization response differences of the microscopic feature regions on the surface of the workpiece to be welded.
[0072] The point selection and localization system compares the absolute grayscale difference |D(i,j)| of each pixel with a difference threshold level Tn. If the absolute grayscale difference |D(i,j)| is less than or equal to the difference threshold level Tn, the mapping judgment result of the pixel in the i-th row and j-th column is determined as the first judgment value, indicating that the pixel belongs to the background region. If the absolute grayscale difference |D(i,j)| is greater than the difference threshold level Tn, the mapping judgment result of the pixel in the i-th row and j-th column is determined as the second judgment value, indicating that the pixel belongs to the feature region. The point selection and localization system determines the mapping judgment result matrix as a matrix composed of the mapping judgment results of all M*N pixels. The mapping judgment result matrix has M rows and N columns, and the value of each element in the mapping judgment result matrix is either the first judgment value or the second judgment value.
[0073] Step 304: Perform polarization difference analysis based on the mapping judgment results to generate a polarization difference image.
[0074] Optionally, the point selection and positioning system performs polarization difference analysis based on the mapping judgment result to generate a polarization difference image, as described in steps 3041 to 3044.
[0075] In this embodiment of the invention, pixels belonging to the background region and pixels belonging to the feature region are assigned values according to different rules. This effectively suppresses the gray values of the background region in the generated polarization difference image, making them approach zero, while the gray values of the feature region are preserved and distinguished from the background region. This improves the contrast and separability of the feature region and the background region in the polarization difference image, providing image support for the subsequent accurate extraction of the geometric center coordinates of the welding point through connected component analysis. This, in turn, improves the accuracy of point selection and positioning when the laser welding machine is working on a highly reflective metal surface.
[0076] Optionally, the processes of steps 3041 to 3044 include: Step 3041: For each difference level in the absolute grayscale difference, if the mapping judgment result indicates that the difference level belongs to the difference threshold level, then map it to zero; if the mapping judgment result indicates that the difference level does not belong to the difference threshold level, then keep its original difference level unchanged, and obtain the difference suppression mapping relationship.
[0077] Optionally, if the difference level d is less than or equal to the difference threshold level Tn, the mapping result corresponding to the difference level d is set to 0, i.e., the mapped difference level is 0. If the difference level d is greater than the difference threshold level Tn, the mapping result corresponding to the difference level d is set to d itself, i.e., the mapped difference level is equal to the original difference level d. The point selection and positioning system combines each difference level d and its corresponding mapping result into an ordered pair (d, d') according to the increasing order of difference levels d from 0 to 255, where d is the original difference level and d' is the mapped difference level. The point selection and positioning system defines the set of 256 ordered pairs (d, d') as the difference suppression mapping relationship. The difference suppression mapping relationship characterizes the mapping rule for each integer difference level in the range of 0 to 255: difference levels less than or equal to the difference threshold level Tn are mapped to 0, and difference levels greater than the difference threshold level Tn remain unchanged.
[0078] Step 3042: Traverse each pixel of the second polarization image, and replace the absolute grayscale difference of each pixel with the corresponding processed difference based on the difference suppression mapping relationship to obtain the suppressed grayscale difference image.
[0079] Optionally, the absolute grayscale difference |D(i,j)| of each pixel obtained in step 302 of the point selection and positioning system, where i is an integer ranging from 1 to M, j is an integer ranging from 1 to N, M is the number of rows in the pixel matrix, N is the number of columns in the pixel matrix, and the absolute grayscale difference |D(i,j)| is an integer ranging from 0 to 255. The point selection and positioning system creates a processed difference matrix with M rows and N columns. The initial value of each element in the processed difference matrix is 0. The absolute grayscale difference |D(i,j)| of each pixel is read sequentially according to the traversal order of row by row and column by column. For the pixel in the i-th row and j-th column, the value of the absolute grayscale difference |D(i,j)| is used as the index value. The mapping result d' corresponding to the index value is found in the difference suppression mapping relationship. The element in the i-th row and j-th column of the processed difference matrix is assigned the value of the mapping result d'. After traversing all M*N pixels, each element in the processed difference matrix stores the processed difference value for the corresponding pixel. The point selection and localization system determines the processed difference matrix as the suppressed gray-level difference image. The suppressed gray-level difference image is a digital image with an M-row, N-column pixel matrix. The gray-level value of each pixel in the suppressed gray-level difference image is the processed difference value, which ranges from 0 to 255.
[0080] Step 3043 involves linearly amplifying the non-zero pixel values in the suppressed gray-level difference image to obtain the enhanced gray-level difference image. This linear amplification increases the gray-level interval between the feature region and the background region.
[0081] Optionally, the point selection and localization system traverses all M*N pixels in the suppressed grayscale difference image for the processed difference values, finds the largest processed difference value, and records it as the maximum difference value, denoted as Dmax. If the maximum difference value Dmax equals 0, it means that the processed difference value of all pixels in the suppressed grayscale difference image is 0, and the point selection and localization system directly determines the suppressed grayscale difference image as the enhanced grayscale difference image. If the maximum difference value Dmax is greater than 0, the point selection and localization system creates a blank image with an M-row N-column pixel matrix as the image to be enhanced. The initial grayscale value of each pixel in the image to be enhanced is 0. Following the traversal order row by row and column by column, the processed difference value of the pixel in the i-th row and j-th column of the suppressed grayscale difference image is read sequentially and recorded as the current difference value V(i, j), where the value of i is an integer from 1 to M, and the value of j is an integer from 1 to N.
[0082] If the current difference V(i,j) equals 0, then the grayscale value of the pixel in the i-th row and j-th column of the image to be enhanced is set to 0. If the current difference V(i,j) is greater than 0, then a linear amplification calculation is performed on the current difference V(i,j). The linear amplification calculation process is as follows: divide the current difference V(i,j) by the maximum difference Dmax to obtain the normalization ratio, multiply the normalization ratio by 255 to obtain the amplified grayscale value, round the amplified grayscale value down to an integer, if the rounded integer is greater than 255, then set the rounded integer to 255, and set the grayscale value of the pixel in the i-th row and j-th column of the image to be enhanced to the integer obtained from the linear amplification calculation.
[0083] After traversing all M*N pixels, the grayscale value of each pixel in the image to be enhanced has been assigned. The point selection and localization system determines the enhanced image as the enhanced grayscale difference image, which is a digital image with an M x N pixel matrix. The grayscale value of each pixel in the enhanced grayscale difference image ranges from 0 to 255. In the enhanced grayscale difference image, the grayscale value of the background pixels is 0, while the grayscale value of the feature pixels is stretched to a grayscale range greater than 0 after linear amplification, thus increasing the grayscale interval between the feature and background regions. This linear amplification of the grayscale interval between the feature and background regions means that the difference between the minimum non-zero grayscale value of the feature pixels and the grayscale value of 0 in the background pixels in the enhanced grayscale difference image is greater than the difference between the minimum non-zero processed difference of the feature pixels and the processed difference of 0 in the background pixels in the suppressed grayscale difference image.
[0084] Step 3044: Arrange the pixel data of the enhanced grayscale difference image according to the image format to generate a polarization difference image.
[0085] Optionally, the point selection and positioning system arranges the pixel data of the enhanced grayscale difference image according to the image format to generate a polarization difference image.
[0086] In the polarization difference image generated by the present invention, the gray value of the background area is effectively suppressed to zero, and the gray value of the feature area has sufficient gray dynamic range after linear amplification, which improves the accuracy of point selection and positioning when the laser welding machine is working on a highly reflective metal surface.
[0087] Optionally, the processes of steps 401 to 404 include: Step 401: Traverse each pixel of the polarization difference image. If the gray value of a pixel is greater than zero, then the pixel is determined as a foreground pixel. If the gray value of a pixel is equal to zero, then the pixel is determined as a background pixel.
[0088] Optionally, the point selection and localization system creates a binary label matrix with M rows and N columns. Each element in the binary label matrix is initially set to 0. Following a row-by-row, column-by-column traversal order, the grayscale value of the pixel in the i-th row and j-th column of the polarization difference image's pixel matrix is read sequentially, where i is an integer from 1 to M, and j is an integer from 1 to N. The point selection and localization system then determines whether the grayscale value is greater than 0.
[0089] If the grayscale value is greater than 0, the element in the i-th row and j-th column of the binary label matrix is assigned a value of 1, indicating that the pixel in the i-th row and j-th column is determined as a foreground pixel. A foreground pixel is a pixel with a grayscale value greater than 0, and it corresponds to a pixel in a feature region of the polarization difference image.
[0090] If the grayscale value is 0, then the element in the i-th row and j-th column of the binary label matrix is kept as 0, indicating that the pixel in the i-th row and j-th column is determined as a background pixel. The background pixel is the pixel with a grayscale value of 0, and the background pixel corresponds to the pixel in the background region of the polarization difference image.
[0091] After traversing all M*N pixels, each element in the binary label matrix is assigned a value of 0 or 1. The pixels corresponding to the elements with a value of 1 in the binary label matrix are determined as foreground pixels, and the pixels corresponding to the elements with a value of 0 are determined as background pixels.
[0092] Step 402: Traverse each row of pixels in the polarization difference image. For consecutive foreground pixels in each row, determine the row direction connectivity information based on their start and end column coordinates. Compare the row direction connectivity information of adjacent rows. If a row direction connectivity segment in the current row overlaps or is adjacent to a row direction connectivity segment in the previous row in terms of column coordinates, then the two row direction connectivity segments are assigned to the same connected component. If there is no overlap or adjacency, then a new connected component is assigned to the row direction connectivity segment of the current row.
[0093] Optionally, the point selection and positioning system initializes a connected component counter with an initial value of 0. The connected component counter is used to record the assigned connected component numbers. It also initializes a row direction connected segment list, which stores information about all detected row direction connected segments in each row. Finally, it initializes a connected component attribution table, which records the connected component number to which each row direction connected segment belongs.
[0094] The point selection and localization system processes the pixels in each row of the polarization difference image in ascending order of row number i from 1 to M. For the i-th row, the system reads the element value of the j-th column in the i-th row of the binary label matrix in ascending order of column number j from 1 to N. During the traversal of the pixels in the i-th row, consecutive foreground pixel segments are detected. Specifically, when a pixel with an element value of 1 is first encountered in the i-th row, its column number j is recorded as the starting column coordinate of the current consecutive foreground pixel segment, denoted as js. The system continues to traverse along the ascending column direction. If the element value of the subsequent adjacent pixel is also 1, it continues to traverse along the ascending column direction until a pixel with an element value of 0 is encountered or column number j reaches N. The column number of the last pixel with an element value of 1 is recorded as the ending column coordinate of the current consecutive foreground pixel segment, denoted as je.
[0095] The point selection and localization system records each consecutive foreground pixel segment detected in the i-th row as a row-direction connected segment. This segment includes the row number i, the starting column coordinate js, and the ending column coordinate je. The system stores the information of all row-direction connected segments in the i-th row in a row-direction connected segment list. This information represents the horizontal position range of all foreground pixel segments in each row; that is, each row-direction connected segment occupies a consecutive position from column js to column je in the i-th row. After detecting all row-direction connected segments in the i-th row, the system determines the connected component affiliation for each segment. Specifically, if i equals 1 (i.e., the current row is the first row), a new connected component number is assigned to each row-direction connected segment in the first row. Each time a new connected component number is assigned, the connected component counter is incremented by 1. The incremented counter value is used as the new connected component number, and this number is recorded in the connected component affiliation table and associated with the corresponding row-direction connected segment.
[0096] If i is greater than 1, then each row-direction connected segment in row i is compared with each row-direction connected segment in row i-1 for column coordinate overlap or adjacency. Specifically, for the row-direction connected segment in row i with starting column coordinate js1 and ending column coordinate je1, and the row-direction connected segment in row i-1 with starting column coordinate js2 and ending column coordinate je2, it is determined whether they overlap or are adjacent in column coordinates. The condition for overlap or adjacency is: js1 is less than or equal to je2+1, and je1 is greater than or equal to js2-1. If the condition is true, it means that the row-direction connected segment in row i overlaps or is adjacent to the row-direction connected segment in row i-1 in column coordinates. If a row-direction connected segment in row i overlaps or is adjacent to a row-direction connected segment in row i-1 on the column coordinate, then the connected component number of the row-direction connected segment in row i is set to the connected component number of the row-direction connected segment in row i-1 that overlaps or is adjacent to it, and this connected component number is recorded in the connected component attribution table. If a row-direction connected segment in row i overlaps or is adjacent to multiple row-direction connected segments in row i-1 on the column coordinate, then the connected component number of the row-direction connected segment in row i is set to the smallest connected component number among the multiple connected component numbers of the row-direction connected segments in row i-1 that overlap or are adjacent to it, and the smallest connected component number is simultaneously updated in the connected component attribution table of all row-direction connected segments in row i-1 that overlap or are adjacent to it, thus merging the connected component numbers.
[0097] If there exists a row-direction connected segment in row i that does not overlap or adjoin any row-direction connected segments in row i-1 in terms of column coordinates, then a new connected component number is assigned to that row-direction connected segment. Each time a new connected component number is assigned, the value of the connected component counter is incremented by 1, and the incremented value of the connected component counter is used as the new connected component number, which is then recorded in the connected component attribution table.
[0098] After traversing all M rows, the connected component attribution table records the connected component number to which each row-direction connected segment belongs. The point selection and positioning system removes duplicate connected component numbers from the connected component attribution table, renumbering the remaining connected component numbers in ascending order as 1, 2, 3...L, where L is the total number of deduplicated connected components and L is a positive integer. The point selection and positioning system then replaces all original connected component numbers in the connected component attribution table with the renumbered connected component numbers.
[0099] Step 403: Traverse each foreground pixel of the polarization difference image, sum the row coordinates of all foreground pixels belonging to the same connected component to obtain the total row coordinate value, and sum the column coordinates of all foreground pixels belonging to the same connected component to obtain the total column coordinate value.
[0100] Optionally, the point selection and positioning system initializes L row coordinate accumulators, L column coordinate accumulators, and L pixel counters. The l-th row coordinate accumulator, l-th column coordinate accumulator, and l-th pixel counter correspond to the l-th connected component, and the value of l ranges from 1 to L. Each row coordinate accumulator, each column coordinate accumulator, and each pixel counter is initialized to 0. Following a row-by-row, column-by-column traversal order, the element value in the i-th row and j-th column of the binary label matrix is read sequentially, where i ranges from 1 to M and j ranges from 1 to N. If the element value is 0, the pixel is skipped, and the traversal continues to the next pixel. If the element value is 1, the connected component number l to which the foreground pixel in the i-th row and j-th column belongs is determined based on the row direction connected segment information and connected component attribution table determined in step 402. Specifically, in the list of row-direction connected segments, find the row-direction connected segment with row number i, starting column coordinate js less than or equal to j, and ending column coordinate je greater than or equal to j. Then, in the connected component attribution table, find the connected component number l to which this row-direction connected segment belongs. Add the value of the l-th row coordinate accumulator to the row coordinate i of the current pixel, add the value of the l-th column coordinate accumulator to the column coordinate j of the current pixel, and increment the value of the l-th pixel counter by 1.
[0101] After traversing all M*N pixels, the value stored in the l-th row coordinate accumulator is the total row coordinate of all foreground pixels in the l-th connected component, denoted as Rl; the value stored in the l-th column coordinate accumulator is the total column coordinate of all foreground pixels in the l-th connected component, denoted as Cl; and the value stored in the l-th pixel counter is the total number of foreground pixels in the l-th connected component, denoted as Nl, where l is an integer ranging from 1 to L. The total row coordinate value Rl and the total column coordinate value Cl represent the linearly accumulated values of all pixel positions in the l-th connected component.
[0102] Step 404: Generate a candidate point coordinate sequence based on the total row coordinates and total column coordinates of each connected component, and convert the pixel coordinates in the candidate point coordinate sequence from the spatial coordinate system to the physical coordinates under the mechanical motion coordinate system based on the preset transformation mapping relationship, thereby generating the target execution coordinate sequence.
[0103] Optionally, the point selection and positioning system generates a sequence of candidate point coordinates based on the total row coordinates Rl, the total column coordinates Cl, and the total number of foreground pixels Nl of each of the L connected components, as described in steps 4041 to 4044.
[0104] The preset transformation mapping relationship is a pre-defined mapping relationship that converts the pixel coordinates of the polarization difference image from the spatial coordinate system to the physical coordinates under the mechanical motion coordinate system of the laser welding machine. The spatial coordinate system is a two-dimensional image coordinate system established with the upper left corner of the pixel matrix of the polarization difference image as the origin, the row direction as the vertical axis, and the column direction as the horizontal axis. The mechanical motion coordinate system is the physical coordinate system used by the mechanical motion mechanism of the laser welding machine to control the spatial position of the welding head. According to the preset transformation mapping relationship, the point selection and positioning system converts the pixel coordinates of each geometric center coordinate in the candidate point coordinate sequence into physical coordinates under the mechanical motion coordinate system. The point selection and positioning system arranges the L converted physical coordinates in the original sequence order to generate the target execution coordinate sequence. The target execution coordinate sequence is an ordered set of L physical coordinates that the mechanical motion mechanism of the laser welding machine can recognize and execute sequentially.
[0105] In the final target execution coordinate sequence generated by this invention, each physical coordinate precisely corresponds to the geometric center position of a microscopic feature area on the surface of the workpiece to be welded. The mechanical motion mechanism of the laser welding machine can move the welding head to each feature area in sequence according to the order of the physical coordinates in the target execution coordinate sequence to perform welding operations. This achieves accurate extraction of welding points and direct drive of the mechanical motion mechanism, improving the accuracy of point selection and positioning when the laser welding machine is working on highly reflective metal surfaces.
[0106] Optionally, the processes of steps 4041 to 4044 include: Step 4041: Count the number of foreground pixels belonging to the same connected component to obtain the number of pixels in each connected component.
[0107] Optionally, the point selection and positioning system obtains the total number of foreground pixels Nl stored in each of the L pixel counters obtained in step 403, where l is an integer ranging from 1 to L, and L is the total number of connected components after deduplication in step 402, and L is a positive integer. The total number of foreground pixels Nl stored in the l-th pixel counter is the value obtained by traversing and accumulating the counts of all foreground pixels in the l-th connected component in step 403, and the total number of foreground pixels Nl is a positive integer. The point selection and positioning system determines the total number of foreground pixels Nl stored in the l-th pixel counter as the number of pixels in the l-th connected component, denoted as Sl, and uses the number of pixels S1, S2, S3...SL of each of the L connected components as the number of pixels in each connected component.
[0108] Step 4042: For each connected component, divide the total value of its corresponding row coordinates by the number of pixels to obtain the geometric center row coordinates of the connected component.
[0109] Optionally, for the l-th connected component, the point selection and localization system divides the total row coordinate value Rl by the number of pixels Sl to obtain the geometric center row coordinate of the l-th connected component, denoted as Yl. The geometric center row coordinate Yl is the quotient obtained by dividing the total row coordinate value Rl by the number of pixels Sl. The geometric center row coordinate Yl represents the centroid position of the feature region corresponding to the l-th connected component in the vertical direction, which is the direction of increasing row number in the pixel matrix of the polarization difference image. The point selection and localization system performs the above division operation on each of the L connected components to obtain L geometric center row coordinates Y1, Y2, Y3...YL.
[0110] Step 4043: For each connected component, divide the total value of its corresponding column coordinates by the number of pixels to obtain the column coordinates of the geometric center of the connected component.
[0111] Optionally, for the l-th connected component, the point selection and localization system divides the total column coordinate value Cl by the number of pixels Sl to obtain the geometric center column coordinate of the l-th connected component, denoted as Xl. The geometric center column coordinate Xl is the quotient obtained by dividing the total column coordinate value Cl by the number of pixels Sl. The geometric center column coordinate Xl represents the centroid position of the feature region corresponding to the l-th connected component in the horizontal direction, which is the direction of increasing column number in the pixel matrix of the polarization difference image. The point selection and localization system performs the above division operation on each of the L connected components to obtain L geometric center column coordinates X1, X2, X3...XL.
[0112] Step 4044: Combine the row coordinates and column coordinates of the geometric center of each connected component to obtain the geometric center position, and arrange the geometric center positions of each connected component in ascending order of the row coordinates to obtain the candidate point coordinate sequence.
[0113] Optionally, for the l-th connected component, the point selection and positioning system combines the geometric center row coordinates Yl and the geometric center column coordinates Xl to form an ordered pair (Yl, Xl). This ordered pair (Yl, Xl) is then used to determine the geometric center position of the l-th connected component, where l is an integer ranging from 1 to L. The point selection and positioning system performs this combination operation on each of the L connected components, obtaining L geometric center positions (Y1, X1), (Y2, X2), (Y3, X3)...(YL, XL). The point selection and positioning system then arranges the L geometric center positions in ascending order of the corresponding connected component's geometric center row coordinates. Specifically, a sorting operation is performed on the L geometric center positions, with the comparison rule being: for any two geometric center positions (Y1, X1), (Y2, X2), (Y3, X3), ..., (YL, XL). a X a ) and (Yb, Xb), if Y a If it is less than Yb, then (Y) a X aArranged before (Yb, Xb); if Y a If the value is greater than Yb, then arrange (Yb, Xb) in (Yb, Xb). a X a Before Y; a If X equals Yb, then the geometric center with the smaller column coordinates is placed first; that is, if X... a If it is less than or equal to Xb, then (Y) a X a If X is arranged before (Yb, Xb), then X a If the value is greater than Xb, then arrange (Yb, Xb) in (Yb). a X a )Before.
[0114] The point selection and localization system uses the ordered set of L geometric center positions after sorting as a candidate point coordinate sequence, denoted as P1, P2, P3...PL, where P1 is the first geometric center position after sorting, P2 is the second geometric center position after sorting, and so on, with PL being the Lth geometric center position after sorting. Therefore, each coordinate point in the candidate point coordinate sequence represents the geometric center position of a feature region in the polarization difference image.
[0115] In this embodiment of the invention, candidate point coordinate sequences are generated by arranging the geometric center row coordinates in ascending order. This ensures that each coordinate point in the sequence is arranged sequentially from top to bottom in the polarization difference image. When the geometric center row coordinates are the same, they are further arranged in ascending order by the geometric center column coordinates, ensuring the determinism of the arrangement order. This provides support for subsequently converting pixel coordinates into physical coordinates in the mechanical motion coordinate system and generating the target execution coordinate sequence through a preset transformation mapping relationship. Therefore, the mechanical motion mechanism of the laser welding machine can perform welding operations sequentially according to the candidate point coordinate sequence, improving the accuracy of point selection and positioning when the laser welding machine is working on highly reflective metal surfaces.
[0116] The laser welding machine point selection and positioning system provided by the present invention is described below. The laser welding machine point selection and positioning system described below can be referred to in correspondence with the laser welding machine point selection and positioning method described above.
[0117] Optionally, refer to Figure 2 , Figure 2 This is a schematic diagram of the laser welding machine point selection and positioning system provided by the present invention. The laser welding machine point selection and positioning system includes: The polarization image generation module 210, based on the polarization beam splitting component of the laser welding head, decomposes the reflected beam from the workpiece surface into a first linearly polarized beam and a second linearly polarized beam with mutually perpendicular vibration directions. These beams are transmitted to the imaging plane via a first imaging channel and a second imaging channel, respectively, generating a first polarization image and a second polarization image. The grayscale level mapping module 220 maps the grayscale levels of the second polarization image based on the grayscale distribution ratio of the first and second polarization images in a preset background area, generating a matched polarization image. The polarization grayscale difference analysis module 230 generates a polarization difference image based on the grayscale difference between corresponding pixels in the first polarization image and the matched polarization image. The machine-selected point positioning module 240 generates a target execution coordinate sequence based on the geometric center coordinates of each connected region in the polarization difference image whose grayscale value differs from the background area, and drives the motion mechanism of the laser welding head to move to the physical position corresponding to the first coordinate point in the target execution coordinate sequence that conforms to the preset process path order.
[0118] The embodiments improve the accuracy of spot selection and positioning when the laser welding machine is working on highly reflective metal surfaces.
[0119] Please see Figure 3 , Figure 3 An embodiment diagram of an electronic device provided in accordance with the present invention. For example... Figure 3 As shown, an embodiment of the present invention provides an electronic device 300, including a memory 310, a processor 320, and a computer program 311 stored in the memory 310 and executable on the processor 320. When the processor 320 executes the computer program 311, it implements the processes of steps 10 to 40.
[0120] Please see Figure 4 , Figure 4 An embodiment diagram of a computer-readable storage medium provided in accordance with an embodiment of the present invention is shown. Figure 4 As shown, this embodiment provides a computer-readable storage medium 400 on which a computer program 311 is stored. When the computer program 311 is executed by a processor, it implements the processes of steps 10 to 40.
[0121] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer is able to execute the laser welding machine point selection and positioning method provided by the above methods, which includes the process of steps 10 to 40.
[0122] The system embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0123] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0124] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. These modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for selecting and positioning points in a laser welding machine, characterized in that, include: The polarization beam splitting component based on the laser welding head decomposes the reflected beam from the workpiece surface into a first linearly polarized beam and a second linearly polarized beam with mutually perpendicular vibration directions. These beams are then transmitted to the imaging plane via the first imaging channel and the second imaging channel, respectively, to generate a first polarization image and a second polarization image. Based on the grayscale distribution ratio of the first polarization image and the second polarization image in a preset background region, the grayscale levels of the second polarization image are mapped to generate a matching polarization image. A polarization difference image is generated based on the grayscale difference of corresponding pixels in the first polarization image and the matched polarization image; Based on the geometric center coordinates of each connected domain in the polarization difference image whose gray values differ from the background region, a target execution coordinate sequence is generated, and the motion mechanism of the laser welding head is driven to move to the physical position corresponding to the first coordinate point in the target execution coordinate sequence that conforms to the preset process path order.
2. The laser welding machine point selection and positioning method according to claim 1, characterized in that, Based on the first grayscale distribution ratio and the second grayscale distribution ratio of the first polarization image and the second polarization image in a preset background region, the grayscale levels of the second polarization image are mapped to generate a matched polarization image, including: Traverse each pixel of the second polarization image, count the number of pixels corresponding to each gray level, and obtain the number of pixels at each gray level in the second polarization image. The actual background cumulative percentage of each gray level in the second polarization image is obtained by accumulating the number of pixels at each gray level in ascending order of gray level and dividing by the total number of pixels in the second polarization image; the actual background cumulative percentage of each gray level represents the proportion of pixels less than or equal to the current gray level in the second polarization image. Based on the first gray-level distribution ratio and the second gray-level distribution ratio, the gray-levels are accumulated in ascending order to obtain the first background cumulative ratio and the second background cumulative ratio for each gray-level corresponding to the background distribution; the first background cumulative ratio represents the proportion of pixels in the background region of the first polarized image that are less than or equal to the current gray-level; the second background cumulative ratio represents the proportion of pixels in the background region of the second polarized image that are less than or equal to the current gray-level. The grayscale levels of the second polarization image are mapped based on the actual cumulative ratio, the first background cumulative ratio, and the second background cumulative ratio to generate the matched polarization image.
3. The laser welding machine point selection and positioning method according to claim 2, characterized in that, The step of mapping the gray levels of the second polarization image based on the actual cumulative ratio, the first background cumulative ratio, and the second background cumulative ratio to generate the matching polarization image includes: Based on the gray levels in both the first and second background cumulative proportions that are within the middle preset proportion range, the common linear mapping gray range is determined. Within the common linear mapping grayscale range, for each grayscale level, find the grayscale level whose first background cumulative proportion of each grayscale level corresponding to the background distribution is closest to the actual cumulative proportion of each grayscale level in the second polarization image, establish the correspondence between the two grayscale levels, and obtain the grayscale correspondence within the common linear mapping grayscale range. Traverse each pixel of the second polarization image. If the gray level of the pixel is within the gray range of the common linear mapping, then replace the gray level of the pixel with the corresponding mapped gray level based on the gray level correspondence of the common linear mapping gray range. If the gray level of the pixel is not within the gray range of the common linear mapping gray range, then keep the original gray level of the pixel unchanged to obtain the matched polarization image.
4. The laser welding machine point selection and positioning method according to claim 1, characterized in that, The step of generating a polarization difference image based on the grayscale difference of corresponding pixels in the first polarization image and the matched polarization image includes: Traverse each pixel in the first polarization image and the matching polarization image that has the same spatial position, and obtain the original gray level difference of each pixel based on the difference between the gray level of the current pixel in the first polarization image and the gray level of the corresponding pixel in the matching polarization image; Take the absolute value of the original grayscale difference of each pixel to obtain the absolute grayscale difference of each pixel. Then, iterate through the absolute grayscale difference of each pixel and count the number of pixels corresponding to each difference level to obtain the frequency distribution of the absolute grayscale difference. In the frequency distribution of absolute grayscale differences, the continuous difference level with the most pixels is selected and determined as the difference threshold level dominated by background noise. A mapping judgment is then performed based on each difference level in the absolute grayscale differences and the difference threshold level to obtain the mapping judgment result. Polarization difference analysis is performed based on the mapping judgment result to generate the polarization difference image.
5. The laser welding machine point selection and positioning method according to claim 4, characterized in that, The step of performing polarization difference analysis based on the mapping judgment result to generate the polarization difference image includes: For each difference level in the absolute grayscale difference, if the mapping judgment result indicates that the difference level belongs to the difference threshold level, then it is mapped to zero; if the mapping judgment result indicates that the difference level does not belong to the difference threshold level, then its original difference level remains unchanged, thus obtaining the difference suppression mapping relationship. Traverse each pixel of the second polarization image, and replace the absolute grayscale difference of each pixel with the corresponding processed difference based on the difference suppression mapping relationship to obtain the suppressed grayscale difference image; The non-zero pixel values in the suppressed gray-level difference image are linearly amplified to obtain the enhanced gray-level difference image; the gray-level interval between the feature region and the background region is linearly amplified. The pixel data of the enhanced grayscale difference image are arranged according to the image format to generate the polarization difference image; the grayscale value of the background region in the polarization difference image is zero, the grayscale value of the feature region is different from that of the background region, and the grayscale value reflects the degree of difference in polarization response.
6. The laser welding machine point selection and positioning method according to claim 1, characterized in that, The step of generating a target execution coordinate sequence based on the geometric center coordinates of each connected region in the polarization difference image whose gray values differ from the background region includes: Traverse each pixel of the polarization difference image. If the gray value of a pixel is greater than zero, the pixel is determined as a foreground pixel; if the gray value of a pixel is equal to zero, the pixel is determined as a background pixel. Traversing each row of pixels in the polarization difference image, for consecutive foreground pixels in each row, the row direction connectivity information is determined based on their start and end column coordinates. The row direction connectivity information of adjacent rows is compared. If a row direction connectivity segment in the current row overlaps or is adjacent to a row direction connectivity segment in the previous row in terms of column coordinates, the two row direction connectivity segments are assigned to the same connected component. If there is no overlap or adjacency, a new connected component is assigned to the row direction connectivity segment of the current row. The row direction connectivity information represents the horizontal position range of all foreground pixel segments in each row. Traverse each foreground pixel of the polarization difference image, sum the row coordinates of all foreground pixels belonging to the same connected component to obtain the total row coordinate value, and sum the column coordinates of all foreground pixels belonging to the same connected component to obtain the total column coordinate value; the total row coordinate value and the total column coordinate value respectively represent the linear summation value of all pixel positions in each connected component; A candidate point coordinate sequence is generated based on the total row and column coordinates of each connected component. Then, based on a preset transformation mapping relationship, the pixel coordinates in the candidate point coordinate sequence are converted from spatial coordinates to physical coordinates in mechanical motion coordinates to generate the target execution coordinate sequence.
7. The laser welding machine point selection and positioning method according to claim 6, characterized in that, The generation of candidate point coordinate sequences based on the total row and column coordinates of each connected component includes: Count the number of foreground pixels belonging to the same connected component to obtain the number of pixels in each connected component; For each connected component, the total row coordinates of its corresponding component are divided by the number of pixels to obtain the geometric center row coordinates of the connected component; the geometric center row coordinates represent the centroid position of the feature region in the vertical direction. For each connected component, the total value of its corresponding column coordinates is divided by the number of pixels to obtain the geometric center column coordinates of the connected component; the geometric center column coordinates represent the centroid position of the feature region in the horizontal direction. The geometric center row coordinates and geometric center column coordinates of each connected component are combined to obtain the geometric center position. The geometric center positions of each connected component are then arranged in ascending order of their row coordinates to obtain the candidate point coordinate sequence. Each coordinate point in the candidate point coordinate sequence represents the geometric center position of a feature region in the polarization difference image.
8. A laser welding machine point selection and positioning system, characterized in that, A system for implementing the laser welding machine point selection and positioning method as described in any one of claims 1 to 7; the system comprises: The polarization image generation module is used in the polarization beam splitting component based on the laser welding head to decompose the reflected beam on the workpiece surface into a first linearly polarized beam and a second linearly polarized beam with mutually perpendicular vibration directions. The beams are transmitted to the imaging plane through the first imaging channel and the second imaging channel, respectively, to generate a first polarization image and a second polarization image. The grayscale level mapping module is used to map the grayscale level of the second polarization image based on the grayscale distribution ratio of the first polarization image and the second polarization image in a preset background area, so as to generate a matching polarization image. The polarization grayscale difference analysis module is used to generate a polarization difference image based on the grayscale difference of corresponding pixels in the first polarization image and the matched polarization image; The machine-selected point positioning module is used to generate a target execution coordinate sequence based on the geometric center coordinates of each connected domain in the polarization difference image whose gray values differ from the background region, and drive the motion mechanism of the laser welding head to move to the physical position corresponding to the first coordinate point in the target execution coordinate sequence that conforms to the preset process path order.
9. An electronic device, comprising: A memory for storing a computer program; a processor for reading and executing the computer program, characterized in that, when the processor executes the computer program, it implements the laser welding machine point selection and positioning method as described in any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the laser welding machine point selection and positioning method as described in any one of claims 1 to 7.