A method, device and medium for calculating a light spot beam divergence angle with adaptive threshold correction

By using an adaptive threshold correction method, the camera exposure is automatically adjusted and the beam divergence angle is calculated, which solves the error problem caused by human factors in the existing technology, realizes high-precision solution of beam divergence angle, and improves the accuracy of laser communication links and detection equipment.

CN121259087BActive Publication Date: 2026-03-24SHANDONG UNIV OF SCI & TECH +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511833482.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-12-08
Publication Date
2026-03-24
Estimated Expiration
2045-12-08

AI Technical Summary

Technical Problem

In existing technologies, the solution of beam divergence angle is subject to significant errors due to human factors, making it impossible to achieve high-precision solutions and affecting the quality of laser communication links and the detection accuracy of ground-based detection equipment.

Method used

By automatically determining the system threshold and adjusting the camera exposure, an adaptive threshold correction method is adopted, including acquiring the debug spot image output by the image acquisition device, calculating the maximum gray value and pixel variance, updating the pixel threshold until the target pixel threshold is obtained, and calculating the first and second moments of the spot image to solve the spot beam divergence angle.

Benefits of technology

It effectively eliminates errors caused by manually selecting thresholds, achieves high-precision solution of beam divergence angle, improves the quality of laser communication links and the detection accuracy of ground detection equipment, and has good noise interference adaptability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121259087B_ABST
    Figure CN121259087B_ABST
Patent Text Reader

Abstract

The application discloses a kind of self-adapting threshold correction spot beam divergence angle calculation method, equipment and medium, it is related to laser communication technical field.The method includes: continuously obtaining the debugging spot picture of image acquisition equipment output, and the maximum gray value of debugging spot picture is calculated;Maximum gray value is based, and the exposure of image acquisition equipment is adjusted, until the initial spot picture of maximum gray value and pixel number reaches preset threshold value is output;Based on preset initial pixel threshold value, the pixel value variance of initial spot picture is calculated, and initial pixel threshold value is updated, until the target pixel threshold value that makes pixel value variance reach maximum value is obtained;Zero is placed in the pixel value lower than target pixel threshold value in initial spot picture, to obtain target spot picture;The first moment and second moment of target spot picture are calculated, to obtain the spot beam divergence angle of target spot picture.The application is by adjusting exposure and variance maximization threshold selection mechanism, to improve the calculation precision of spot beam divergence angle.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of laser communication technology, and in particular to an adaptive threshold correction method, device and medium for calculating beam divergence angle. Background Technology

[0002] In the field of laser communication technology, determining the beam divergence angle is a crucial function of ground-based inspection equipment for laser communication terminals. In existing technologies, the beam divergence angle is typically obtained by calculating the beam width after acquiring a beam image using an infrared camera. This process requires manually selecting a threshold to filter out noise. Since different personnel may select different thresholds, the calculated beam divergence angle results can vary significantly due to this human error. Furthermore, due to factors such as the emitted optical power of the laser communication terminal, the exposure time of the ground inspection camera, and the stability of the on-site environment, fixed or semi-fixed threshold methods cannot achieve high-precision beam divergence angle determination.

[0003] Therefore, how to automatically determine the system threshold and adjust the camera exposure to avoid errors caused by manually selecting the threshold, achieve high-precision solution of beam divergence angle, and effectively improve the quality of laser communication links and the detection accuracy of ground detection equipment has become an urgent problem to be solved. Summary of the Invention

[0004] This application provides an adaptive threshold correction method, device, and medium for calculating beam divergence angle, which solves the following technical problem: how to automatically determine the system threshold and adjust the camera exposure to avoid errors caused by manually selecting the threshold, achieve high-precision beam divergence angle calculation, and effectively improve the quality of laser communication links and the detection accuracy of ground detection equipment.

[0005] In a first aspect, embodiments of this application provide an adaptive threshold-corrected method for calculating beam divergence angle. The method includes: continuously acquiring a test beam image output by an image acquisition device and calculating the maximum grayscale value of the test beam image; adjusting the exposure of the image acquisition device based on the maximum grayscale value until an initial beam image with the maximum grayscale value and the number of pixels reaches a preset threshold is output; calculating the pixel value variance of the initial beam image based on a preset initial pixel threshold and updating the initial pixel threshold until a target pixel threshold that maximizes the pixel value variance is obtained; setting the pixel values ​​in the initial beam image below the target pixel threshold to zero to obtain a target beam image; and calculating the first moment and second moment of the target beam image to obtain the beam divergence angle of the target beam image.

[0006] In one implementation of this application, continuously acquiring debugging spot images output by an image acquisition device and calculating the maximum grayscale value of the debugging spot images specifically includes: parsing the debugging spot image data to obtain the total number of pixels and the pixel value of each pixel in the debugging spot image; and calculating the maximum grayscale value of the debugging spot image based on the total number of pixels and the pixel values.

[0007] In one implementation of this application, the exposure of the image acquisition device is adjusted based on the maximum grayscale value until an initial spot image with a maximum grayscale value and a number of pixels reaches a preset threshold is output. Specifically, this includes: determining whether the maximum grayscale value of the test spot image reaches the maximum grayscale value of the image acquisition device; if the maximum grayscale value of the test spot image does not reach the maximum grayscale value of the image acquisition device, increasing the exposure of the image acquisition device and re-acquiring the spot image until a first spot image with a maximum grayscale value equal to the maximum grayscale value of the image acquisition device is obtained; acquiring the number of pixels in the first spot image; if the number of pixels exceeds a preset threshold, decreasing the exposure of the image acquisition device until an initial spot image with a number of pixels less than the preset threshold is obtained.

