Improved Centroid Algorithm for Beam Stability Control System

In order to eliminate the beam jitter caused by the air disturbance and the vibrating devices, the error of light spotted jitter must be detected firstly. The beam jitter error can be corrected by a compensator to realize the beam stability control system. In this paper, an Improved Centroid Algorithm (ICA) combining with the Gaussian Fitting Algorithm (GFA), the Bilinear Interpolation and the Weighted Center of Mass (WCOM) was proposed. A Gaussian template is used to roughly locate the spot image in order to improve the efficiency and stability of the algorithm. The light spot image is interpolated by the Bilinear Interpolation to improve the accuracy of centroid identification. The identification accuracy and efficiency of the algorithm were verified by 100 sets of light spot experiments. The experimental results showed that the identification accuracy and efficiency of the Improved Centroid Algorithm were higher than those of the other algorithms. Our algorithm was of great significance for improving the performance of the beam stability control system.


I. INTRODUCTION
An adaptive optical system is a real time correction system for the wavefront distortion. The beam jitter is the main factor of the wavefront distortion, which has become an urgent problem in the adaptive optical system [1]- [5]. The beam jitter control is important for the beam stability system.
Beam jitter is an external interference, which causes a deflection of the optical axis and resulting in a deviation in the beam propagation direction. In an adaptive optical system, the beam jitter is mainly caused by the atmospheric turbulence, the vibrating devices (such as motors, fans, water coolers, etc.) or the vibration of the optical platform itself [6]- [11]. Therefore, it is necessary to design a beam stability control system to eliminate the beam jitter .
Real-time detection of the centroid is a vital step in the beam stability control system. There are two difficulties with centroid detection. One is to accurately detect the spot and distinguish it from the noise pixel, and the other is to extract the subpixel centroid with a high precision [12]- [15]. At present, the main centroid identification algorithm includes Center of Mass (CoM), the Weighted Center of Mass (WCoM) and Gaussian Fitting Algorithm (GFA), etc. [16]- [23]. Among them, the CoM is suitable for light spot with the small noise and the regular shape. The precision of GFA is high, but the efficiency is low [24]- [25].
In this paper, an Improved Centroid Algorithm (ICA) with high accuracy and efficiency is proposed to identify the centroid of light spot. Firstly, the light spot images were filtered by a suitable Gaussian template to determine the rough location of the light spot in the image. After Gaussian filtering, the resolution of the light spot image was increased to the subpixel level by the Bilinear Interpolation. And then, the WCoM was used for spot identification to achieve the accurate location. Finally, the accuracy and efficiency of the ICA were verified by the experiments.

A. CENTER OF MASS
In the CoM, the gray value of the target pixel in the light spot area is taken as the weight of its coordinates, and the mean values of the calculated coordinates are the centroid coordinates of the light spot [17], [22], [23], [25]. The centroid is calculated referring to (1).
where 00 ( , ) xy is the centroid pixel coordinate, ( , ) ii f x y is the gray value at the grayscale image ( , ) ii xy . The algorithm is easy to implement and the identification accuracy is high, but it is sensitive to the pixels outside the peak of the gray graph.

B. WEIGHTED CENTER OF MASS
In order to overcome the limitation of the common centroid algorithm in calculating some special images, the quadratic power of the gray values are used in the WCoM to replace the original gray values for weighting [12], [17], [22].
However, the WCoM is sensitive to pulse noise, especially when the image quality is poor, its extraction accuracy will decrease sharply.

III. IMPROVED CENTROID ALGORITHM
The ICA is proposed by combining with the GFA, the Bilinear Interpolation and the WCoM. The Gaussian surface approximates to the actual spot with the high stability GFA. The fitted Gaussian surface is discretized and normalized to a (2k+1) × (2k+1) light spot template. The image is filtered by the template to reduce the influence of noise on the accuracy of centroid location and simplify the calculation in the centroid identification. At the same time, the spot rough positioning is completed by locating the target spot region in the image. The filtered spot image, is subdivided into the sub-pixel levels by the Bilinear Interpolation to improve the accuracy of the centroid identification. Finally, the WCoM recognizes the interpolated spot image. The algorithm flow is shown in Fig. (1).

A. GENERATING A GAUSSIAN TEMPLATE
The stars image was generated by the off-axis reflection collimator, and the spot images with a large number of starspots were obtained. Then the light spot is fitted by Gaussian surface to acquire the accurate template. The two-dimensional Gaussian equation is shown in (3): where A is amplitude, Using the least square method to minimize the sum of squares of the residuals, we get: VOLUME XX, 2022 Taking the partial derivative of each variable and setting to zero, the equations are obtained as shown in (8) Then we get the linear equations: Referring to (14), the fitted Gaussian formula can be obtained. The Gaussian discrete template with 00 ( , ) xy as the template center expanded to (2 1) (2 1) kk    size. According to the simulation results, the optimal template with 7 k  is acquired. And the discrete template is normalized to obtain the 15×15 filtering template, as shown in Fig. 2.

