# Vision-Based Concrete-Crack Detection on Railway Sleepers Using Dense U-Net Model
## 3 Methodology
### Model Architecture  
This paper designed a railway sleeper crack detection system based on [PERSON]'s U-net architecture. U-net is a classic encoder-decoder [59] model where the encoder part extracts necessary features of the images, and the decoder part of the model generates predicted images (exact resolution with input image) by combining the features extracted from the encoder module. Unlike the FCN model, U-net architecture uses skip connections for maximum information flow from the encoder to the decoder module. To improve the result of the original U-net model, in this study, we proposed a Dense U-net model by combining the concept of both U-net and DenseNet [60] architectures. The architecture of the proposed Dense U-Net method is illustrated in Figure 3.  
The encoder module's structure is shown in the left dotted box. The encoder module consists of a total of 4 encoder blocks. Each of the encoder blocks consists of two repeated convolution layers for extracting the features, followed by an activation function layer. We used a kernel size of 3 \(\times\) 3, the same padding, and the Rectified Linear Unit (ReLu) activation function throughout the architecture. Figure 3: Structure of the Dense U-net model. Figure 2: Example images and their corresponding ground truth from our dataset. The first row presents the original images, and the second row presents the ground truth images. The convolution kernels traverse through the images and perform element-wise multiplication with the corresponding elements of the receptive fields. The mathematical equation of the convolution operation is as follows:  
\[\mathcal{F}(p,q)=(A*B)(p,q)=\sum_{c}\sum_{d}A(c,d)B(p-c,q-d) \tag{1}\]  
where \(A\) is the input image, \(B\) is the filter, \(p\), \(q\) denotes the rows, and the columns of the image, \(c\), and \(d\) are loop controllers. After stacking the outputs from all of the kernels, the feature map function from a particular layer \(l\) can be achieved, which can be stated as follows:  
\[v^{l}=f(b^{l}+W^{l}z^{lr-1}) \tag{2}\]  
\[f(z)=ReLu(z)= \begin{cases}z,&\text{if }z>0\\ 0,&\text{otherwise}\end{cases}  \tag{3}\]  
where \(v\) is the extracted feature, \(b\) denotes the bias vector, \(W\) denotes the weight matrix, and \(z\) is the input from the previous layer. The utilized ReLu activation function converts the output values to \(z\) if \(z\) is a positive number, otherwise, the output is 0. The dimension of the extracted features can be calculated by utilizing the equation below:  
\[(M,N,N_{c})\times(f,f,f_{c})=([(A+2p-f)/S+1]) \tag{4}\]  
where \(S\) = number of stride, \(p\) = number of padding, \(N_{c}\) = number of channels, \(f_{c}\) = number of filters, \(A\) is input image,\(f\) = size of the kernel. Finally, at the end of each encoder block, we used a \(2\times 2\) Maxpooling layer to reduce the spatial dimensions of the feature maps to one-quarter in size. If a feature map has a dimension of \(N\times 1\), then the Maxpooling will be  
\[o_{j}=max_{N\times 1}\{o_{i}^{n\times 1}d(n,1)\} \tag{5}\]  
where, \(d(n,1)\) is a window patch from the \(N\times 1\) dimensional feature map and \(o_{j}\) is the maximum value among the considered patch. As the DenseNet model argued that short connections among the layers of a DL network improve the feature propagation, we established a few short linkages among the encoder layers and the original contracting path. We designed the short connections in such a way so that an encoder block, as well as the bridge between the encoder and decoder module, can get the features produced by all of the previous encoder layers directly through the short connections. Mathematically, the \(e\)th encoder layer \(E_{e}\) is receiving the features of all the previous encoder layers, \(v_{E_{0}}\), \(v_{E_{1}}\),....... \(v_{E_{e-1}}\), as input:  
\[v_{E_{e}}=C([v_{E_{0}},v_{E_{1}},\dots v_{E_{e-1}}]) \tag{6}\]  
where \(C\) denotes the concatenation of all the features from \(E_{0}\), \(E_{1}\),... \(E_{e-1}\) encoder layers.