[0008] In one implementation of this application, based on a preset initial pixel threshold, the pixel value variance of the initial spot image is calculated, and the initial pixel threshold is updated until a target pixel threshold that maximizes the pixel value variance is obtained. Specifically, this includes: selecting an initial pixel threshold and executing variance calculation logic to calculate the initial pixel value variance in the initial spot image that exceeds the initial pixel threshold; selecting a second pixel threshold and calculating the second pixel value variance corresponding to the second pixel threshold; selecting a pixel variance value with a larger variance value from the initial pixel value variance and the second pixel value variance, and using the pixel threshold corresponding to the pixel variance value with the larger variance value as a candidate pixel threshold; and repeatedly executing the variance calculation logic until a target pixel threshold that maximizes the pixel value variance is obtained.

[0009] In one implementation of this application, the variance calculation logic is represented by the following formula: The global mean of pixel values ​​in the initial spot image is calculated by the following formula:

[0010]

[0011] in, For the first The pixel value of each pixel. This represents the total number of pixels in the initial light spot image. The global mean of pixel values ​​in the initial spot image;

[0012] The summation of the pixel values ​​in the initial spot image that are greater than the initial pixel threshold is calculated using the following formula:

[0013]

[0014] in, The first pixel in the initial light spot image that exceeds the initial pixel threshold The pixel value of each pixel. This represents the number of pixels in the initial spot image that exceed the initial pixel threshold. This is the summation mean of pixel values ​​in the initial spot image that are greater than the initial pixel threshold;

[0015] The variance of the initial pixel values ​​exceeding the initial pixel threshold in the initial spot image is calculated using the following formula:

[0016]

[0017] in, This represents the variance of pixels in the initial spot image that exceed the initial pixel threshold.

[0018] In one implementation of this application, the pixel values ​​in the initial spot image that are below the target pixel threshold are set to zero to obtain the target spot image. Specifically, this includes: traversing each pixel in the initial spot image and extracting the pixel value of each pixel; comparing the pixel value of each pixel with the target pixel threshold and recording the pixel values ​​above the target pixel threshold and the distribution of neighboring pixels; marking pixels with pixel values ​​above the target pixel threshold and whose neighboring pixel distribution meets preset distribution conditions as valid spot core pixels, and directly setting the pixel values ​​of pixels with pixel values ​​below the target pixel threshold to zero to obtain the target spot image.

[0019] In one implementation of this application, the first and second moments of the target spot image are calculated to obtain the beam divergence angle of the target spot image, which is expressed by the following formula:

[0020]

[0021]

[0022]

[0023]

[0024]

[0025]

[0026]

[0027] in, For the first The pixel value of each pixel. The sum of the energy of all light spots. , These represent the number of rows and columns of pixels in the target light spot image, respectively. For the purpose of action, For example, For the corresponding pixel grayscale, , This represents the column and row mean of the light spot image. , The variance in the column direction, To obtain the laser beam width, The resolution of a single pixel in an image acquisition device. To obtain the beam divergence angle of the light spot.

[0028] In one implementation of this application, the method further includes: extracting the grayscale value distribution data of the core pixels of the effective spot in the target spot image and fitting a grayscale distribution curve; comparing the grayscale distribution curve with the ideal Gaussian distribution curve and calculating the fitting deviation; if the fitting deviation exceeds a preset deviation threshold, adjusting the target pixel threshold to obtain the corrected spot beam divergence angle.

[0029] Secondly, embodiments of this application also provide an adaptive threshold-corrected spot beam divergence angle calculation device, the device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to: continuously acquire a debug spot image output by an image acquisition device and calculate the maximum grayscale value of the debug spot image; adjust the exposure of the image acquisition device based on the maximum grayscale value until an initial spot image with the maximum grayscale value and the number of pixels reaches a preset threshold is output; calculate the pixel value variance of the initial spot image based on a preset initial pixel threshold and update the initial pixel threshold until a target pixel threshold is obtained that maximizes the pixel value variance; set the pixel values ​​in the initial spot image below the target pixel threshold to zero to obtain a target spot image; and calculate the first moment and second moment of the target spot image to obtain the spot beam divergence angle of the target spot image.

[0030] Thirdly, embodiments of this application also provide a non-volatile computer storage medium for calculating the beam divergence angle of an adaptive threshold correction, storing computer-executable instructions. These instructions are configured to: continuously acquire a debug spot image output by an image acquisition device and calculate the maximum grayscale value of the debug spot image; adjust the exposure of the image acquisition device based on the maximum grayscale value until an initial spot image with the maximum grayscale value and the number of pixels reaches a preset threshold is output; calculate the pixel value variance of the initial spot image based on a preset initial pixel threshold and update the initial pixel threshold until a target pixel threshold is obtained that maximizes the pixel value variance; set the pixel values ​​in the initial spot image below the target pixel threshold to zero to obtain the target spot image; and calculate the first and second moments of the target spot image to obtain the beam divergence angle of the target spot image.

[0031] The adaptive threshold correction method, device, and medium for calculating beam divergence angle provided in this application have the following advantages: by continuously acquiring beam spot images and adjusting the exposure in real time, the data distortion problem caused by improper exposure in traditional methods is avoided; by adopting a threshold selection mechanism that maximizes variance, the optimal critical point for distinguishing beam spot signals from background noise is automatically found, eliminating the subjective bias of manually setting the threshold and ensuring that the beam spot presents an approximately Gaussian distribution; through an iterative optimization process, it has good adaptability to noise interference and image quality fluctuations of different degrees. Attached Figure Description

