## 2 Materials and Methods
### Neural Network Architecture of the Proposed Method  
To enhance the accuracy of soil pore structure identification while preserving the spatial continuity of pores, we propose a novel architecture, the bidirectional U-Net with long short-term memory (BDULSTM). We incorporated a U-Net-based RNN capable of processing multiple inputs concurrently and managing information with the retention and selective forgetting characteristics of an LSTM network. This architecture not only assimilates the spatial information from a sequence of adjacent images but also leverages U-Net's robust encoding, decoding, and cropping framework to accomplish precise segmentation. BDULSTM consists of an odd number of ULSTM units, and Figure 1 shows the complete process of data flow and handling within the model when three images are inputted. Each ULSTM unit receives an image as input, with the output of the ULSTM unit positioned in the center designated as the final output of the model. C and H mean the input and output of a cell in ULSTM, respectively, with the numbers indicating the specific cell responsible for transmitting features in the sequence. The sequential representation of soil CT images does not have a before and after order, and each sequential image maintains spatial correlation with its adjacent images. Therefore, by adding one ULSTM unit to each end of the ULSTM unit, a bidirectional structure of ULSTM is formed, namely, bidirectional ULSTM, abbreviated as BDULSTM. ULSTM is based on the U-Net framework, integrating CLSTM between its encoder and decoder components, as illustrated in Figure 2. The original U-Net network has a U-shaped structure, with the left side downsampling, the right side upsampling, and the middle relying on skip connections to merge the features of each layer in the downsampling with those of each layer in the upsampling. By incorporating the concept of recursion into the foundation of U-Net, ULSTM is capable of processing multiple inputs at once and, like the LSTM network, can preserve and forget certain specific information. It achieves high-precision segmentation by not only integrating the spatial information of several  
The ULSTM network architecture utilizes CLSTM with convolutional, pooling, dropout, and deconvolutional layers. The input tensor size is 3 \(\times\) 256 \(\times\) 256. First, downsampling of five convolutional and four pooling layers is performed, where the size of the convolution kernel in the convolutional layer associated with each downsampling operation is 3 \(\times\) 3, with a padding size of one. The numbers of convolution kernels in the layers are 64, 128, 256, 512, and 1024, and the maximum pooling layer dimensions are 2 \(\times\) 2, with \(\rho\) = 0.5 in the dropout layer. The size of the feature tensor is 1024 \(\times\) 16 \(\times\) 16 when downsampling is performed. Each CLSTM module contains 1024 hidden units. The convolution kernel size is 5 \(\times\) 5, the padding size is one, and the output feature tensor size is 1024 \(\times\) 16 \(\times\) 16. Four deconvolutional layers are upsampled, where the size of the convolution kernels is 3 \(\times\) 3, the padding size is one, and the numbers of convolution kernels are 512, 256, 128, and 64, with \(\rho\) = 0.5 in the dropout layer. It is worth noting that there is a skip connection between each upsampling and downsampling operation on the same level, allowing the deep and shallow features of the network to be combined to optimize the segmentation accuracy. In the BDULSTM network architecture, CLSTM provides the ability to fuse features between layers. LSTM is particularly powerful for processing time-series data, but traditional LSTM networks can only process one-dimensional sequence data such as word vectors in natural language processing. To process two-dimensional image sequences, it is necessary to expand a two-dimensional image into one-dimensional sequence data with a data length of width \(\times\) height to be inputted into the network.