Auto Focus System based on RTS2 and EPICS Jiajing Liu, Guangyu Zhang, Jian Wang Modern Physics Department, University of Science and Technology of China, State Key Laboratory of Technologies of Particle Detection and Electronics
Contents Structure of BSST Toolkits and Librarys we uesd to implement Auto focus System RTS2-EPICS and Design of Telescope IOC Structure of Auto Focus System based on RTS2 Algorithms we used to deal with fits images while focusing The process of auto focus system Tasks to do in the future
Structure of BSST
Toolkits and Librarys we uesd to implement Auto focus System EPICS - Experimental Physics and Industrial Control System –EPICS is a set of Open Source software tools, libraries and applications used worldwide to create distributed soft real-time control systems for scientific instruments.
Toolkits and Librarys we uesd to implement Auto focus System EPICS - Experimental Physics and Industrial Control System –EPICS is a set of Open Source software tools, libraries and applications used worldwide to create distributed soft real-time control systems for scientific instruments. OpenCV –OpenCV is a library used in image processing, video capturing and etc. GNU Scientific Library (GSL) –The GNU Scientific Library (GSL) is a numerical library for C and C++ programmers.
Structure of RTS2-EPICS
Design of Telescope IOC
Run-time Database Design
Design of Telescope IOC Device Support Design
Struct of auto focus system BSSTFocus is a sub class of Focusd with auto focus function in it BSSTFocus receives “focus” command from other RTS2 module like Executor BSSTFocus can control Telescope IOC and CCD IOC to complete auto focus task The Connection class can either send epics cmd or rts2 cmd depend on the type of the modules.
Struct of auto focus system Inside BSSTFocus, we implement CCD DevClient and Telescope DevClient CCD DevClient and Telescope DevClient use CCD Connection and Telescope Connection to communicate with the CCD and Telescope IOC
Algorithms The focus algorithm is the very important part of auto focus system. We plan to implement 3 different algorithms to calculate the best focus position. Each algorithm has its advantage. We use OpenCV to Process the fits image. 1 calcute the area of the stars in the image. 2 calcute the HDF (Half Flux Diameter) of the stars in the image. 3 calcute the FWHM (Full Width Half Maximum) of the stars in the image. The image shot near the best focus position has the smallest area, HDF and FWHM.
Algorithms Step 1: Scale –Most of the pixels in the image has a low value as its shown in the histogram figure below. –Most stars are hidden in the background, even though there are some bright ones. So we need to scale the image first.
Algorithms Use IRAF’s Z-Scale algorithm to process the image. Z-Scale is an iterative algorithm to find 2 value (Z1 and Z2). The pixel values which are greater than Z2 are bright values. The pixel values which are lower than Z1 are dark values. For the values between Z1 and Z2 we need to scale them to deferent grey value levels The values between Z1 and Z2
Algorithms Step 2: smoothing After Z-Scale we need to smooth because of noise in the image. Different smoothing method has different result. Gaussian smoothing method can wipe off the noise in image, but make the edge of the stars blurry. Before Gaussion smooth After Gaussion smooth
Algorithms Median smoothing method can make the image get rid of the noise. The edge of stars is clear than Gaussian method. After Gaussion smoothAfter Median smooth
Algorithms The effect of Median smoothing method depend on the size of filter windows. We need to find a appropriate size of the filter windows. After compare the 4 image, we select the 5 pixels size filter windows. 9 pixels size 5 pixels size 3 pixels size 13 pixels size Before smooth
The process of auto focus system. We need to move camera to several positions and take images at each position Calculate the best focus position based on these images. Move camera to the best focus position. Find best focus position based on curve fitting
The process of auto focus system. We calculate the best focus position based on curve fitting method using GNU Scientific Library. We make this curve using samples which is also used in rts2saf modules. The results between rts2saf and area calculate method are similar. How to calculate the best focus position area calculate’s result rts2saf’s result
The process of auto focus system. Some times the focus curve may not a regular curve. So the curve fitting method may be not the best approach to find the position. So we need another method to find the position. Iterative approach used to find best focus position
The process of auto focus system. We can also use the curve fitting and iterative method together to find the best focus position. First use the curve fitting method to find a range then we use iterative method in this range to find the best focus position exactly. Use the curve fitting and iterative method together The range we used
The task to do in the future Implement the HDF and FWHM method compare these method to find which is better To do more test to make the software more stable.
Thanks