Light spot feature calculation method, device and equipment for dynamic image
By performing noise floor correction and feature calculation on CCD real-time spot images, the difficulty of spot feature calculation caused by drag in dynamic images is solved, and efficient and accurate spot feature acquisition is achieved, providing good data support for image processing and analysis.
Patent Information
- Application Number
- CN202510235067.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-28
- Publication Date
- 2025-06-06
AI Technical Summary
During the dynamic image capture process, due to the inconsistent frame rate, exposure time and spot movement speed of the camera, the shadow phenomenon is caused, which increases the difficulty of spot feature calculation, and interferes with image processing and analysis work.
By reading the real-time spot image of the CCD, noise floor correction is performed, non-zero pixels are filtered, index row and column vectors are generated, center of mass coordinates and variance is calculated, spot roundness and diameter are calculated based on the least squares method, and beam waist radius and beam divergence angle are calculated.
Effectively overcome the impact of shading on spot feature calculation, improve calculation efficiency, provide reliable and accurate spot features, and provide a good data foundation for subsequent processing and analysis work.
Smart Images

Figure CN120107337A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of optical technology, and further to the field of optical image processing, and in particular to a method, device and apparatus for calculating light spot characteristics for dynamic images. Background Art
[0002] The light spot is the intuitive and critical form of the light beam at the receiving end. The intensity distribution of the light spot can reflect the energy loss during the propagation of the light beam, the change of the center of mass position of the light spot can reflect the alignment accuracy of the optical system, and the shape and size of the light spot are closely related to the divergence of the light beam, focusing effect, etc.; in the process of dynamic image capture, usually because the camera's frame rate, exposure time and light spot movement speed are not compatible, a smear will be formed on the photosensitive element; the smear will make the shape, size and other features of the light spot unclear, increase the difficulty of calculating the light spot characteristics, and interfere with subsequent image processing and analysis.
[0003] Although adjusting the camera's frame rate, exposure time, and light spot movement speed can reduce the ghosting phenomenon, in actual application scenarios, there are still a variety of interferences that aggravate the ghosting. Therefore, it is difficult to adjust the three to a perfect adaptation state, and the adjustment requires a lot of time and effort. Therefore, how to accurately and efficiently calculate the light spot characteristics in dynamic images in a complex and changeable actual environment has become a problem that needs to be solved urgently. Summary of the invention
[0004] In view of this, the present disclosure provides a method, device and apparatus for calculating light spot features for dynamic images.
[0005] According to a first aspect of the present disclosure, a method for calculating spot features for dynamic images is provided, the method comprising: Read the real-time spot image of CCD, convert the real-time spot image into a pixel file, and use the reference background noise to perform background noise correction on the pixel file; Filter the pixels in the corrected pixel file that are smaller than the threshold value, set them to zero pixels, and calculate the sum of non-zero pixels; Generate an index row vector and an index column vector based on the index of the non-zero pixel matrix; Sum each row of the non-zero pixel matrix to get a column vector, multiply the column vector by the index row vector, and divide the product by the sum of the non-zero pixels to get the y coordinate value; Sum each column of the non-zero pixel matrix to get a row vector, multiply the row vector by the index column vector, and divide the product by the sum of the non-zero pixels to get the x-coordinate value; According to the x-coordinate value and the y-coordinate value, the x-direction centroid coordinate and the y-direction centroid coordinate of the light spot are obtained; According to the x-coordinate value and the y-coordinate value, the variance in the x-direction and the y-direction is calculated. According to the variance in the x-direction and the y-direction, the spot roundness and the spot diameter are calculated based on the least squares method. The beam waist radius and the beam divergence angle are calculated based on the spot diameter.
[0006] In some implementations of the first aspect, performing background noise correction on a pixel file using a reference background noise includes: Perform background noise correction on the pixel file of each real-time spot image according to the background noise correction formula; The noise correction formula is as follows: ; Where I (x, y) is the gray value of the original pixel in the pixel file of the real-time spot image; B max is the reference noise floor, e 2 is the normalization factor.
[0007] In some implementations of the first aspect, generating an index row vector and an index column vector based on an index of a non-zero pixel matrix includes: Based on the row index m and column index n of the non-zero pixel matrix, an index row vector R = [0, 1, ..., m-1] and an index column vector C = [0, 1, ..., n-1] are generated.
[0008] In some implementations of the first aspect, summing each row of the non-zero pixel matrix to obtain a column vector, multiplying the column vector by the index row vector, and dividing the product sum by the sum of the non-zero pixels to obtain a y coordinate value includes: Sum each row of the non-zero pixel matrix to get the column vector V y , the column vector V y Multiply the corresponding elements of the index row vector R and add all the products, that is: ; The sum of all products is divided by the sum of non-zero pixels S to obtain the y coordinate value, that is, the coordinate of the centroid in the y direction: y cm =Sum y / S.
[0009] In some implementations of the first aspect, summing each column of the non-zero pixel matrix to obtain a row vector, multiplying the row vector by the index column vector, and dividing the product sum by the sum of the non-zero pixels to obtain an x-coordinate value includes: Sum each column of the non-zero pixel matrix to get the row vector V x , the column vector V x Multiply the corresponding elements of the index row vector C and add all the products, that is: ; The sum of all products is divided by the sum of non-zero pixels S to obtain the x-coordinate value, that is, the x-direction centroid coordinate: x cm =Sum x / S.
[0010] In some implementations of the first aspect, the variances in the x-direction and the y-direction are calculated according to the x-coordinate value and the y-coordinate value, and the spot circularity and the spot diameter are calculated based on the least squares method according to the variances in the x-direction and the y-direction; and the beam divergence angle is calculated based on the spot diameter, including: Calculate the sum of the squares of the distances from each non-zero pixel to the x-coordinate value, and divide the sum of the squares by the sum of the non-zero pixels S to get the variance in the x-direction; Calculate the sum of the squares of the distances from each non-zero pixel to the y coordinate value, and divide the sum of the squares by the sum of the non-zero pixels S to get the variance in the y direction; Based on the least squares method, the spot circularity is calculated according to the spot circularity calculation formula; wherein, the spot circularity calculation formula is as follows: ; is the sum of the squares of the distances from all non-zero pixels to the fitting circle obtained by the least squares method; k is the weight coefficient; The square root of the sum of the variances in the x-direction and the y-direction is taken to obtain the spot diameter, and the beam waist radius is obtained based on the spot diameter; Multiply the spot diameter and the CCD angular resolution to obtain the beam divergence angle.
[0011] In some implementations of the first aspect, the method further includes: Using the variance in the x direction and the variance in the y direction , the beam divergence angle is corrected; the corrected beam divergence angle θ n It can be defined as: ; in, and is the variance of the ideal spot in the x and y directions.
[0012] According to a second aspect of the present disclosure, a device for calculating light spot features for dynamic images is provided. The device comprises: The first processing module is used to read the real-time spot image of the CCD, convert the real-time spot image into a pixel file, and perform background noise correction on the pixel file using a reference background noise; The second processing module is used for screening pixels smaller than a threshold in the corrected pixel file, setting them as zero pixels, and calculating the sum of non-zero pixels; A third processing module, used for generating an index row vector and an index column vector based on the index of the non-zero pixel matrix; A fourth processing module is used to sum each row of the non-zero pixel matrix to obtain a column vector, multiply the column vector by the index row vector, and divide the product sum by the sum of the non-zero pixels to obtain a y coordinate value; A fifth processing module is used to sum each column of the non-zero pixel matrix to obtain a row vector, multiply the row vector by the index column vector, and divide the product sum by the sum of the non-zero pixels to obtain an x-coordinate value; A sixth processing module, used for obtaining the centroid coordinates in the x direction and the centroid coordinates in the y direction of the light spot according to the x coordinate value and the y coordinate value; The seventh processing module is used to calculate the variance in the x-direction and the y-direction according to the x-coordinate value and the y-coordinate value, and calculate the spot roundness and the spot diameter based on the least squares method according to the variance in the x-direction and the y-direction; and calculate the beam waist radius and the beam divergence angle based on the spot diameter.
[0013] According to a third aspect of the present disclosure, an electronic device is provided. The electronic device includes: at least one processor; and a memory connected to the at least one processor in communication; the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method described above.
[0014] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, where the computer instructions are used to cause a computer to execute the method described above.
[0015] In the present disclosure, the reference background noise is used to correct the background noise of the pixel file, which can reduce the influence of background noise on the light spot characteristics when processing the real-time light spot image, highlight the real signal of the light spot itself, and provide a better data basis for the subsequent accurate calculation of various characteristics of the light spot; by accurately calculating the center of mass coordinates, the influence of problems such as smear can be effectively overcome, and the light spot morphological characteristics that are closer to the actual situation can be restored.
[0016] It should be understood that the contents described in the summary of the invention are not intended to limit the key or important features of the embodiments of the present disclosure, nor are they intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure. In the accompanying drawings, the same or similar reference numerals represent the same or similar elements, among which: Figure 1 A flow chart of a method for calculating light spot features for dynamic images provided by an embodiment of the present disclosure is shown; Figure 2 A block diagram of a light spot feature calculation device for dynamic images according to an embodiment of the present disclosure is shown; Figure 3 A block diagram of an exemplary electronic device capable of implementing embodiments of the present disclosure is shown. DETAILED DESCRIPTION
[0018] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present disclosure.
[0019] In addition, the term "and / or" in this article is only a description of the association relationship between the associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0020] In response to the problems mentioned in the background technology, the present disclosure provides a method, device and equipment for calculating spot features for dynamic images.
[0021] Specifically, the real-time spot image of the CCD is read, the real-time spot image is converted into a pixel file, and the pixel file is subjected to background noise correction using a reference background noise; pixels in the corrected pixel file that are less than a threshold value are screened and set to zero pixels, and the sum of non-zero pixels is calculated; an index row vector and an index column vector are generated based on the index of the non-zero pixel matrix; each row of the non-zero pixel matrix is summed to obtain a column vector, the column vector is multiplied by the index row vector, and the sum of the products is divided by the sum of the non-zero pixels to obtain a y coordinate value; each column of the non-zero pixel matrix is summed to obtain a row vector, the row vector is multiplied by the index column vector, and the sum of the products is divided by the sum of the non-zero pixels to obtain an x coordinate value; according to the x coordinate value and the y coordinate value, the x-direction centroid coordinates and the y-direction centroid coordinates of the spot are obtained; according to the x coordinate value and the y coordinate value, the variance in the x direction and the y direction is calculated, and according to the variance in the x direction and the y direction, the spot roundness and the spot diameter are calculated based on the least squares method; the beam waist radius and the beam divergence angle are calculated based on the spot diameter.
[0022] In this way, the influence of problems such as smear on the calculation of spot features can be effectively overcome, saving time and energy spent on adjusting camera parameters in actual operation and improving calculation efficiency.
[0023] The following is a more detailed description of the spot feature calculation method, device and equipment for dynamic images provided by the present disclosure based on the accompanying drawings and specific embodiments.
[0024] Figure 1 FIG. 1 is a flow chart showing a method for calculating light spot features for dynamic images provided by an embodiment of the present disclosure; Figure 1 As shown, the spot feature calculation method 100 for dynamic images may include: S110, reading the real-time spot image of the CCD, converting the real-time spot image into a pixel file, and performing background noise correction on the pixel file using a reference background noise.
[0025] Specifically, the noise correction is performed on the pixel file of each real-time spot image according to the noise correction formula; the noise correction formula is as follows: ; Where I (x, y) is the gray value of the original pixel in the pixel file of the real-time spot image; B max is the reference noise floor, e 2 is the normalization factor.
[0026] Furthermore, the reference noise floor can be obtained by the following steps: When the spot imaging system is started but there is no actual spot signal input, the same CCD camera and parameters as those for subsequent spot acquisition are used to continuously acquire N background noise images to ensure that various fluctuations of the background noise are fully covered; for each background noise image, all pixels are traversed, the maximum pixel value is recorded, and the maximum pixel value is used as the reference background noise; the maximum pixel value can be set to take the maximum pixel value of all pixels, or to take the maximum pixel value or pixel average of each pixel.
[0027] According to the embodiments of the present disclosure, the real-time spot image is processed by the background noise correction formula, which can effectively eliminate the interference of the background noise on the spot image, making the spot image clearer and the real characteristics of the spot more obvious, providing a better data basis for subsequent spot feature analysis.
[0028] S120, filtering pixels smaller than a threshold in the corrected pixel file, setting them to zero pixels, and calculating the sum of non-zero pixels.
[0029] Specifically, for each corrected light spot image, all pixels are traversed. When the corrected grayscale value of the pixel is greater than or equal to the preset threshold, the pixel value of the pixel is set to 1, indicating that it belongs to the light spot area; when the corrected grayscale value is less than the preset threshold, the pixel value of the pixel is set to 0, indicating that it belongs to the background area. The sum S of non-zero pixels is calculated to obtain the area of the light spot area.
[0030] S130, generating an index row vector and an index column vector based on the index of the non-zero pixel matrix.
[0031] Specifically, based on the row index m and column index n of the non-zero pixel matrix, an index row vector R=[0, 1, ..., m-1] and an index column vector C=[0, 1, ..., n-1] are generated.
[0032] S140, sum each row of the non-zero pixel matrix to obtain a column vector, multiply the column vector by the index row vector, and divide the product sum by the sum of the non-zero pixels to obtain a y coordinate value.
[0033] Specifically, sum each row of the non-zero pixel matrix to obtain the column vector V y , the column vector V y Multiply the corresponding elements of the index row vector R and add all the products, that is: ; The sum of all products is divided by the sum of non-zero pixels S to obtain the y coordinate value, that is, the coordinate of the centroid in the y direction: y cm =Sum y / S.
[0034] S150, sum each column of the non-zero pixel matrix to obtain a row vector, multiply the row vector by the index column vector, and divide the product by the sum of the non-zero pixels to obtain an x-coordinate value.
[0035] Specifically, sum each column of the non-zero pixel matrix to obtain the row vector V x , the column vector V x Multiply the corresponding elements of the index row vector C and add all the products, that is: ; The sum of all products is divided by the sum of non-zero pixels S to obtain the x-coordinate value, that is, the x-direction centroid coordinate: cm =Sum x / S.
[0036] S160, obtaining the centroid coordinates in the x direction and the centroid coordinates in the y direction of the light spot according to the x coordinate value and the y coordinate value.
[0037] S170, calculating the variance in the x direction and the y direction according to the x coordinate value and the y coordinate value, calculating the spot roundness and the spot diameter based on the least square method according to the variance in the x direction and the y direction; and calculating the beam waist radius and the beam divergence angle based on the spot diameter.
[0038] Specifically, the sum of the squares of the distances from each non-zero pixel to the x-coordinate value is calculated, and the sum of the squares is divided by the sum S of the non-zero pixels to obtain the variance in the x-direction.
[0039] Each non-zero pixel (x i ,y i The square of the distance from the centroid coordinate x is (x i -x) 2 , the sum of squares is S x , then the variance in the x direction is .
[0040] Calculate the sum of the squares of the distances from each non-zero pixel to the y coordinate value, and divide the sum of the squares by the sum of the non-zero pixels S to get the variance in the y direction.
[0041] Each non-zero pixel (x i ,y i The square of the distance from the center of mass coordinate y is (y i -y) 2 , the sum of squares is S y , then the variance in the y direction is .
[0042] Based on the least squares method, the spot circularity is calculated according to the spot circularity calculation formula. When fitting a circle using the least squares method, the goal is to find a set (a, b, r) such that all pixels (x i ,y i ) is the smallest sum of the squares of the distances to the circle; where (a, b) are the coordinates of the center of the circle and r is the radius.
[0043] Distance d i The calculation formula is , the objective function minimize.
[0044] The spot circularity C is defined as: ; It is the sum of the squares of the distances from all non-zero pixels to the fitting circle obtained by the least squares method; k is the weight coefficient.
[0045] The square root of the sum of the variances in the x-direction and the y-direction is taken to obtain the spot diameter. The equivalent diameters in the x-direction and the y-direction can also be calculated based on the variances in the x-direction and the averaging is performed to obtain the spot diameter D. In actual calculations, the spot radius can also be fitted based on the least squares method, and the spot diameter can be obtained from the spot radius. , the beam waist radius can be further calculated.
[0046] Furthermore, the beam divergence angle can be obtained by using the spot diameter D×CCD angular resolution.
[0047] In some embodiments, the spot feature calculation method 100 for dynamic images may further include: The beam divergence angle is corrected using the variances in the x-direction and the y-direction calculated above.
[0048] The beam divergence angle is originally calculated by the spot diameter D and the CCD angular resolution rate. Considering that the variance reflects the discrete degree of the spot in the x and y directions, the beam divergence angle can be corrected using the variance to more accurately reflect the actual divergence of the spot.
[0049] Corrected beam divergence angle θ n It can be defined as: ; in, and is the variance of the ideal spot in the x and y directions.
[0050] According to the embodiments of the present disclosure, the variance reflects the degree of discreteness of the spot pixels in the x and y directions. Including it in the calculation makes the roundness index not only consider the distance from the pixel to the fitting circle, but also take into account the uniformity of the distribution of the spot in different directions. By introducing the variance to calculate the spot roundness and diameter, the roundness and diameter of the spot can be further calculated. Compared with the traditional method that only relies on the least squares method, the calculation of beam divergence can more comprehensively and accurately reflect the actual characteristics of the light spot, and provide more reliable information for the analysis and optimization of the optical system.
[0051] A specific embodiment is provided below to illustrate the above content in more detail.
[0052] S110, reading the real-time spot image of the CCD, converting the real-time spot image into a pixel file, and performing background noise correction on the pixel file using a reference background noise.
[0053] Assuming that the resolution of the CCD camera is 320×256, the collected real-time spot image data is as follows: [10, 12, 15, 0, 0, ..., 0], [13, 18, 20, 0, 0, ..., 0], [16, 22, 25, 0, 0, ..., 0], [13, 18, 20, 0, 0, ..., 0], When the spot imaging system is started but there is no actual spot signal input, the same CCD camera and imaging parameters are used to continuously collect 5 background noise images. The data are as follows: noise_image_1: [5, 3, 4, 2, 1, ..., 0], [4, 3, 2, 2, 1, ..., 0], [3, 2, 2, 1, 1, ..., 0], [0, 0, 0, 0, 0, ..., 0] noise_image_2: [4, 3, 3, 2, 1, ..., 0], [3, 3, 2, 2, 1, ..., 0], [2, 2, 2, 1, 1, ..., 0], [0, 0, 0, 0, 0, ..., 0] noise_image_3: [6, 4, 4, 3, 2, ..., 0], [5, 4, 3, 3, 2, ..., 0], [4, 3, 3, 2, 2, ..., 0], [0, 0, 0, 0, 0, ..., 0] noise_image_4: [5, 3, 4, 2, 1, ..., 0], [4, 3, 2, 2, 1, ..., 0], [3, 2, 2, 1, 1, ..., 0], [0, 0, 0, 0, 0, ..., 0] noise_image_5: [4, 3, 3, 2, 1, ..., 0], [3, 3, 2, 2, 1, ..., 0], [2, 2, 2, 1, 1, ..., 0], [0, 0, 0, 0, 0, ..., 0] As an example, traverse all pixels of each background noise image and record the maximum pixel value: For noise_image_1, the maximum pixel value obtained after traversal is max_pixel_1 = 5.
[0054] For noise_image_2, the maximum pixel value obtained after traversal is max_pixel_2 = 4.
[0055] For noise_image_3, the maximum pixel value obtained after traversal is max_pixel_3 = 6.
[0056] For noise_image_4, the maximum pixel value obtained after traversal is max_pixel_4 = 5.
[0057] For noise_image_5, the maximum pixel value obtained after traversal is max_pixel_5 = 4.
[0058] Comparing the above maximum pixel values, since max_pixel_3 = 6 is the largest, the pixel value 6 is selected as the reference background noise Bmax.
[0059] As another example, we traverse all pixels of each noise-based image and record the maximum pixel value: After traversal, the maximum pixel value of pixel point (0, 0) is max_pixel_(0, 0) = 6; After traversing, we get the maximum pixel value of pixel point (1, 0) max_pixel_(0, 0) = 5; After traversing, we get the maximum pixel value of pixel point (0, 1) max_pixel_(0, 0)=4; After traversing, we get the maximum pixel value of pixel point (1, 1) max_pixel_(0, 0) = 4; ... Select the maximum pixel value corresponding to each pixel as the reference background noise B max At this time, according to the correction formula, the pixel value of each pixel in the real-time spot image minus the corresponding reference background noise B max Calculate the corrected grayscale value of each pixel.
[0060] As another example, we traverse all pixels of each noise-based image and record the pixel mean: After traversing, we get the pixel mean value of pixel point (0, 0) max_pixel_(0, 0) = (5+4+6+5+4) / 5 = 4.8; After traversing, we get the pixel mean of pixel point (1, 0) max_pixel_(0, 0) = (4+3+5+4+3) / 5 = 3.8; After traversing, we get the pixel mean value of pixel point (0, 1) max_pixel_(0, 0) = (3+3+4+3+3) / 5 = 3.2; After traversing, we get the pixel mean value of pixel point (1, 1) max_pixel_(0, 0) = (3+3+4+3+3) / 5 = 3.2; ... Select the maximum pixel mean corresponding to each pixel as the reference background noise B max At this time, according to the correction formula, the pixel value of each pixel in the real-time spot image minus the corresponding reference background noise B max Calculate the corrected grayscale value of each pixel.
[0061] Furthermore, the reference noise floor is used for correction: Assume the normalization factor e 2 = 1. Taking the above example of selecting the maximum pixel value 6 as the reference background noise, the original grayscale value of the pixel point (0,0) in the real-time spot image is I(0,0)=10, and the corrected grayscale value is: I 校正 (0,0)=(10 -6) / 1=4.
[0062] The same calculation is performed on all pixels of the real-time spot image to obtain the corrected real-time spot image: [4, 6, 9, -6, -6, ..., -6], [7, 12, 14, -6, -6, ..., -6], [10, 16, 19, -6, -6, ..., -6], ... [-6, -6, -6, -6, -6, ..., -6] S120, filtering pixels smaller than a threshold in the corrected pixel file, setting them to zero pixels, and calculating the sum of non-zero pixels.
[0063] Assume that the corrected pixel file is a 100×100 pixel image P, and the threshold T=6 is preset. The corrected pixel file is traversed, and the pixel values less than the threshold 6 are set to 0 to obtain a new pixel matrix P'.
[0064] S130, generating an index row vector and an index column vector based on the index of the non-zero pixel matrix.
[0065] Traverse the new pixel matrix P' to obtain the row index range m=10 (from the 1st row to the 10th row) and the column index range n=15 (from the 1st column to the 15th column) of P', count all non-zero pixel values and sum them, and get the total number of non-zero pixels S=300.
[0066] Based on the row index m, generate the index row vector R = [0, 1, 2, ..., 9]; based on the column index n, generate the index column vector C = [0, 1, 2, ..., 14].
[0067] S140, sum each row of the non-zero pixel matrix to obtain a column vector, multiply the column vector by the index row vector, and divide the product sum by the sum of the non-zero pixels to obtain a y coordinate value.
[0068] Sum each row of the non-zero pixel matrix P' to get a column vector: ; The column vector V y Multiply the corresponding elements of the index row vector R and add all the products to get Sum y=60×0+150×1+…+50×9=1800; Then the coordinate of the center of mass in the y direction is: y=1800 / 300=6.
[0069] S150, sum each column of the non-zero pixel matrix to obtain a row vector, multiply the row vector by the index column vector, and divide the product by the sum of the non-zero pixels to obtain an x-coordinate value.
[0070] Sum each column of the non-zero pixel matrix P' to get the row vector: V x =[70 150 80 … 50]; The row vector V x Multiply the corresponding elements of the index column vector C and add all the products to get Sum x =2100; Then the coordinate of the center of mass in the x direction is: y=2100 / 300=7.
[0071] S160, obtaining the centroid coordinates in the x direction and the centroid coordinates in the y direction of the light spot according to the x coordinate value and the y coordinate value.
[0072] Through the above calculation, it can be obtained that the coordinates of the center of mass of the light spot are (7, 6).
[0073] S170, calculating the variance in the x direction and the y direction according to the x coordinate value and the y coordinate value, calculating the spot roundness and the spot diameter based on the least square method according to the variance in the x direction and the y direction; and calculating the beam waist radius and the beam divergence angle based on the spot diameter.
[0074] Assume S=300, calculate the sum of the squares of the distances from each non-zero pixel (i, j) to the x-coordinate value, and divide the sum of the squares by the sum of the non-zero pixels S to obtain the variance in the x-direction; illustratively: ; Assume S=300, calculate the sum of the squares of the distances from each non-zero pixel (i, j) to the y coordinate value, and divide the sum of the squares by the sum of the non-zero pixels S to obtain the variance in the y direction; illustratively: ; Assumptions , k=0.1, and substitute S=300: , the spot circularity C≈7.65.
[0075] According to the variance in the x-direction and the y-direction, the equivalent diameters in the x-direction and the y-direction are calculated respectively, and we can get , , taking the average value, we get the spot diameter D=28.12+24.2 / 2=26.16.
[0076] Then the waist radius .
[0077] Assuming that the CCD angular resolution is ɑ=0.01 radians, the beam divergence angle θ=26.16×0.01≈0.2 radians can be obtained.
[0078] Assuming that the variance of the ideal spot in the x and y directions is 10, and the beam divergence angle θ = 0.2 radians, the corrected beam divergence angle is .
[0079] It should be noted that, in order to facilitate the explanation of the content of the solution, the present disclosure provides the above simple examples. In actual environments, since the electronic components inside the CCD camera will generate inherent noise when working, even if there is no external light signal input, the pixel points will have a certain electrical signal output, which will appear as a non-zero pixel value. Therefore, the image value of each pixel point of the non-spot image is mostly between 50 and 200, and the spot image has a variety of complex pixel value expressions depending on different situations.
[0080] According to the embodiments of the present disclosure, the following technical effects are achieved: It effectively overcomes the influence of problems such as smear on the calculation of spot features, without wasting time and energy on complex adjustments to camera parameters, thus improving calculation efficiency; and the calculated spot features are reliable and accurate, providing a good data foundation for subsequent processing and analysis based on spot features.
[0081] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should be aware that the present disclosure is not limited by the order of the actions described, because according to the present disclosure, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present disclosure.
[0082] The above is an introduction to the method embodiment. The following is a further explanation of the scheme disclosed in the present invention through an apparatus embodiment.
[0083] Figure 2 FIG. 4 is a block diagram of a light spot feature calculation device for dynamic images according to an embodiment of the present disclosure. Figure 2 As shown, the spot feature calculation device 200 for dynamic images may include: The first processing module is used to read the real-time spot image of the CCD, convert the real-time spot image into a pixel file, and perform background noise correction on the pixel file using a reference background noise.
[0084] The second processing module is used for screening out pixels smaller than a threshold in the corrected pixel file, setting them as zero pixels, and calculating the sum of non-zero pixels.
[0085] The third processing module is used to generate an index row vector and an index column vector based on the index of the non-zero pixel matrix.
[0086] The fourth processing module is used to sum each row of the non-zero pixel matrix to obtain a column vector, multiply the column vector by the index row vector, and divide the product sum by the sum of the non-zero pixels to obtain a y coordinate value.
[0087] The fifth processing module is used to sum each column of the non-zero pixel matrix to obtain a row vector, multiply the row vector by the index column vector, and divide the product sum by the sum of the non-zero pixels to obtain an x-coordinate value.
[0088] The sixth processing module is used to obtain the centroid coordinates in the x direction and the centroid coordinates in the y direction of the light spot according to the x coordinate value and the y coordinate value.
[0089] The seventh processing module is used to calculate the variance in the x-direction and the y-direction according to the x-coordinate value and the y-coordinate value, and calculate the spot roundness and the spot diameter based on the least squares method according to the variance in the x-direction and the y-direction; and calculate the beam waist radius and the beam divergence angle based on the spot diameter.
[0090] Understandably, Figure 2 Each module in the light spot feature calculation device 200 for dynamic images shown has the function of implementing each step in the light spot feature calculation method 100 for dynamic images provided in the embodiment of the present disclosure, and can achieve its corresponding technical effect. The specific working process of the described modules can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here for the convenience and brevity of description.
[0091] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device and a readable storage medium.
[0092] Figure 3 A block diagram of an exemplary electronic device capable of implementing embodiments of the present disclosure is shown.
[0093] The electronic device 300 is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0094] The electronic device 300 includes a computing unit 301, which can perform various appropriate actions and processes according to a computer program stored in a ROM 302 or a computer program loaded from a storage unit 308 into a RAM 303. In the RAM 303, various programs and data required for the operation of the electronic device 300 can also be stored. The computing unit 301, the ROM 302, and the RAM 303 are connected to each other via a bus 304. An I / O interface 305 is also connected to the bus 304.
[0095] A number of components in the electronic device 300 are connected to the I / O interface 305, including: an input unit 306, such as a keyboard, a mouse, etc.; an output unit 307, such as various types of displays, speakers, etc.; a storage unit 308, such as a disk, an optical disk, etc.; and a communication unit 309, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 309 allows the electronic device 300 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0096] The computing unit 301 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 301 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 301 performs the various methods and processes described above, such as method 100. For example, in some embodiments, the method 100 may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 308. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 300 via the ROM 302 and / or the communication unit 309. When the computer program is loaded into the RAM 303 and executed by the computing unit 301, one or more steps of the method 100 described above may be performed. Alternatively, in other embodiments, the computing unit 301 may be configured to perform the method 100 in any other appropriate manner (e.g., by means of firmware).
[0097] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0098] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0099] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0100] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0101] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0102] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0103] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0104] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A method for calculating spot features for dynamic images, characterized in that: The method comprises: Read the real-time spot image of the CCD, convert the real-time spot image into a pixel file, and perform background noise correction on the pixel file using a reference background noise; Filter the pixels in the corrected pixel file that are smaller than the threshold value, set them to zero pixels, and calculate the sum of non-zero pixels; Generate an index row vector and an index column vector based on the index of the non-zero pixel matrix; Summing each row of the non-zero pixel matrix to obtain a column vector, multiplying the column vector by the index row vector, and dividing the product by the sum of the non-zero pixels to obtain a y coordinate value; Summing each column of the non-zero pixel matrix to obtain a row vector, multiplying the row vector by the index column vector, and dividing the product by the sum of the non-zero pixels to obtain an x-coordinate value; According to the x-coordinate value and the y-coordinate value, the x-direction centroid coordinate and the y-direction centroid coordinate of the light spot are obtained; According to the x-coordinate value and the y-coordinate value, the variance in the x-direction and the y-direction is calculated. According to the variance in the x-direction and the y-direction, the spot roundness and the spot diameter are calculated based on the least squares method. The beam waist radius and the beam divergence angle are calculated based on the spot diameter.
2. The method according to claim 1, characterized in that The performing background noise correction on the pixel file by using the reference background noise includes: Perform background noise correction on the pixel file of each real-time spot image according to the background noise correction formula; The noise correction formula is as follows: ; Where I (x, y) is the gray value of the original pixel in the pixel file of the real-time spot image; B max is the reference noise floor, e 2 is the normalization factor.
3. The method according to claim 1, characterized in that The step of generating an index row vector and an index column vector based on the index of the non-zero pixel matrix includes: Based on the row index m and column index n of the non-zero pixel matrix, an index row vector R = [0, 1, ..., m-1] and an index column vector C = [0, 1, ..., n-1] are generated.
4. The method according to claim 1, characterized in that: The method of summing each row of the non-zero pixel matrix to obtain a column vector, multiplying the column vector by the index row vector, and dividing the product by the sum of the non-zero pixels to obtain a y coordinate value includes: Sum each row of the non-zero pixel matrix to get the column vector V y , the column vector V y Multiply the corresponding elements of the index row vector R and add all the products, that is: ; The sum of all products is divided by the sum of non-zero pixels S to obtain the y coordinate value, that is, the coordinate of the centroid in the y direction: y cm =Sum y / S.
5. The method according to claim 1, characterized in that The method of summing each column of the non-zero pixel matrix to obtain a row vector, multiplying the row vector by the index column vector, and dividing the product by the sum of the non-zero pixels to obtain an x-coordinate value includes: Sum each column of the non-zero pixel matrix to get the row vector V x , the column vector V x Multiply the corresponding elements of the index row vector C and add all the products, that is: ; The sum of all products is divided by the sum of non-zero pixels S to obtain the x-coordinate value, that is, the x-direction centroid coordinate: x cm =Sum x / S.
6. The method according to claim 1, characterized in that The method further comprises calculating the variance of the x-direction and the y-direction according to the x-coordinate value and the y-coordinate value, and calculating the spot circularity and the spot diameter based on the least square method according to the variance of the x-direction and the y-direction; Calculates beam divergence based on spot diameter, including: Calculate the sum of the squares of the distances from each non-zero pixel to the x-coordinate value, and divide the sum of the squares by the sum of the non-zero pixels S to get the variance in the x-direction; Calculate the sum of the squares of the distances from each non-zero pixel to the y coordinate value, and divide the sum of the squares by the sum of the non-zero pixels S to get the variance in the y direction; Based on the least squares method, the spot circularity is calculated according to the spot circularity calculation formula; wherein, the spot circularity calculation formula is as follows: ; is the sum of the squares of the distances from all non-zero pixels to the fitting circle obtained by the least squares method; k is the weight coefficient; The square root of the sum of the variances in the x-direction and the y-direction is taken to obtain the spot diameter, and the beam waist radius is obtained based on the spot diameter; Multiply the spot diameter and the CCD angular resolution to obtain the beam divergence angle.
7. The method according to claim 1, characterized in that The method further comprises: Using the variance in the x direction and the variance in the y direction , the beam divergence angle θ is corrected; the corrected beam divergence angle θ n It can be defined as: ; in, and is the variance of the ideal spot in the x and y directions.
8. A spot feature calculation device for dynamic images, characterized in that: include: The first processing module is used to read the real-time spot image of the CCD, convert the real-time spot image into a pixel file, and perform background noise correction on the pixel file using a reference background noise; The second processing module is used for screening pixels smaller than a threshold in the corrected pixel file, setting them as zero pixels, and calculating the sum of non-zero pixels; A third processing module, used for generating an index row vector and an index column vector based on the index of the non-zero pixel matrix; A fourth processing module is used to sum each row of the non-zero pixel matrix to obtain a column vector, multiply the column vector by the index row vector, and divide the product sum by the sum of the non-zero pixels to obtain a y coordinate value; A fifth processing module is used to sum each column of the non-zero pixel matrix to obtain a row vector, multiply the row vector by the index column vector, and divide the product sum by the sum of the non-zero pixels to obtain an x-coordinate value; A sixth processing module, used for obtaining the centroid coordinates in the x direction and the centroid coordinates in the y direction of the light spot according to the x coordinate value and the y coordinate value; The seventh processing module is used to calculate the variance in the x-direction and the y-direction according to the x-coordinate value and the y-coordinate value, calculate the spot roundness and the spot diameter based on the variance in the x-direction and the y-direction based on the least squares method; and calculate the beam waist radius and the beam divergence angle based on the spot diameter.
9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory in communication with the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to cause the computer-readable storage medium to execute the method according to any one of claims 1-7.
Citation Information
Cited By
Light spot beam divergence angle calculation method and device based on self-adaptive threshold correction and medium
CN121259087A