Today, optical systems of subpixel measurements of geometric dimensions of objects, as well as 3D triangulation measurement systems, have gained wide application. This capability is achieved under the condition of obtaining sharp images of the investigated object. However, challenges arise when the object's image or a specific part of it becomes blurred or defocused, as some of its features lie outside the focal plane. The use of defocused images leads to significant measurement errors during their computer processing. The paper introduces a method based on the use of two defocused images of the research object. Through advanced computer processing, this approach enables obtaining a sharp image, extracting its contour, and acquiring its geometric parameters with subpixel precision.