[0032] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0033] Figure 1 A flowchart illustrating an adaptive threshold correction method for calculating beam divergence angle provided in this application embodiment;

[0034] Figure 2 This is a schematic diagram of the internal structure of an adaptive threshold correction beam divergence angle calculation device provided in an embodiment of this application. Detailed Implementation

[0035] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0036] This application provides an adaptive threshold correction method, device, and medium for calculating beam divergence angle, which solves the following technical problem: how to automatically determine the system threshold and adjust the camera exposure to avoid errors caused by manually selecting the threshold, achieve high-precision beam divergence angle calculation, and effectively improve the quality of laser communication links and the detection accuracy of ground detection equipment.

[0037] The technical solutions proposed in the embodiments of this application will be described in detail below with reference to the accompanying drawings.

[0038] Figure 1 A flowchart illustrating an adaptive threshold correction method for calculating beam divergence angle provided in an embodiment of this application. Figure 1 As shown in the embodiment of this application, an adaptive threshold correction method for calculating beam divergence angle specifically includes the following steps:

[0039] Step 10: Continuously acquire debugging spot images output by the image acquisition device and calculate the maximum grayscale value of the debugging spot images.

[0040] As an optional embodiment, continuously acquiring the debugging spot image output by the image acquisition device and calculating the maximum grayscale value of the debugging spot image can specifically include: Step 101: Parsing the debugging spot image data to obtain the total number of pixels and the pixel value of each pixel in the debugging spot image.

[0041] In this step, the debugging spot image stored in the image acquisition device is first fully loaded to avoid data loss or corruption affecting subsequent analysis results. After the image is loaded, the image data analysis module statistically analyzes the overall pixel composition of the image to determine the total number of pixels contained in the debugging spot image. This value reflects the overall size of the image and is an important basis for subsequent calculations of key parameters such as pixel ratio and global mean. At the same time, for each individual pixel in the image, its corresponding pixel value is read and recorded one by one. This pixel value directly represents the gray intensity information of the spot at the corresponding location, covering the high gray value in the center area of ​​the spot and the low gray value in the edge and background areas, completely preserving the gray distribution characteristics of the spot. Through this analysis process, not only is original data support provided for subsequent adjustment of exposure based on the maximum gray value, but it also lays a precise data foundation for subsequent calculation of pixel value variance, determination of system threshold, and final calculation of spot beam divergence angle. This ensures that the entire beam divergence angle calculation process has reliable data basis from the source, avoiding errors in subsequent steps due to incomplete or inaccurate initial data analysis.

[0042] Step 102: Based on the total number of pixels and pixel values, calculate the maximum grayscale value of the debugging spot image.

[0043] In this step, the calculation process is based on the acquired full set of pixel values ​​as the core data foundation. It is completed by traversing and comparing the grayscale information of all pixels. First, the pixel value corresponding to each recorded pixel is retrieved one by one and these pixel values ​​are included in a unified comparison system. By comparing the size relationship of each pixel value in turn, the pixel value with the largest value is selected. This value is the maximum grayscale value of the debugging spot image. This maximum grayscale value directly reflects the highest brightness level of the spot under the current image acquisition conditions. It not only determines whether it is necessary to further increase or decrease the exposure to optimize the grayscale distribution of the spot, but also provides an important reference for defining the range of pixel values ​​when calculating the variance of pixel values ​​and determining the system threshold. This ensures that all subsequent parameter calculations and adjustments based on grayscale values ​​can be carried out around the actual brightness characteristics of the spot, avoiding deviations in subsequent processes caused by inaccurate understanding of the maximum brightness of the spot.

[0044] Step 20: Based on the maximum grayscale value, adjust the exposure of the image acquisition device until the output of the initial spot image with the maximum grayscale value and the number of pixels reaches the preset threshold.

[0045] As an optional embodiment, the exposure of the image acquisition device is adjusted based on the maximum gray value until the output of the initial spot image with the maximum gray value and the number of pixels reaches a preset threshold. Specifically, it may include: Step 201: Determine whether the maximum gray value of the adjustment spot image reaches the maximum gray value of the image acquisition device.

[0046] In this step, based on the hardware performance parameters of the image acquisition device itself, the upper limit of the maximum grayscale value that the device can output is first determined. This upper limit is the highest brightness level that the device can present at the hardware level and is the core reference standard for judgment. Then, the maximum grayscale value of the previously calculated debugging spot image is directly compared with the upper limit of the device's maximum grayscale value. Through this comparison, it can be clearly known whether the current highest brightness of the spot has fully utilized the grayscale rendering capability of the device, thus providing a clear directional guide for subsequent exposure adjustment, ensuring that the grayscale distribution of the spot in the image is neither oversaturated nor insufficient in information, and meeting the requirements of accurate beam divergence angle calculation for spot image quality.

[0047] Step 202: If the maximum grayscale value of the bokeh image does not reach the maximum grayscale value of the image acquisition device, increase the exposure of the image acquisition device and re-acquire the bokeh image until a first bokeh image with a maximum grayscale value equal to the maximum grayscale value of the image acquisition device is obtained.

