## 3 Surface Defect Detection Network for Automobile Wheel Hub
### Body and Edge Decoupling Module  
The multi-scale feature of an image can be decoupled into two parts: the body and edge features of the low- and high-frequency parts, respectively, [31]. The body feature represents the internal association of objects in the image, and the edge feature represents the boundary difference between objects. Among these features, the multi-scale, body, and edge features meet the addition rule.  
\[F_{multi}=F_{body}+F_{edge} \tag{1}\]  
\(F_{multi}\), \(F_{body}\), and \(F_{edge}\) represent the multi-scale, body, and edge features, respectively.  
The optical flow can learn the positional relationship of each pixel in the same object between two frames, and a mutual relationship also exists between the feature points in the body feature of the defect image. Therefore, the body feature can be learned through the optical flow. The positional relationship can be found between the central and peripheral feature points of the same object, which is the optical flow field. To represent the body feature consistently and accurately, the central feature points are mapped to the positions of the corresponding peripheral feature points.  
To generate optical flow field \(\delta\), as shown in Figure 4, two 3 \(\times\) 3 convolutions with a stride of 2 are used for downsampling. Using two consecutive convolutions can minimize the high-frequency information and enhance the body information representation of low-resolution features.  
After downsampling \(F_{multi}\), the feature map must be upsampled four times to obtain low-resolution feature \(F_{flow}\) because its resolution is 1/4 that of \(F_{multi}\). Similar to the input module of the optical flow network named FlowNet-Simple [32], a 3 \(\times\) 3 convolution is used to extract the optical flow field after concatenating \(F_{multi}\) and \(F_{flow}\). Given that optical flow field \(\delta\) is extracted based on \(F_{multi}\), \(\delta\) already contains a multi-scale feature, and a 3 \(\times\) 3 convolution is sufficient to extract the feature between long-distance pixels.  
After generating \(\delta\), \(F_{multi}\) is warped to obtain \(F_{body}\).  
\[F_{body}(x_{2},y_{2})=F_{body}(x_{1}+u_{x},y_{1}+u_{y})=F_{multi}(x_{1},y_{1}) \tag{2}\]  
As shown in Figure 5, \((x_{1},y_{1})\) represents the coordinate of the feature point in \(F_{multi}\), and \((x_{2},y_{2})\) represents the coordinate of the feature point in \(F_{body}\) warped from \(F_{multi}\), \((u_{x},u_{y})\) represents the positional relationship of the feature points between \(F_{multi}\) and \(F_{body}\). According to the brightness constancy constraint, \(F_{multi}(x_{1},y_{1})\) can be mapped to \(F_{body}(x_{2},y_{2})\).  
Figure 4: Generate optical flow field.  
Given that \((x_{1},y_{1})\) is floating, \(F_{multi}(x_{1},y_{1})\) is calculated by bilinear sampling.  
\[F_{multi}(x_{1},y_{1})=\sum_{p\in N}\omega_{p}F_{multi}(p) \tag{3}\]  
\(N\) represents the set of four feature points near \((x_{1},y_{1})\) in \(F_{multi}\), \(p\) represents one of the points, and \(\omega_{p}\) represents the bilinear kernel weight of \(p\).  
\(F_{multi}\) is a deep feature and lacks boundary information in the low-level feature. If \(F_{multi}\) is subtracted from \(F_{body}\) to obtain \(F_{edge}\) directly, \(F_{edge}\) will also lack in boundary information, which will result in low accuracy in the boundary area.  
After obtaining \(F_{edge}\) by subtraction, the low-level feature (\(F_{fine}\)) extracted by the first convolution in HRNet is introduced into \(F_{edge}\), which can introduce the missing boundary information to improve the accuracy in the boundary area. The process of extracting \(F_{edge}\) can be formulated as Equation (4), and the network is shown in Figure 6.  
\[F_{edge}=\gamma\Big{(}concat(F_{multi}-F_{body}),\gamma(F_{fine})\Big{)} \tag{4}\]  
\(\gamma\) represents convolution, and _concat_ represents concatenation.