FIGURE 2. Gaussian template
The original image with locating the light spot centroid pixels is smoothed by the Gaussian filter. Then expanding outward the light spot centroid pixels generate a window with a size of 15pixels ×15pixelsfor the next steps of the precise positioning. The light spot image after Gaussian filtering is shown in Fig. 3.

B. BILINEAR INTERPOLATION
In order to further improve the centroid identification accuracy, the Bilinear Interpolation is used to interpolate the light spot images (obtained from the rough positioning) to subdivide the pixel into the sub-pixel level [27]. The Bilinear Interpolation algorithm(the first-order interpolation algorithm) can get the final result via three times of the interpolations, which is an improvement to the neighboring interpolation algorithm. In the Bilinear Interpolation algorithm, a first-order Linear Interpolation is performed in the x and y direction. The principle of interpolation is shown in Fig. 4.

FIGURE. 5. The light spot image after interpolation
Finally, the WCoM recognizes the centroid of the interpolated spot image.

IV. SIMULATION EXPERIMENT
In order to verify the accuracy and efficiency of the proposed ICA algorithm, we simulated 100 Gaussian light spot images and applied to the whole process of light spot centroid identification algorithm. The resolution of the light spot image is 256 pixels × 256 pixels. The gray value of the simulated spot is 0~255. The different degrees of Gaussian noise are added. The GFA, CoM, WCoM, and ICA are used to identify spot centroid, and the accuracy and efficiency of different algorithms are analyzed and compared. The general Gaussian filter is performed on the image before the GFA, COM, and WCOM identification. The comparison results are shown in from Fig. 6 to Fig. 8, and the datum are shown in Table Ⅰ and  Table Ⅱ.  From the simulation results, the accuracies of centroid identification for the CoM, WCoM and ICA are high with low noise. Among them, the accuracy of ICA is highest and the centroid identification error of GFA is largest. When the noise is large, the accuracies of the GFA, COM, and WCOM decrease significantly, and the accuracy of ICA is still high and stable. Table Ⅱ shows the calculation time of all centroid algorithms used for a given test image. The calculation speed of the improved ICA is faster than other algorithms.

V. OPTICAL EXPERIMENT
As shown in Fig. 9, the experimental system consists of a lifting platform, a Leica MS60 Electronic Total Station, a plane mirror, sub-arcsec optical axis parallel detection system and an air floating optical platform.

FIGURE. 9 The experimental system
The optical path in the detection system is shown in Fig. 10.

FIGURE. 10. Optical path diagram
All equipments are built on the air floating optical platform, and the plane mirror is fixed in the Leica MS60 Electronic Total Station, as shown in Fig. 11. The Leica MS60 Electronic Total Station is fixed on the lifting platform and aligned with the optical axis of sub-arcsec optical axis parallel detection system.

FIGURE. 11. Flat mirror is fixed on the Leica MS60 Electronic Total Station
In the sub-arcsec optical axis parallel detection system, the light source irradiates on a single star point plate, and the star point target is collimated by an off-axis parabolic reflector, and is reflected by the plane mirror on the electronic total station. The reflective light is incident to the CCD center after passing through the secondary mirror. 100 star point images are collected by the computer, the resolution of the light spot image is 2448 × 2048 pixels. The centroid is identified by four algorithms and the accuracy and efficiency of the centroid identification are compared. Due to the large quantities of acquired images, only 2 of them are listed here, as shown in Fig. 12. The recognition accuracy of the four algorithms are shown in Fig. 13. The identification accuracy of the ICA algorithm is much higher than that of GFA, CoM and WCoM. There is a slight jitter in the optical path due to the mechanical vibration in the experiment, resulting an increase in the error of the identification accuracy of the centroid, but this does not affect the comparison of the accuracy of the four algorithms. The computation time of the four algorithms in experimentally acquiring images are listed in table Ⅲ . The ICA algorithm is significantly more efficient than the other three algorithms.
Ordinary Gaussian filtering is the process of weighted averaging over the entire image. The value of each pixel is obtained by a weighted average of its own and neighbor pixels. Gaussian filtering is performed by scanning each pixel in the image with a template (or convolution, mask), and replacing the value of the pixel point at the center of the template with the average value. The computation is large.
The calculation efficiency of ICA is higher than other algorithms, because the roughly centroid coordinates 00 ( , ) xy is obtained by Gaussian algorithm , i.e., using the Gaussian discrete template with 00 ( , ) xy as the template center and expanding images to 15×15 size. Then the interpolation and centroid identification are directly performed on expanded images, instead of calculating on pixels of the entire image to reduce the amount of calculation, and improve calculation efficiency.

VI. CONCLUSION
In summary, we have proposed an improved centroid algorithm to identify the centroid with high pricision and high efficiency. In the proposed ICA algorithm, the GFA is used to filter the spot image, the light spot images are subdivided into sub-pixel levels by the Bilinear Interpolation, and the WCoM is used for the light spot centroid identification. The experiments demonstrate that the accuracy and efficiency of the ICA algorithm for centroid identification is significantly higher than other algorithms.
There is still a problem in this algorithm, the best Gaussian template cannot be obtained by the calculation. In this paper, according to repeatedly simulation tests, 15×15 template has the best effect. How to calculate the best template needs further research.