[0048] In this step, when it is determined that the maximum grayscale value of the debugging spot image does not reach the maximum grayscale value of the image acquisition device, the image quality of the spot needs to be optimized by increasing the exposure of the image acquisition device to ensure that the brightness information of the spot can be fully captured. Based on the current maximum grayscale value that does not meet the standard, the exposure parameters of the device are moderately increased. This parameter adjustment needs to be combined with the exposure adjustment range of the device and the brightness improvement requirements of the spot to avoid distortion of subsequent image information due to excessive adjustment in a single step. After the exposure parameters are adjusted, the image acquisition device is controlled to re-acquire the spot image to obtain a new debugging spot image. Subsequently, the newly acquired image is processed according to the previous analysis and calculation process. The image of the light spot is analyzed to obtain its total number of pixels and the pixel value of each pixel. The maximum gray value of the image is then recalculated. The newly calculated maximum gray value is compared with the maximum gray value of the image acquisition device. If the maximum gray value of the device is still not reached, the process of increasing the exposure, re-acquiring the image, and calculating and comparing the maximum gray value is repeated until the maximum gray value of the re-acquired light spot image is exactly equal to the maximum gray value of the image acquisition device. At this point, the light spot image is the first light spot image that meets the brightness requirements, laying the image foundation for further optimization of the light spot image and accurate solution of the beam divergence angle.

[0049] Step 203: Collect the number of pixels in the first light spot image.

[0050] In this step, after obtaining the first spot image whose maximum grayscale value is equal to the maximum grayscale value of the image acquisition device, the full pixel information of the previously parsed first spot image is retrieved, including the specific pixel value of each pixel. Then, using the maximum grayscale value of the image acquisition device as the filtering standard, all pixels are checked one by one, and pixels whose pixel value is equal to the maximum grayscale value are filtered out. The total number of such pixels is determined by traversing and counting, thus completing the acquisition of the number of pixels corresponding to the first spot image.

[0051] Step 204: If the number of pixels exceeds the preset threshold, reduce the exposure of the image acquisition device until an initial spot image with fewer pixels than the preset threshold is obtained.

[0052] In this step, after collecting the number of pixels, it is necessary to compare the number with a preset threshold. If the number of pixels collected exceeds the preset threshold, it indicates that the exposure of the current image acquisition device is too high, resulting in an excessively large high-brightness area in the spot, which may destroy the ideal grayscale distribution characteristics of the spot and is not conducive to the accurate solution of the beam divergence angle. At this time, it is necessary to appropriately reduce the exposure parameters of the image acquisition device. After adjustment, control the device to re-acquire the spot image and repeat the process of comparing the number of pixels corresponding to the maximum grayscale value in the acquired image with the preset threshold. If the number of pixels in the re-acquired image still exceeds the preset threshold, continue to reduce the exposure and collect and compare again until the number of pixels corresponding to the maximum grayscale value in a certain acquired spot image is less than the preset threshold. This spot image is the initial spot image that meets the requirements of subsequent calculations, providing an image data basis that conforms to the grayscale distribution standard for subsequent threshold optimization and beam divergence angle solution.

[0053] Step 30: Based on the preset initial pixel threshold, calculate the pixel value variance of the initial spot image and update the initial pixel threshold until the target pixel threshold that makes the pixel value variance reach its maximum value is obtained.

[0054] As an optional embodiment, based on a preset initial pixel threshold, the variance of pixel values ​​in the initial spot image is calculated, and the initial pixel threshold is updated until a target pixel threshold that makes the variance of pixel values ​​reach its maximum value is obtained. Specifically, it may include: Step 301: Select an initial pixel threshold and execute variance calculation logic to calculate the variance of initial pixel values ​​in the initial spot image that exceeds the initial pixel threshold.

[0055] As an optional embodiment, the variance calculation logic is represented by the following formula: Step 3011: Calculate the global mean of pixel values ​​in the initial spot image, represented by the following formula:

[0056]

[0057] in, For the first The pixel value of each pixel. This represents the total number of pixels in the initial light spot image. The global mean of pixel values ​​in the initial spot image;

[0058] In this step, the global mean comprehensively reflects the overall grayscale distribution level of the initial spot image, avoiding variance calculation bias caused by relying solely on local pixel grayscale information. This ensures that the variance result accurately reflects the dispersion of spot grayscale at the current threshold during each threshold iteration, thus providing reliable data support for selecting the target pixel threshold that maximizes the variance. This effectively improves the scientific rigor and accuracy of threshold selection and reduces beam divergence calculation errors caused by threshold deviations. Simultaneously, the global mean not only provides key parameters for variance calculation but also indirectly assists in verifying the effectiveness of previous exposure adjustments. If the global mean significantly deviates from a reasonable range, it can provide a negative indication that previous exposure adjustments may have been overlooked, ensuring that the initial spot image entering the threshold calculation stage has a compliant grayscale foundation. This prevents subsequent processes from being carried out on unqualified image data, guaranteeing the accuracy and stability of beam divergence calculation from the source, and ultimately helping to achieve the goal of controlling beam divergence error within the preset range.

[0059] Step 3012: Calculate the average sum of pixel values ​​in the initial spot image that are greater than the initial pixel threshold, expressed by the following formula:

[0060]

[0061] in, The first pixel in the initial light spot image that exceeds the initial pixel threshold The pixel value of each pixel. This represents the number of pixels in the initial spot image that exceed the initial pixel threshold. This is the summation mean of pixel values ​​in the initial spot image that are greater than the initial pixel threshold;

[0062] In this step, the summation mean focuses on pixels exceeding the initial pixel threshold, accurately reflecting the grayscale concentration level of the effective signal area of ​​the light spot rather than the background noise area. This avoids the problem that the global mean cannot accurately characterize the effective light spot features because it includes low grayscale background pixels. By comparing this summation mean with the global mean, the grayscale difference between the effective light spot pixels and the overall pixels under the current initial pixel threshold can be clearly quantified. This ensures that the variance calculation result can truly reflect the current threshold's ability to distinguish between the effective signal and background noise, providing a reliable basis for iteratively selecting the target pixel threshold that maximizes the variance, and ultimately achieving accurate division of the effective light spot area.

