Autofocus has been widely used in biological imaging to free users from tedious and repetitive works. However, due to background noise and different combination of sample types and staining method, the stability and reproducability of autofocus method is a main challenge. Therefore, we developed a fast and accurate autofocus method based on enhanced mountain climbing search algorithm which can be broadly used in different senarios.

We developed an autofocus method with threshold denoising to enhance the stability, which utilised the combination of Laplacian function and variance operator as the focus evaluation function.
Several modifications have been made to improve the autofocus performance based on the traditional mountain climbing search algorithm that moves the stage back and forth.
Additionally, two-step curve fitting and NIQE final focus evaluation are used to make the mountain climbing search stride adaptive and to make the final focus position prediction more precise. The NIQE assessment code that we used is from https://github.com/guptapraful/niqe, which is based on skvideo's NIQE.
Instead of using two or three initial points to determine the focus direction, we used linear curve fitting to ensure more accurate search direction prediction.
Additionally, when the stage is moving forward, z-stack images are captured by the camera at each position. And each image is processed through the evluation function to get a score. The optimal focus position should have the highest evaluation score, representing the peak in the focus evaluation curve on the right figure.
A image restoration process is specifically designed for imaging thick samples and unevenly distributed organelles. It is hard to get all the structures into sharpest focus simultaneously when the spatial distribution of the structures are across multiple planes. So, even when we reached the optimal focus position, some structions in the image can still look blurry. To solve this problem, we modelled the point spread function (PSF) theoretically, generating 3D PSF for the following deconvolution process. The deconvolution we used here is Richardson–Lucy (RL) deconvolution.
