## 2 Methodology
### Three-Dimensional Numerical Model Reconstruction by Digital Image Processing  
Using the DIP technology, the actual microstructure of heterogeneous rocks could be precisely extracted from images and incorporated into numerical models. Pixels make up a digital image on a computer. Each pixel consists of the intersection area on either side of horizontal and vertical scan lines of equal width, resulting in a square element with a width of w. Each pixel is represented by three primary colors, namely, red (R), green (G), and blue (B). The reconstruction of 3D numerical samples was divided into four steps based on the digital image. As a first step, we collected high-resolution pictures of the research object, which provided information about its microstructure--numerical models of different scales with different image sources. The shale images at the microscale in Section 3.1 were obtained using Focused Ion Beam Scanning Electron Microscopes technology (Figure 4a). Mesoscale shale images were obtained using the micro-CT scanning technique in Section 3.2. The columnar jointed rock mass image of Section 3.3 was obtained using a video camera [35]. Second, the image vectorization processing used DIP technology to convert the image into vectorized data that could be recognized by numeric codes. In order to construct a 3D model, the extracted digital microstructures were stacked layer by layer in a particular sequence and at specific intervals based on variation within a certain thickness 1 (Figure 4c,d). The 3D FE meshes were simultaneously established (Figure 4c). A pixel's size determines the dimensions of the elements, which were all hexahedral quads. The thickness of each element was equal to the distance between layers. That is, the length and width of each element mesh are w, and the height is h. Third, we determined the segmentation threshold to distinguish and segment the constructed 3D microstructure of the finite element model, with microcracks, cracks, voids, and mineral particles. Finally, the DIP method was applied to assign the corresponding mechanical properties to the elements of the components (Figure 4d). In the following section, we describe the third step in detail.  
In order to accurately characterize the microscopic and macroscopic structures of the models, the image processing methods and segmentation thresholding methods were slightly different for each model. The following briefly introduces the method of determining the segmentation threshold, taking the microscale shale in Section 3.1 as an example. The gray histogram threshold method was adopted to segment microstructural segmentation [2] from the solid matrix to determine the segmentation threshold. Figure 4b shows a microscopic image of the shale and the corresponding grayscale histograms of the I values. I represents the average of R, G, and B, while the \(X\)-axis represents the level of grey and the \(Y\)-axis represents the pixel count. The gray level is similar in the same material, but there are significant differences among different materials. The peaks reflect this difference in the histogram. Therefore, the different rock components can be classified by identifying the grayscale at the start and end of each peak. That is, the gray value at the location of each trough is the segmentation threshold. After this, we artificially adjusted the repeated segmentation threshold until the derived model could accurately reflect the reality of the microstructural and mineral distribution inside the shale. The final segmentation thresh olds of this model are 25, 75, and 225. Here, the I value in the range of 0-25 corresponds to fractures, the I value in the range of 25-75 corresponds to organic matters, the I value in the range of 75-225 corresponds to the carbonate mineral matrix dominated by calcite, and the I value in the range of 225-255 corresponds to pyrite.