[0063] Step 3013: Calculate the variance of the initial pixel values ​​exceeding the initial pixel threshold in the initial spot image, expressed by the following formula:

[0064]

[0065] in, This represents the variance of pixels in the initial spot image that exceed the initial pixel threshold.

[0066] In this step, the variance is the core basis for determining whether the current initial pixel threshold can optimally distinguish between effective spot pixels and background noise pixels. The global mean and the summation mean respectively represent the gray-level concentration level of the overall pixels and the pixels exceeding the threshold. The proportion of pixels exceeding the threshold reflects the quantity distribution of the two types of pixels. All three factors work together to calculate the variance. When the variance reaches its maximum value, it means that under the current initial pixel threshold, the gray-level difference between the effective spot pixels exceeding the threshold and the overall pixels containing background noise is the most significant. At this time, the threshold has the best effect on filtering background noise and can retain the gray-level characteristics of the effective spot to the greatest extent, avoiding the loss of effective spot information or noise mixing due to improper threshold. At the same time, the optimal target pixel threshold selected by the variance can effectively filter out low gray-level background noise, so that the target spot image retains only the high-purity effective spot area, avoiding the interference of noise pixels on the subsequent calculation of the first and second moments.

[0067] Step 302: Select the second pixel threshold and calculate the variance of the second pixel value corresponding to the second pixel threshold.

[0068] In this step, after calculating the variance of the pixel value corresponding to the initial pixel threshold, in order to select the target pixel threshold that can achieve optimal separation between effective spot and background noise, it is necessary to further select a second pixel threshold and calculate its corresponding second pixel value variance. First, based on the grayscale distribution characteristics of the initial spot image, within the range of less than the maximum pixel value of the image, a second pixel threshold different from the initial pixel threshold is selected to ensure that the threshold can cover another possible signal and noise distinction range, avoiding the filtering limitations caused by a single threshold. After selecting the second pixel threshold, the operation is carried out in the same way as the calculation of the initial pixel value variance. Finally, the global mean, the summation mean of pixels exceeding the threshold, and the proportion of pixels exceeding the threshold are substituted into the variance calculation formula to complete the calculation of the second pixel value variance corresponding to the second pixel threshold.

[0069] Step 303: Select the pixel variance value with the larger variance value from the initial pixel value variance and the second pixel value variance, and use the pixel threshold value corresponding to the pixel variance value with the larger variance value as the candidate pixel threshold.

[0070] In this step, the variances of the initial and second pixel values ​​obtained from the two calculations are included in the same comparison system and directly compared from the perspective of numerical magnitude to determine which variance value better reflects the grayscale difference between the effective spot pixels and the overall pixels. Since the larger the variance value, the more significant the difference in grayscale distribution between the effective spot pixels and the overall pixels under the current threshold, the threshold has a better effect on filtering background noise and can retain the grayscale characteristics of the effective spot to the greatest extent, which is more in line with the subsequent requirement of accurately extracting the effective spot area. Therefore, after comparison, the pixel variance value with the larger variance value is selected, and the pixel threshold corresponding to the larger variance value is determined as the candidate pixel threshold.

[0071] Step 304: Repeat the variance calculation logic until the target pixel threshold that makes the pixel value variance reach its maximum value is obtained.

[0072] In this step, firstly, within a range smaller than the maximum pixel value of the initial spot image, a new pixel threshold, different from the current candidate pixel threshold, is selected. This new threshold must cover grayscale ranges not covered by previous thresholds to avoid overlooking potential thresholds that might cause the variance to reach its maximum. Then, following the same variance calculation process as before, the pixel value variance corresponding to the new threshold is obtained. The variance of the new threshold is compared with the variance corresponding to the current candidate pixel threshold. If the new variance is larger, the new threshold and its corresponding variance are updated as the new candidate pixel threshold and candidate variance; if the new variance is smaller, the original candidate pixel threshold and candidate variance are retained. Afterward, the process of selecting a new pixel threshold and calculating the new variance continues. The complete logic of comparing the variance with the candidate variance and updating the candidate threshold continues until, within the preset threshold selection range, no matter how a new pixel threshold is selected, its corresponding variance cannot exceed the variance of the current candidate pixel threshold. At this point, it can be determined that the variance corresponding to the current candidate pixel threshold has reached its maximum value, and this candidate pixel threshold is the final target pixel threshold required. This continuous iterative process, by constantly exploring the threshold effect of different grayscale ranges, ensures that the final determined target pixel threshold can maximize the grayscale difference between the effective spot pixels and the background noise pixels, providing the optimal threshold basis for subsequent accurate noise filtering and extraction of the effective spot area, thereby ensuring the accuracy of subsequent beam divergence angle calculation.

[0073] Step 40: Set the pixel values ​​in the initial spot image below the target pixel threshold to zero to obtain the target spot image.

[0074] As an optional embodiment, the pixel values ​​in the initial spot image that are below the target pixel threshold are set to zero to obtain the target spot image. Specifically, this may include: Step 401: Traversing each pixel in the initial spot image and extracting the pixel value of each pixel.

[0075] In this step, firstly, the pixel array data of the stored initial spot image is called, and each pixel in the pixel array is accessed one by one according to the preset traversal order. When accessing each pixel, the grayscale parameter corresponding to the pixel in the data structure is read, that is, the pixel value of the pixel. The extracted pixel value is associated with the pixel position information and stored to form a corresponding dataset of pixel position and pixel value. The entire traversal process must ensure that all pixels of the initial spot image are covered without any pixels being missed or read repeatedly, so as to ensure that the subsequent comparison and screening based on pixel value and target threshold can be carried out comprehensively and accurately, and avoid incomplete extraction of effective spot area or incomplete background noise filtering due to missing pixel data.

