# Automated 3D Image Processing System for Inspection of Residential Wall Spalls
## 2 Materials and Methods
### Randla-Spall
#### 2.3.2. Dynamic Enhanced Dual-Branch Structure  
Currently, the collected data contains a small percentage of spall and a large percentage of background; therefore, additional defective feature inputs are required for the segmentation of spall damage to enhance the network's generalization. To address this issue, a dynamic enhanced dual-branch structure based on the input data has been constructed. Specifically, the dynamic enhancement module has been constructed, which integrates data enhancement and attention mechanisms to improve the model's generalization ability and performance by enhancing the diversity of input data and introducing feature-level attention mechanisms. This allows the model to adapt to more diverse scenarios and different defect features, helping to enhance its robustness and reduce the risk of overfitting. First, the input data are processed by three different data enhancement strategies, including random mirroring, random rotation, and adding random dithering, as shown in Figure 9.  
Figure 8: RandLA-Spall network architecture. Figure 9: Example of data enhancement. The random mirroring can be expressed as Equation (4):  
\[data^{\prime}_{xyz}= \begin{bmatrix}-x\\ y\\ z\end{bmatrix} \text{or }data^{\prime}_{xyz}= \begin{bmatrix}x\\ -y\\ z\end{bmatrix}  \tag{4}\]  
The random rotation can be expressed as Equations (5)-(7):  
\[\theta=2\pi\times random \tag{5}\]  
\[R= \begin{bmatrix}\cos\theta&0&-\sin\theta\\ 0&1&0\\ \sin\theta&0&\cos\theta\end{bmatrix}  \tag{6}\]  
\[data^{\prime}_{xyz}=data_{xyz}\cdot R \tag{7}\]  
Adding the random jitter component can be expressed as Equation (8):  
\[data^{\prime}_{xyz}=data_{xyz}+\epsilon= \begin{bmatrix}x+\epsilon_{x}\\ y+\epsilon_{y}\\ z+\epsilon_{z}\end{bmatrix}  \tag{8}\]  
where \(\epsilon_{x},\epsilon_{y},\epsilon_{z}\) are drawn independently from a Gaussian distribution with mean 0 and standard deviation \(\sigma\). \(\epsilon\) satisfies the probability density function (9) as follows:  
\[f(\epsilon)=\frac{1}{\sqrt{2\pi\sigma}}exp\bigg{(}-\frac{\epsilon^{2}}{2 \sigma^{2}}\bigg{)} \tag{9}\]  
These strategies enhance the diversity of the input data and facilitate the model's ability to learn a more robust feature representation. Additionally, splicing the enhanced point cloud data (x, y, z) with feature information (r, g, b) along the channel dimensions ensures consistency in terms of both dimension and shape. On this basis, an attention mechanism module utilizing a dense connectivity layer is introduced. A feature-level attention mechanism is employed during the data enhancement phase to assign weights to features across different channels, thereby enabling the model to focus more effectively on important features. Specifically, attentional activation values are generated by a fully connected layer, and a softmax function is applied to these values, resulting in an attention score \(\alpha_{i,j}\) that reflects the importance of each point within the overall data. Finally, the original data is multiplied element-wise by the attention scores to obtain the weighted data representation \(Y_{i,j,k}\), thereby allowing the model to focus more on important features during the training process. This step implements feature-level attention allocation, allowing the model to automatically focus on features critical to the segmentation task, thus maintaining a dynamic balance between the enhanced data and the original input. The attention mechanism is mathematically formulated as shown in Equations (10)-(12):  
\[\alpha_{i,j}=\frac{exp(A_{i,j})}{\sum_{k=1}^{N}exp(A_{i,k})} \tag{10}\]  
\[Y_{i,j,k}=X_{i,j,k}\cdot\alpha_{i,j,k} \tag{11}\]  
\[M(X)=softmax(FC\big{(}X^{\prime}_{t}W\big{)}) \tag{12}\]  
where \(X\in R^{B\times N\times C}\) is the input point cloud data, B is the batch size, N is the number of input points in a single batch, C is the number of channel features, A is the attentional activation value, FC is the fully connected layer, and W is the weight matrix of the fully connected layer.