## 2 Methodology  
### Architecture and Workflow  
In order to improve the accuracy of surface defect detection for CT, this paper proposes an algorithm that integrates comparison, detection, and discrimination, as shown in Figure 1. The detector dictates the defect detection performance of the CNFA. Improving the detector's sensitivity to defects will bring a high false detection rate, which is unbearable in practical applications. Therefore, the accuracy of our proposed algorithm is determined by the comparator and the discriminator together. The comparator is used to extract the characteristics and compare the image to be detected with the negative sample set, and ultimately the corresponding reference image is obtained. The detector realizes the defect target detection on the detected image to acquire rectangle boxes; the discriminator simultaneously accomplishes feature extraction and similarity measurements of the derived rectangular boxes from the reference image and the one to be detected, finally evaluating whether the rectangle boxes of the image to be detected are actual defects. The entire approach process consists of the following steps:  
Step 1: Collecting non-defective tile images of different textures with the same texture template to construct a negative sample set and obtaining the feature vectors of each image in real-time based on the comparator, which is defined as \(V_{re}^{j}(\alpha_{i})\), assume that \(\alpha_{i}\) is the feature dimension of the reference image, \(j\) represents the number of reference images.  
Step 2: The comparator is the first used to extract the feature vectors of the detection image, named \(V_{\text{det}}(\beta_{i})\), where \(\beta_{i}\) indicates the dimension of feature vectors is \(i\). Then, measure its distance from each feature vector in the negative sample set; the feature vector with the smallest distance corresponds to the image as the reference image.  
Step 3: The category and rectangle boxes of the image to be detected(det_boxes) are obtained by the defect detector, and the rectangle boxes image are cropped. Based on the det_boxes coordinates, the length and width of the rectangle boxes are enlarged several times on the reference image, and the enlarged rectangle boxes image is obtained by cropping, the reference rectangle boxes(ref_boxes) is retrieved from the enlarged rectangle boxes image, which is the most recognizable to det_boxes.  
Figure 1: Block diagram of our algorithm. The gray line specifies that an image to be detected is directly inferred, and det_boxes surrounded by the light orange background box are obtained simultaneously by the detector. The blue line indicates the comparator extracts feature vectors of non-defective and defective images, then the most similar non-defective image retrieved is the reference image, ref_boxes surrounded by a light green background box are acquired based on the reference image and det_boxes.  
Step 4: The det_boxes and the corresponding ref_boxes are pushed into the discriminator; feature extraction and distance measurement capabilities are pretty beneficial to distinguish the degree of mutual acquaintance.  
Step 5: The judgment of the true/false defect of the det_boxes is accomplished according to the prior threshold.  
Retrieving the correct reference image is a prerequisite for improving the detection accuracy of the entire algorithm. In addition, another essential procedure is to extract the characteristics of different scales and shapes of the det_boxes and the corresponding ref_boxes and measure the gap to strengthen the ability to distinguish true/false defects.