For automated optical inspection, autofocusing microscopes play an important role in capturing clear images of the measured object. At present, the image processing part of optics-based autofocusing microscopes often has various factors, which makes it impossible to describe the image information of the semicircular (or elliptical) spot with a simple circle-finding method. Accordingly, this study has developed a novel algorithm that can quickly calculate the ideal center of the elliptical spot and effectively compensate the linearity of the focusing characteristic curve. A prototype model was used to characterize and verify the proposed algorithm. The experimental results show that by using the proposed algorithm, the autofocusing accuracy can be effectively improved to less than 1.5 μm.