[0076] Step 402: Compare the pixel value of each pixel with the target pixel threshold, and record the pixel values ​​that are higher than the target pixel threshold and the distribution of neighboring pixels.

[0077] In this step, firstly, the pixel value of each extracted pixel is compared with the previously determined target pixel threshold to determine whether the pixel value is higher than the target pixel threshold. After filtering out valid pixels with pixel values ​​higher than the target pixel threshold, a specific neighborhood area is delineated around each valid pixel. The number, distribution density, and spatial arrangement characteristics of pixels with pixel values ​​higher and lower than the target pixel threshold within this neighborhood are counted. This recording process aims to verify the validity of valid pixels through neighborhood distribution. If a pixel higher than the threshold has many other pixels with values ​​higher than the threshold in its neighborhood, it indicates that the pixel belongs to a continuous valid spot area. If a pixel higher than the threshold exists isolated among a large number of pixels lower than the threshold, it may be a misjudged pixel caused by accidental noise interference. By recording the valid pixels and their neighborhood distribution, isolated misjudged noise pixels can be subsequently removed, ensuring that the final retained valid spot area has spatial continuity and integrity, more closely matches the physical distribution characteristics of the actual laser spot, and provides more reliable pixel data for subsequent target spot image generation and accurate beam divergence angle calculation.

[0078] Step 403: Mark the pixels with pixel values ​​higher than the target pixel threshold and whose neighboring pixel distribution meets the preset distribution conditions as valid spot core pixels, and set the pixel values ​​of pixels with pixel values ​​lower than the target pixel threshold to zero directly to obtain the target spot image.

[0079] In this step, if the number, distribution density, or spatial continuity of pixels in the neighborhood of a certain pixel that exceed the target pixel threshold meets preset conditions, it indicates that the pixel belongs to a continuous and real effective spot region, and it is marked as an effective spot core pixel. If the neighborhood distribution does not meet the preset conditions, it is determined to be an isolated noise pixel and is not included in the effective spot core pixel range. After completing the marking of effective spot core pixels, all pixel values ​​of the initial spot image are uniformly processed. For those already marked as effective spot core pixels, their original pixel values ​​are retained to completely preserve the grayscale features of the effective spot. Spatial distribution information; for pixels with pixel values ​​lower than the target pixel threshold, their pixel values ​​are directly set to zero to completely filter out background noise and low grayscale interference information; for isolated noise pixels with pixel values ​​higher than the target pixel threshold but not meeting the neighborhood distribution conditions, their pixel values ​​are also set to zero according to the background noise processing logic to avoid such misjudged pixels interfering with subsequent calculations; after the above filtering and zeroing processing, the initial spot image retains only the original grayscale information of the effective spot core pixels, and the rest of the area is zero, finally forming a target spot image that only contains the real effective spot area.

[0080] Step 50: Calculate the first and second moments of the target spot image to obtain the beam divergence angle of the target spot image.

[0081] As an optional embodiment, the first and second moments of the target spot image are calculated to obtain the beam divergence angle of the target spot image, which is expressed by the following formula:

[0082] Step 501:

[0083]

[0084]

[0085]

[0086]

[0087]

[0088]

[0089]

[0090] in, For the first The pixel value of each pixel. The sum of the energy of all light spots. , These represent the number of rows and columns of pixels in the target light spot image, respectively. For the purpose of action, For example, For the corresponding pixel grayscale, , This represents the column and row mean of the light spot image. , The variance in the column direction, To obtain the laser beam width, The resolution of a single pixel in an image acquisition device. To obtain the beam divergence angle of the light spot.

[0091] Step 502: Extract the grayscale value distribution data of the core pixels of the effective spot in the target spot image and fit the grayscale distribution curve.

[0092] In this step, the grayscale values ​​of the extracted effective laser spot core pixels are statistically analyzed. First, the range of grayscale values ​​is determined, and then the grayscale values ​​within this range are grouped according to a preset grayscale interval. The number of effective laser spot core pixels contained in each grayscale interval is counted, forming a grayscale distribution dataset of grayscale value interval - corresponding pixel count. Based on the above grayscale distribution dataset, a fitting algorithm that conforms to the laser spot energy distribution law, such as a Gaussian distribution fitting method, is used for curve fitting. During the fitting process, the grayscale value is used as the horizontal axis and the corresponding pixel count as the vertical axis. The parameters of the fitting curve are adjusted by the algorithm to make the curve most closely resemble the laser spot energy distribution. The grayscale distribution data points are closely approximated to actual statistics to reduce fitting errors. The resulting grayscale distribution curve not only clearly shows the trend of effective spot grayscale changes from the center to the edge, but also verifies whether the grayscale distribution of the effective spot conforms to the preset physical model through the goodness of fit of the curve. If the fitting effect is good, it indicates that the effective spot area in the target spot image is accurately extracted, providing a direct basis for the reliability of the subsequent beam divergence angle calculation results. If the fitting effect is poor, it can indicate that there may be deviations in the previous threshold screening or neighborhood verification process, which requires further optimization to ensure the rigor of the entire beam divergence angle calculation process.

[0093] Step 503: Compare the grayscale distribution curve with the ideal Gaussian distribution curve and calculate the goodness-of-fit deviation.

