# Defect R-CNN: A Novel High-Precision Method for CT Image Defect Detection
## 2 Methods
### Improvement on Mask R-CNN
#### 2.3.1 Edge-Prior Convolutional Block  
Given the edge-texture characteristics of CT images, the network prioritizes extracting these critical details. To achieve this, Defect R-CNN introduces the EPCB, structured as follows. As shown in Figure 3, the EPCB consists of four branches, each combining a convolutional kernel with a batch normalization (BN) layer. These include a standard 3 \(\times\) 3 kernel, a horizontal Sobel-Dx kernel, a vertical Sobel-Dy kernel, and a Laplacian kernel. The Sobel operators compute local gradient changes in the horizontal and vertical directions, effectively detecting edges, while the Laplacian operator highlights regions with significant gray value variations, enhancing edge information. The integration of the standard convolutional kernel with these specialized operators improves edge detection performance. The BN layer adjusts the weights of each branch during training, accelerating convergence and mitigating issues such as vanishing or exploding gradients. The input image passes through all four branches, each performing distinct convolutions, and the resulting feature maps are normalized and summed to produce the final output. To improve training speed, a skip connection is introduced in the EPCB convolutional component in EP-Net with a step size of 1, along with a branch containing only the BN layer. This design preserves the original input information, ensuring that shallow features are passed to deeper layers, which enhances gradient backprop  
Figure 3: Structure of EPCB. Figure 2: Defect R-CNN framework. model expressiveness and training performance. Since the convolution operations and skip connection are linear, once the model is trained and converged, the parameters of these branches become fixed. The linear nature of the kernels allows the parameters to be merged into a single 3 \(\times\) 3 convolution kernel, maintaining the same feature extraction capabilities as the original multi-branch structure while improving computational efficiency. In contrast, ResNet50's BottleNeck, shown in Figure 4, includes a ReLU activation layer in the left branch, introducing nonlinearity. Consequently, the two branches cannot be merged parametrically during inference. The output of the multi-branch structure in the EPCB module can be mathematically expressed as  
\[M_{out}\ =\sum_{i=1}^{4}BN(M_{in}\ *W^{(i)},\mu^{(i)},\sigma^{(i)},\gamma^{(i)}, \beta^{(i)}) \tag{7}\]  
where \(M_{in}\) and \(M_{out}\) denote the input and output feature maps of the EPCB module, and \(W^{(i)}\) represents the convolution kernel of the \(i\)-th branch. The operation \"\(*\)\" denotes convolution, and the parameters \(\mu^{(i)},\sigma^{(i)},\gamma^{(i)},\beta^{(i)}\) are the BN statistics and affine parameters for the \(i\)-th branch: mean, standard deviation, scaling factor, and shift factor, respectively. The values \(\gamma^{(i)}\) and \(\beta^{(i)}\) are learnable parameters and are updated during training, enabling dynamic scaling and shifting of feature maps. When fusing the multi-branch outputs, the convolution operation and the BN transformation in each branch can be merged, since both are linear operations. The BN transformation can be written as  
\[BN(M,\mu,\sigma,\gamma,\beta)=(M-\mu\ )\frac{\gamma}{\sigma}+\beta \tag{8}\]  
This allows each branch to be equivalently represented by a single convolution operation with recalibrated weights and bias terms, which can be pre-computed before inference. The equivalent convolution kernel and bias can be defined as  
\[W^{\prime}=\frac{\gamma}{\sigma}M \tag{9}\]  
\[b^{\prime}=\beta-\frac{\gamma}{\sigma}\mu \tag{10}\]  
Finally, these equivalent parameters from each branch are summed to produce the final fused output. In this way, the EPCB retains its multi-branch structure during training to enhance edge-aware feature extraction. However, at inference time, it can be converted into a single-branch form, preserving the performance gains while improving inference speed  
Figure 4: BottleNeck block in ResNet [33]. and reducing memory consumption.