*3.3. Autofocus Results*

The image sources are the NVG images introduced in the description of the tested images section. According to the process introduced in the autofocus using sparse matrix section, an experiment was performed and Equation (9) was carried out for computing. The statistical result was as shown in in Figure 19a. The lowest point was the frame with the best sharpness. In the example, the 96th frame was the sharpest frame. The image in this frame is Figure 19c. In order to compare the accuracy of the sharpness in this study, Figure 19b was the same source image. The normalized gray-level variance sharpness method proved that the autofocusing application of NVG was effective. According to the calculation result using the normalized gray-level variance sharpness method, the 96th frame was also the one with the best sharpness. Figure 19d is the image in the vicinity of the sharpest point. Compared to Figure 19c, the 90th frame showed obvious differences, proving the robustness of the method in this study and the normalized gray-level variance sharpness method. The method in this study featured the advantages of simple and easy-to-understand computing. In Equation (9), only the sum of the sparse matrices corresponding to the respective images needed to be computed, and the least value was sought as the best sharpness point. This part also validated the concept that "the corresponding frame information in the sparse matrix serves as a reference for sharpness" proposed in the autofocus using sparse matrix section.

(**c**) Image at the sharpest point (96 degree) (**d**) Image nearby the sharpest point (90 degree)

**Figure 19.** Result comparison of this study and normalized gray-level variance sharpness method under correct focal distances.

#### **4. Conclusions**

The decomposition process of the deep semi-NMF model was employed in this study to obtain the sparse and low-rank matrix information, based on which information the autofocusing requirements were completed. Additionally, the simple calculation can be completed using the sparse matrix. Experimental results also proved that under NVG images, the autofocusing method and the traditional normalized gray-level variance sharpness method derived the same calculation results, both deriving the sharpest image frame. Furthermore, in solving the multifocus problem arising from mechanism errors, taking into account the 12 image fusion indicators and the square effect and halo, overall experimental results proved that the method in this study was superior to the other three methods in terms of image testing. On top of it, 18 best ratings were obtained under the image fusion indicator rations. Finally, the autofocusing and image fusion algorithm put forth in this study possessed substantive value in terms of enhancing automated testing equipment process.

**Author Contributions:** Conceptualization, B.-L.J. and H.-T.Y.; methodology, B.-L.J.; software, W.-L.C.; validation, Y.-C.L.; formal analysis, B.-L.J.; investigation, B.-L.J.; resources, H.-T.Y.; data curation, W.-L.C.; writing—original draft preparation, B.-L.J. and H.-T.Y.; writing—review and editing, W.-L.C.; visualization, Y.-C.L.; supervision, H.-T.Y.; project administration, B.-L.J.; funding acquisition, B.-L.J. and H.-T.Y. All authors have read and agreed to the published version of the manuscript.

**Funding:** This research was funded by Ministry of Science and Technology of the Republic of China, Taiwan, grant numbers 107-2218-E-167-004 and 108-2218-E-167-005.

**Acknowledgments:** This work was supported in part by the Ministry of Science and Technology of the Republic of China, Taiwan, under Contract MOST 107-2218-E-167-004 and 108-2218-E-167-005.

**Conflicts of Interest:** The authors declare no conflict of interest.