[0094] In this step, the ideal Gaussian distribution curve is set based on the physical characteristics of laser beam propagation. It presents a typical shape with a prominent central peak and a smooth, symmetrical decay towards both sides, serving as a benchmark template for judging whether the actual spot grayscale distribution conforms to physical laws. Subsequently, a professional curve comparison algorithm is used to comprehensively compare the fitted actual grayscale distribution curve with the ideal Gaussian distribution curve. The numerical differences between the actual curve and the ideal curve at corresponding positions are calculated point by point, while also considering the overall shape characteristics of the curves, including the degree of peak position shift, the symmetry of both sides of the curve, and the consistency of the decay rate, avoiding focusing only on local differences while ignoring the matching degree of the overall distribution law. Based on the above point-by-point differences and Overall morphological analysis integrates various comparison results through a pre-defined deviation calculation model, ultimately yielding a quantified fitting deviation. This deviation value directly reflects the degree of fit between the actual spot grayscale distribution and the ideal Gaussian distribution: a small deviation indicates that the actual spot grayscale distribution conforms to the inherent propagation characteristics of the laser beam, and the previous threshold screening, neighborhood verification, and curve fitting steps are accurate and effective; a large deviation suggests that the actual spot may have residual noise, incomplete extraction of the effective region, or insufficient adaptability of the fitting algorithm, requiring reverse optimization of the pre-processing steps to ensure that subsequent beam divergence angle calculations are based on spot distribution data that conforms to physical laws, thus guaranteeing the scientific nature of the entire calculation process and the accuracy of the results.

[0095] Step 504: If the fitting deviation exceeds the preset deviation threshold, adjust the target pixel threshold to obtain the corrected beam divergence angle.

[0096] In this step, when the fitting deviation exceeds the preset deviation threshold, it indicates that the grayscale distribution of the effective spot core pixels extracted under the current target pixel threshold does not fully conform to the ideal Gaussian distribution characteristics of the laser beam. The spot data needs to be optimized by adjusting the target pixel threshold to obtain the corrected, accurate spot beam divergence angle. First, combining the quantification results of the fitting deviation with the possible causes of the deviation, such as a threshold that is too high causing some effective spot pixels to be filtered out or a threshold that is too low leaving too much background noise, the direction for adjusting the target pixel threshold is determined. After the threshold adjustment is completed, the previous spot processing and calculation process is repeated to obtain the corrected spot beam divergence angle, ensuring that the result truly reflects the actual divergence characteristics of the laser beam and meets the requirements of high-precision detection.

[0097] The above are embodiments of the method proposed in this application. Based on the same inventive concept, embodiments of this application also provide an adaptive threshold correction beam divergence angle calculation device, the structure of which is as follows: Figure 2 As shown.

[0098] Figure 2 This is a schematic diagram of the internal structure of an adaptive threshold correction beam divergence angle calculation device provided in an embodiment of this application. Figure 2 As shown, the device includes:

[0099] At least one processor 201;

[0100] And a memory 202 that is communicatively connected to at least one processor;

[0101] The memory 202 stores instructions executable by at least one processor. These instructions are executed by at least one processor 201 to enable the at least one processor 201 to: continuously acquire a debug spot image output by an image acquisition device and calculate the maximum grayscale value of the debug spot image; adjust the exposure of the image acquisition device based on the maximum grayscale value until an initial spot image with the maximum grayscale value and the number of pixels reaches a preset threshold is output; calculate the pixel value variance of the initial spot image based on a preset initial pixel threshold and update the initial pixel threshold until a target pixel threshold that maximizes the pixel value variance is obtained; set the pixel values ​​in the initial spot image below the target pixel threshold to zero to obtain a target spot image; and calculate the first and second moments of the target spot image to obtain the spot beam divergence angle of the target spot image.

[0102] Some embodiments of this application provide corresponding to Figure 1 A non-volatile computer storage medium for calculating beam divergence angle with adaptive threshold correction is disclosed. The computer-executable instructions are configured to: continuously acquire a debug beam image output by an image acquisition device and calculate the maximum grayscale value of the debug beam image; adjust the exposure of the image acquisition device based on the maximum grayscale value until an initial beam image with the maximum grayscale value and the number of pixels reaches a preset threshold is output; calculate the pixel value variance of the initial beam image based on the preset initial pixel threshold and update the initial pixel threshold until a target pixel threshold is obtained that maximizes the pixel value variance; set the pixel values ​​in the initial beam image below the target pixel threshold to zero to obtain the target beam image; and calculate the first and second moments of the target beam image to obtain the beam divergence angle of the target beam image.

[0103] The various embodiments in this application are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the embodiments for IoT devices and media are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.

[0104] The systems, media, and methods provided in this application are one-to-one correspondences. Therefore, the systems and media also have similar beneficial technical effects as their corresponding methods. Since the beneficial technical effects of the methods have been described in detail above, the beneficial technical effects of the systems and media will not be repeated here.

[0105] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0106] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0107] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0108] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0109] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0110] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0111] Computer-readable media include both permanent and non-permanent, removable and non-removable media that can store information by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0112] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0113] The above description is merely an embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principle of this application should be included within the scope of the claims of this application.

Claims

