## 7 Conclusions  
This study introduces a novel method for accurately characterizing layer contours in MEX/P parts using digital images captured with a contact image sensor (CIS). The basic premise is that the local grayscale gradient in the transition from the target layer to the surrounding background is influenced by their distance apart and the relative orientation of the contour and the scanning direction. Therefore, the accurate location of contour pointscan rely on evaluating the similarity between grayscale patterns near a tentative contour point and reference grayscale patterns precisely centered on an actual contour point.  
Based on this premise, a method to create a database of gradient reference patterns (GRPs) using digital images of custom-made rotational test artefacts has been developed. These test artefacts ideally represent combinations of contour orientation and layer-to-background distances, but they can be made more complex to account for additional influencing factors, such as the feedstock. Once the layer under inspection has been manufactured and digitized with the CIS, tentative contour point locations are identified in the retrieved image. Regions of interest (ROIs) likely containing the actual contour points are then determined in the vicinity of these tentative points. A similarity analysis is then conducted between the appropriate GRPs for each tentative point, and the local candidate patterns (CPs) are extracted from the ROIs. This allows for determining the most probable contour point location. By replicating this process for all tentative points, the layer edge is finally discretely reconstructed.  
The proposed method was applied in a case study using circular test targets. The results demonstrate that contour points can be properly located independently of the differences between contrast scenarios. The average deviation of point position compared to that achievable with a CMM in a metrology laboratory ranges from 8.02 m to 13.11 m within the experimental limits, which should be suitable for an MEX/P application. Moreover, it also provides a significant improvement in the accuracy of contour point localization compared to generic edge-detection algorithms. Even in the worst-case scenarios, with highly non-uniform layer-to-background contrast, the results are significantly better than those achieved in previous research [29] (54.9 m for an \(H_{2}\) specimen, and 55.97 m for an \(H_{4}\) specimen).  
This approach ensures high precision in determining contour point locations by adaptively processing the local characteristics of the layer-to-background pattern, setting it apart from conventional methods that use a single algorithm to process entire images. Additionally, the proposed method guarantees that each local search yields a single contour point, unlike most edge-detection algorithms that typically generate multiple candidate points. This specificity enhances the accuracy and reliability of contour point identification, making the method more robust against variations in local contrast patterns. Future work will focus on developing a heuristic model for the grayscale pattern distribution near the contour, as well as a machine learning model to infer the contour gradient structure in untested scenarios.  
Conceptualization, A.F., P.F. and D.B.; methodology, A.F. and D.B.; software, A.F. and P.F.; validation, B.J.A., P.Z. and G.V.; writing--original draft preparation, A.F. and D.B.; writing--review and editing, B.J.A., P.Z. and G.V.; visualization, B.J.A. and P.F.; supervision, D.B. and G.V.; project administration, G.V. All authors have read and agreed to the published version of the manuscript.  
This research was funded by the Spanish Ministry of Science, Innovation and Universities and by FEDER (DPI2017-83068-P).  
Not applicable.  
The authors will make the raw data on which the conclusions of this article are based available upon request.  
The authors declare no conflicts of interest.