In the modern manufacturing industries, the 3D reconstruction of scenes emerges as a critical element with far-reaching implications. This study presents the development of a 3D reconstruction system based on active illuminated Shape from focus to capture images with added surface texture. An algorithm is introduced to select the most suitable image frame from a series of images with different texture patterns based on their focus metrics, thereby enhancing the accuracy of depth interpretation. A comparative analysis is conducted between the proposed method for depth map reconstruction and the conventional shape-from-focus approach. The results demonstrate significant improvements in accuracy and performance. Root mean square errors for three different shape samples are reported as 2.50, 1.72, and 1.23, accompanied by correlation values of 0.56, 0.25, and 0.39. Furthermore, median filtering with a dynamic window size is employed to refine the initial depth map further, resulting in enhanced performance. The resulting root mean square errors are measured as 1.71, 1.12, and 1.13, corresponding correlation values of 0.82, 0.38, and 0.42. The results obtained in this study provide strong evidence supporting the effectiveness of the proposed method combined with median filtering using a dynamic window size in significantly improving accuracy and performance for depth map reconstruction.