1. A method for calculating beam divergence angle with adaptive threshold correction, characterized in that, The method includes: Continuously acquire debugging spot images output by the image acquisition device, and calculate the maximum grayscale value of the debugging spot images; Based on the maximum gray value, the exposure of the image acquisition device is adjusted until the output of an initial spot image with the maximum gray value and the number of pixels reaching a preset threshold is achieved. Based on a preset initial pixel threshold, the pixel value variance of the initial spot image is calculated, and the initial pixel threshold is updated until a target pixel threshold that maximizes the pixel value variance is obtained. Set the pixel values ​​in the initial light spot image that are lower than the target pixel threshold to zero to obtain the target light spot image; Calculate the first and second moments of the target spot image to obtain the spot divergence angle of the target spot image; Based on a preset initial pixel threshold, the pixel value variance of the initial spot image is calculated, and the initial pixel threshold is updated until a target pixel threshold that maximizes the pixel value variance is obtained. Specifically, this includes: Select the initial pixel threshold and execute the variance calculation logic to calculate the variance of the initial pixel values ​​in the initial spot image that exceed the initial pixel threshold; Select a second pixel threshold and calculate the variance of the second pixel value corresponding to the second pixel threshold; Select the pixel variance value with the larger variance value from the initial pixel value variance and the second pixel value variance, and use the pixel threshold corresponding to the pixel variance value with the larger variance value as the candidate pixel threshold; Repeat the variance calculation logic until the target pixel threshold that makes the pixel value variance reach its maximum value is obtained; The variance calculation logic is expressed by the following formula: The global mean of pixel values ​​in the initial spot image is calculated using the following formula: in, For the first The pixel value of each pixel. This represents the total number of pixels in the initial light spot image. The global mean of pixel values ​​in the initial spot image; The average sum of pixel values ​​in the initial spot image that are greater than the initial pixel threshold is calculated using the following formula: in, The first pixel in the initial light spot image that exceeds the initial pixel threshold The pixel value of each pixel. This represents the number of pixels in the initial spot image that exceed the initial pixel threshold. This is the summation mean of pixel values ​​in the initial spot image that are greater than the initial pixel threshold; The variance of the initial pixel values ​​exceeding the initial pixel threshold in the initial spot image is calculated using the following formula: in, This represents the variance of pixels in the initial spot image that exceed the initial pixel threshold.

2. The adaptive threshold correction method for calculating beam divergence angle according to claim 1, characterized in that, Continuously acquire debugging spot images output by the image acquisition device, and calculate the maximum grayscale value of the debugging spot images, specifically including: The debugging spot image data is analyzed to obtain the total number of pixels in the debugging spot image and the pixel value of each pixel; Based on the total number of pixels and the pixel values, the maximum grayscale value of the debugging spot image is calculated.

3. The adaptive threshold correction method for calculating beam divergence angle according to claim 1, characterized in that, Based on the maximum grayscale value, the exposure of the image acquisition device is adjusted until an initial spot image with a maximum grayscale value and a number of pixels reaches a preset threshold is output, specifically including: Determine whether the maximum grayscale value of the debug spot image reaches the maximum grayscale value of the image acquisition device; If the maximum grayscale value of the debug spot image does not reach the maximum grayscale value of the image acquisition device, the exposure of the image acquisition device is increased, and the spot image is re-acquired until a first spot image with a maximum grayscale value equal to the maximum grayscale value of the image acquisition device is obtained. The number of pixels in the first light spot image is collected; If the number of pixels exceeds a preset threshold, the exposure of the image acquisition device is reduced until an initial spot image with a number of pixels less than the preset threshold is obtained.

4. The adaptive threshold correction method for calculating beam divergence angle according to claim 1, characterized in that, Setting pixel values ​​in the initial light spot image that are below the target pixel threshold to zero to obtain the target light spot image specifically includes: Iterate through each pixel in the initial spot image and extract the pixel value of each pixel; The pixel value of each pixel is compared with the target pixel threshold, and the distribution of pixels with pixel values ​​higher than the target pixel threshold and their neighboring pixels is recorded. Pixels whose pixel values ​​are higher than the target pixel threshold and whose neighborhood pixel distribution meets the preset distribution conditions are marked as valid spot core pixels, and the pixel values ​​of pixels whose pixel values ​​are lower than the target pixel threshold are directly set to zero, so as to obtain the target spot image.

5. The adaptive threshold correction method for calculating beam divergence angle according to claim 1, characterized in that, The first and second moments of the target spot image are calculated to obtain the beam divergence angle of the target spot image, which is expressed by the following formula: in, For the first The pixel value of each pixel. The sum of the energy of all light spots. , These represent the number of rows and columns of pixels in the target light spot image, respectively. For the purpose of action, For example, For the corresponding pixel grayscale, , This represents the column and row mean of the light spot image. , The variance in the column direction, To obtain the laser beam width, The resolution of a single pixel in an image acquisition device. To obtain the beam divergence angle of the light spot.

6. The adaptive threshold correction method for calculating beam divergence angle according to claim 4, characterized in that, The method further includes: Extract the grayscale value distribution data of the core pixels of the effective spot in the target spot image, and fit the grayscale distribution curve. The grayscale distribution curve is compared with the ideal Gaussian distribution curve, and the fitting deviation is calculated. If the fitting deviation exceeds the preset deviation threshold, the target pixel threshold is adjusted to obtain the corrected beam divergence angle.

7. An adaptive threshold-corrected beam divergence angle calculation device, characterized in that, The device includes: At least one processor; And, a memory communicatively connected to the at least one processor; The memory stores instructions that can be executed by the at least one processor, which are executed by the at least one processor to enable the at least one processor to perform an adaptive threshold correction beam divergence angle calculation method as described in any one of claims 1-6.

8. A non-volatile computer storage medium for adaptive threshold-corrected beam divergence angle calculation, storing computer-executable instructions, characterized in that, When the computer-executable instructions are executed, they implement the adaptive threshold correction beam divergence angle calculation method as described in any one of claims 1-6.

Citation Information

Patent Citations

  • Apparatus and method for characterizing texture

    US20150110359A1

  • Method and system for calculating laser beam spot size

    US20160364886A1