When performing digital image processing, the most critical technology that affects its use effect is the autofocus technology. With the advancement of science and the development of computer technology, autofocus technology has become more and more widely used in various fields. Autofocus technology is a key technology in robot vision and digital video systems. In order to allow digital image processing technology to better serve humans, it is necessary to further improve the focus evaluation function algorithm. This article focuses on the imaging principle of defocused images, using different evaluation functions to analyze and process the experimental images to observe the changes in image clarity. Through the introduction and analysis of the existing evaluation function, it can be known that the focus evaluation function will directly affect the quality of digital image processing. Therefore, it is best to choose unimodality, unbiasedness, low noise sensitivity, wide coverage, and a small amount of calculation. For the evaluation function, the Laplacian gradient function is an ideal choice. However, because the current digital image processing technology is not perfect enough, the focus function is still prone to multiextreme problems when the image is severely defocused and the high-frequency components in the image are missing; the balance between image processing speed and focus accuracy also still needs to be improved. Therefore, this paper studies the autocontrol microscope focus algorithm based on digital image processing, analyzes the principle of visual image imaging, and makes some improvements to the microscope focus algorithm. Through experiments, it can be seen that the real-time data of the original Laplace function in the edge-obvious target is 76.9, and it reaches 77.6 after improvement. The improved algorithm can better maintain the single-peak state during the focusing process, which improves the image processing efficiency while ensuring the measurement accuracy.