Reflection sphere light spot centroid positioning method based on adaptive expansion and background compensation
By employing adaptive expansion and background compensation methods, the bottleneck in centroid positioning accuracy of the reflective sphere spot was resolved, achieving high-precision and high-stability spot center positioning, which is applicable to fields such as surgical navigation, visual tracking, and industrial online measurement.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HANGZHOU INST FOR ADVANCED STUDY UCAS
- Filing Date
- 2026-02-05
- Publication Date
- 2026-06-23
AI Technical Summary
Under complex imaging conditions, existing technologies suffer from bottlenecks in centroid positioning accuracy of reflected spherical spots due to inaccurate fixed threshold segmentation and background interference, making it difficult to achieve high-precision adaptive expansion and background compensation.
An adaptive expansion and background compensation method is adopted. The initial ROI boundary is expanded by an adaptive gray-level gradient criterion, and background gray-level estimation compensation is performed to improve the gray-level centroid method for calculating the center coordinates of the spot.
It significantly improves the accuracy and stability of spot centroid positioning, overcomes the limitations of traditional methods, enhances positioning accuracy, and reduces sensitivity to image contrast, making it suitable for applications requiring high precision.
Smart Images

Figure CN122265387A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of light spot positioning technology, specifically relating to a method for positioning the centroid of a reflective sphere light spot based on adaptive expansion and background compensation. Background Technology
[0002] Improving the centroid positioning accuracy of a reflective sphere's light spot refers to the process of more accurately analyzing and calculating the image light spot formed by the reflective sphere in high-precision applications such as optical 3D measurement and visual tracking, so that the positioning result of its center coordinates is closer to the true geometric center. This accuracy is the cornerstone of subsequent 3D coordinate reconstruction and spatial analysis, and directly determines the final performance of the entire measurement system.
[0003] In practical engineering, the imaging of a reflective sphere spot often deviates from the ideal model. Factors such as ambient stray light, surface contamination of the reflective sphere, camera exposure differences, and non-perpendicular observation angles can easily lead to complex problems such as uneven brightness distribution, gradual blurring of edges, and dynamic changes in background contrast. These non-ideal imaging characteristics make the accurate extraction of the spot center a challenging technical problem.
[0004] Current mainstream technical solutions generally adopt a two-step process of "fixed threshold segmentation - traditional gray-level centroid calculation". First, the image is binarized by a preset global gray-level threshold to separate the spot area from the background; then, the gray-level centroid method is applied to the segmented area, and a weighted average center is calculated using pixel gray-level values as weights. However, this approach has obvious drawbacks: fixed threshold segmentation has poor adaptability: the global threshold cannot adapt to dynamic changes in image brightness and contrast, easily leading to undersegmentation or oversegmentation of the spot area, making it difficult to accurately capture gray-level gradient edges, resulting in the calculation area containing unrealistic boundary information; the traditional gray-level centroid method does not eliminate background interference: it directly calculates the center using pixel gray-level weights without distinguishing between the spot signal and background noise, incorporating the gray-level of background pixels within the area into the calculation, thus causing the centroid to shift towards the high gray-level background, introducing systematic errors.
[0005] The errors in the two stages mentioned above are coupled with each other in the process: inaccurate segmentation in the front stage leads to contamination of the basic data for calculation in the back stage, and traditional algorithms cannot correct the contaminated data, which together restricts the further improvement of positioning accuracy.
[0006] Therefore, how to overcome the bottleneck of spot centroid positioning accuracy caused by inaccurate fixed threshold segmentation and uncompensated background interference under complex imaging conditions, and provide a method for positioning the center of a reflective sphere spot that can adaptively expand the target area, actively suppress background interference, and achieve high-precision adaptive correction, is a technical problem that urgently needs to be solved by those skilled in the art. Summary of the Invention
[0007] The purpose of this invention is to provide a method for locating the centroid of a reflective sphere spot based on adaptive expansion and background compensation, addressing the problems in the prior art.
[0008] Therefore, the above-mentioned objectives of the present invention are achieved through the following technical solutions:
[0009] The method for localizing the centroid of a reflective sphere spot based on adaptive expansion and background compensation includes the following steps:
[0010] S1. Obtain a grayscale image containing the reflected spherical spot;
[0011] S2. The grayscale image is binarized using a fixed threshold segmentation method to obtain a binarized image, thereby separating the initial spot region.
[0012] S3. Extract the contour of the initial spot region in the binarized image and determine its minimum bounding rectangle as the initial ROI;
[0013] S4. Adaptively expand each boundary of the initial ROI to obtain the target ROI;
[0014] The adaptive expansion process includes:
[0015] Calculate the average grayscale gradient of the initial ROI boundary region;
[0016] Determine whether the average gray-level gradient is greater than a preset gradient threshold;
[0017] If it is greater than the specified value, then expand the boundary outward by one pixel and update the boundary position.
[0018] Repeat the above calculations and judgments until the average gray-scale gradient is not greater than the preset gradient threshold, or the preset maximum number of expansions is reached;
[0019] S5. Based on the target ROI, the center coordinates of the reflected spherical spot are calculated using the background compensation centroid method.
[0020] While adopting the above technical solutions, the present invention may also adopt or combine the following technical solutions:
[0021] As a preferred technical solution of the present invention: In step S2, the fixed threshold segmentation method uses a preset global grayscale threshold to mark the region in the grayscale image with a pixel value greater than the threshold as the target region, and the region with a pixel value less than or equal to the threshold as the background region.
[0022] As a preferred technical solution of the present invention: In step S4, the average gray-level gradient is calculated as follows: For the current boundary, its average gray-level gradient is... Calculated using the following formula:
[0023]
[0024] in, and Let represent the grayscale values of the outermost pixel inside the initial ROI and the nearest neighbor pixel outside, respectively, where N is the total number of pixels at the boundary. The boundary expansion condition is: if , If the preset gradient threshold is not met, expansion will be performed; otherwise, expansion will stop.
[0025] As a preferred technical solution of the present invention: to suppress excessive boundary expansion caused by random noise, a maximum expansion number is set. .
[0026] As a preferred technical solution of the present invention: In step S5, the background compensation centroid method includes the following steps:
[0027] S501, Calculate the average grayscale value of the outermost pixels of the target ROI as the background estimate;
[0028] S502, obtain the compensated grayscale distribution for each of the background grayscale estimates within the target ROI;
[0029] S503, based on the compensated gray-level distribution, the gray-level centroid method is used to calculate the center coordinates of the light spot.
[0030] As a preferred technical solution of the present invention: in step 503, the pixel coordinates of the light spot center... The calculation formula is:
[0031]
[0032] In the formula, This is the estimated grayscale value for the background. This represents the grayscale value within the ROI.
[0033] Compared with existing technologies, the present invention provides a method for centroid localization of reflective sphere light spots based on adaptive extension and background compensation, which has the following advantages: The present invention utilizes an adaptive ROI boundary dynamic extension method based on average gray-level gradient criteria to intelligently extend the initial binary contour, so that the target ROI can more completely encompass the real gray-level gradient edge of the light spot, laying the foundation for subsequent high-precision calculation. While capturing the light spot signal more completely, it also introduces a small number of background pixels.
[0034] This invention innovatively improves the classic gray-scale centroid method. By performing local background estimation on the target ROI and substituting the estimated background gray value as a compensation term into the centroid calculation formula, the problem of background interference within the expanded ROI is solved, thereby effectively suppressing the systematic deviation introduced by the background gray value. This compensation step achieves high-precision centroid positioning based on complete spot data.
[0035] This invention systematically solves the two core problems leading to decreased positioning accuracy—incomplete edge capture and sensitivity to background interference—by combining adaptive expansion and background compensation. The method overcomes the limitations of traditional fixed-threshold segmentation, significantly improving the stability and accuracy of spot positioning under complex imaging conditions. It achieves positioning accuracy close to that of the computationally more complex Gaussian fitting method, while significantly outperforming Gaussian fitting in computational speed. It maintains high efficiency comparable to the classic gray-scale centroid method, combining high precision with high real-time performance. This makes the method highly promising for applications in fields requiring high precision and processing speed, such as surgical navigation, visual tracking, and industrial online measurement. Attached Figure Description
[0036] Figure 1 This is a flowchart of a method for locating the centroid of a reflective sphere spot based on adaptive expansion and background compensation according to the present invention;
[0037] Figure 2 This is a flowchart of step S4 of a method for locating the centroid of a reflective sphere spot based on adaptive expansion and background compensation according to the present invention.
[0038] Figure 3 This is the initial ROI for step S3 of the method for locating the centroid of a reflective sphere spot based on adaptive expansion and background compensation according to the present invention;
[0039] Figure 4 This is the target ROI in step S4 of the method for locating the centroid of a reflective sphere spot based on adaptive expansion and background compensation according to the present invention;
[0040] Figure 5 The coordinates of the center of the reflective sphere are calculated using a method for locating the centroid of the reflective sphere based on adaptive expansion and background compensation, according to the present invention. Detailed Implementation
[0041] The present invention will be described in further detail with reference to the accompanying drawings and specific embodiments.
[0042] The method for localizing the centroid of a reflective sphere spot based on adaptive expansion and background compensation includes the following steps:
[0043] S1. Obtain a grayscale image containing the reflected spherical spot;
[0044] S2. The grayscale image is binarized using a fixed threshold segmentation method to obtain a binarized image, thereby separating the initial spot region.
[0045] S3. Extract the contour of the initial spot region in the binarized image and determine its minimum bounding rectangle as the initial ROI;
[0046] S4. Adaptively expand each boundary of the initial ROI to obtain the target ROI;
[0047] The adaptive expansion process includes:
[0048] Calculate the average grayscale gradient of the initial ROI boundary region;
[0049] Determine whether the average gray-level gradient is greater than a preset gradient threshold;
[0050] If it is greater than the specified value, then expand the boundary outward by one pixel and update the boundary position.
[0051] Repeat the above calculations and judgments until the average gray-scale gradient is not greater than the preset gradient threshold, or the preset maximum number of expansions is reached;
[0052] S5. Based on the target ROI, the center coordinates of the reflected spherical spot are calculated using the background compensation centroid method.
[0053] In step S2, the fixed threshold segmentation method uses a preset global grayscale threshold to mark the region in the grayscale image with a pixel value greater than the threshold as the target region, and the region with a pixel value less than or equal to the threshold as the background region.
[0054] In step S4, the average gray-level gradient is calculated as follows: for the current boundary, its average gray-level gradient is... Calculated using the following formula:
[0055]
[0056] in, and Let represent the grayscale values of the outermost pixel inside the initial ROI and the nearest neighbor pixel outside, respectively, where N is the total number of pixels at the boundary. The boundary expansion condition is: if , If the preset gradient threshold is not met, expansion will be performed; otherwise, expansion will stop.
[0057] To suppress excessive boundary expansion caused by random noise, a maximum number of expansions is set. .
[0058] In step S5, the background compensation centroid method includes the following steps:
[0059] S501, Calculate the average grayscale value of the outermost pixels of the target ROI as the background estimate;
[0060] S502, obtain the compensated grayscale distribution for each of the background grayscale estimates within the target ROI;
[0061] S503, based on the compensated gray-level distribution, the gray-level centroid method is used to calculate the center coordinates of the light spot.
[0062] As a preferred technical solution of the present invention: in step 503, the pixel coordinates of the light spot center... The calculation formula is:
[0063]
[0064] In the formula, This is the estimated grayscale value for the background. This represents the grayscale value within the ROI.
[0065] This invention utilizes an adaptive ROI boundary dynamic extension method based on average gray-level gradient criteria to intelligently extend the initial binary contour, enabling the target ROI to more completely encompass the true gray-level gradient edge of the spot, laying the foundation for subsequent high-precision calculations. While capturing the spot signal more completely, it introduces a small number of background pixels. Combined with an improved gray-level centroid method with background estimation and compensation functions, this invention systematically solves the positioning accuracy bottleneck problem caused by inaccurate fixed threshold segmentation and background gray-level interference in existing spot centroid localization techniques. This invention uses an adaptive extension mechanism to dynamically extend the boundary according to local gray-level changes, enabling the target ROI to more completely contain the gray-level gradient edge of the spot, avoiding spot area segmentation caused by improper threshold setting, and solving the problem of incomplete spot edge capture by fixed threshold segmentation. Through background estimation and compensation, it effectively suppresses the systematic deviation introduced by background pixels within the ROI, significantly improving the anti-background interference capability of centroid coordinate calculation, and solving the problem of background gray-level interference in traditional gray-level centroid methods.
[0066] This invention utilizes an adaptive expansion method to further process the binary image obtained by the fixed threshold method, thereby obtaining a target ROI containing a complete spot image. Inevitably, a small amount of background is introduced. The gray-scale centroid method is further improved, and background estimation is performed based on the target ROI. A background compensation centroid method is proposed to eliminate the influence of background gray-scale values and improve positioning accuracy.
[0067] Example 1
[0068] The present invention provides a method for locating the centroid of a reflective sphere spot based on adaptive expansion and background compensation, comprising the following steps:
[0069] S1. Obtain the grayscale image.
[0070] S2. Binarize the grayscale image. The binarization process involves selecting a fixed grayscale value as a threshold, and using pixels with grayscale values greater than the threshold as target regions (grayscale value set to 255, white), and vice versa as background regions (grayscale value set to 0, black). This results in a binarized image with a clear boundary between the target region and the background. Then, contour lookup is performed on the binarized image to obtain the white target region.
[0071] S3. Calculate the minimum bounding rectangle of the target region and use the obtained minimum bounding rectangle as the initial ROI (Region of Interest).
[0072] S4. Adaptively expand the boundary of the initial ROI to obtain the target ROI. The overall boundary expansion process is as follows:
[0073] Suppose the average gray-level gradient of a certain boundary region of the initial ROI. Calculated using the following formula:
[0074]
[0075] in, and Let represent the grayscale values of the outermost pixel inside the initial ROI and the nearest neighbor pixel outside, respectively, where N is the total number of pixels at this boundary. The decision condition for boundary expansion is: if ( If a preset gradient threshold is set, the boundary is determined to be ready for further expansion; otherwise, expansion stops. To suppress excessive boundary expansion caused by random noise, a maximum number of expansions is set. The entire algorithm flow is shown in the figure.
[0076] S5. Using the expanded ROI as the target ROI, the center coordinates of the spot are obtained by applying the background compensation centroid method to the target ROI.
[0077] The background compensation centroid method first calculates the average grayscale value of the outermost pixels of the target ROI as a background estimate. Then, it subtracts this background estimate from the grayscale values of all pixels in the entire target ROI before performing the grayscale centroid method to obtain the coordinates of the spot center. The formula for the background compensation centroid method is:
[0078]
[0079] In the formula, The pixel coordinates of the center of the light spot. This is the estimated grayscale value for the background. This represents the grayscale value within the ROI.
[0080] The initial ROI obtained by fixed threshold segmentation is as follows: Figure 3 As shown, the entire light spot was not covered. However, the adaptive boundary expansion mentioned in step 4 can obtain the target ROI that includes the entire light spot, as shown in the image. Figure 4 As shown.
[0081] The center coordinates of the light spot obtained by using the background compensation centroid method on the target ROI can achieve a positioning accuracy of 0.08mm, which is a significant improvement over the grayscale centroid method. For example... Figure 5 As shown.
[0082] This invention presents a method for locating the centroid of a reflective sphere spot based on adaptive expansion and background compensation. Under various lighting conditions and imaging qualities, this method can more stably approximate the true geometric center of the spot, improving the accuracy of centroid localization. Adaptive expansion reduces dependence on fixed thresholds, and the background compensation mechanism reduces sensitivity to overall image contrast, enhancing the method's robustness. In practical engineering scenarios with blurred spot edges and uneven background grayscale, this invention offers superior repeatability and absolute accuracy compared to traditional methods, providing a more reliable data foundation for subsequent 3D visual measurements.
[0083] The above specific embodiments are used to explain and illustrate the present invention, and are only preferred embodiments of the present invention, not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made to the present invention within the spirit and scope of the claims shall fall within the protection scope of the present invention.
Claims
1. A method for centroid localization of a reflective sphere spot based on adaptive expansion and background compensation, comprising the following steps: S1. Obtain a grayscale image containing the reflected spherical spot; S2. The grayscale image is binarized using a fixed threshold segmentation method to obtain a binarized image, thereby separating the initial spot region. S3. Extract the contour of the initial spot region in the binarized image and determine its minimum bounding rectangle as the initial ROI; S4. Adaptively expand each boundary of the initial ROI to obtain the target ROI; The adaptive expansion process includes: Calculate the average grayscale gradient of the initial ROI boundary region; Determine whether the average gray-level gradient is greater than a preset gradient threshold; If it is greater than the specified value, then expand the boundary outward by one pixel and update the boundary position. Repeat the above calculations and judgments until the average gray-scale gradient is not greater than the preset gradient threshold, or the preset maximum number of expansions is reached; S5. Based on the target ROI, the center coordinates of the reflected spherical spot are calculated using the background compensation centroid method.
2. The method for centroid localization of a reflective spherical spot based on adaptive expansion and background compensation as described in claim 1, characterized in that: In step S2, the fixed threshold segmentation method uses a preset global grayscale threshold to mark the region in the grayscale image with a pixel value greater than the threshold as the target region, and the region with a pixel value less than or equal to the threshold as the background region.
3. The method for centroid localization of a reflective spherical spot based on adaptive expansion and background compensation as described in claim 1, characterized in that: In step S4, the average gray-level gradient is calculated as follows: for the current boundary, its average gray-level gradient is... Calculated using the following formula:
4. Among them, and Let represent the grayscale values of the outermost pixel inside the initial ROI and the nearest neighbor pixel outside, respectively, where N is the total number of pixels at the boundary. The boundary expansion condition is: if , If the preset gradient threshold is not met, expansion will be performed; otherwise, expansion will stop.
5. The method for centroid localization of a reflective spherical spot based on adaptive expansion and background compensation as described in claim 3, characterized in that: To suppress excessive boundary expansion caused by random noise, a maximum number of expansions is set. .
6. The method for centroid localization of a reflective spherical spot based on adaptive expansion and background compensation as described in claim 1, characterized in that: In step S5, the background compensation centroid method includes the following steps: S501, Calculate the average grayscale value of the outermost pixels of the target ROI as the background estimate; S502, obtain the compensated grayscale distribution for each of the background grayscale estimates within the target ROI; S503, based on the compensated gray-level distribution, the gray-level centroid method is used to calculate the center coordinates of the light spot.
7. The method for centroid localization of a reflective spherical spot based on adaptive expansion and background compensation as described in claim 5, characterized in that: In step 503, the pixel coordinates of the center of the light spot The calculation formula is:
8. In the formula, This is the estimated grayscale value for the background. This represents the grayscale value within the ROI.