An even threshold \(T=0.5\)  is usually considered as a reasonable value for good thresholding. However, this may cause mislabeling in the case with an unbalanced ratio between a faulty feature and an intact background. To obtain a better result, it is worth seeking a mechanism for autotuning of the threshold. To this end, we propose the contrast-based autotuned thresholding (CBAT), a contrast-based approach refined from Otsu's thresholding [1]}, to improve the accuracy of binarization. A flowchart for obtaining the binary map is depicted in Fig. REF , wherein Otsu's thresholding is only implemented in the region of interest (ROI) that encompasses a cluster of high-probability defect candidates during the iteration process rather than a large background region.
<FIGURE>