## 2 Materials and Methods
### Extraction Method of Hole and Crack in CT Scanning Image  
The initial CT scan image is a grayscale representation with pixel values ranging from 0 to 255, as illustrated in Figure 6. This image can be manipulated to visualize the mineral components (higher grayscale values), matrix (intermediate grayscale values), and pores (lower grayscale values). However, the precise dimensions of each element cannot be accurately determined, and some smaller pores may not be discernible by visual inspection alone. The overall grayscale distribution of the raw CT image, as well as the grayscale histogram of the line path, was acquired using MATLAB analysis (v.R2021a), and is presented in Figure 7. The majority of raw CT images exhibit grayscale values between 140 and 220, with relatively concentrated pixel values and minimal color contrast, making it challenging to distinguish certain pores and matrix elements via human visual inspection. Consequently, image processing techniques [19; 20] are required to enhance the visual recognition of the original CT images, and to accurately extract characteristics of pore and fissure development. The specific method to achieve this is described below. The histogram equalization method was used to nonlinearly stretch CT images, and the initial narrow concentrated gray interval was transformed into a uniform distribution throughout the gray interval (0-255), greatly improving image contrast. The specific algorithm proceeds as follows: First, the occurrence times of each pixel value in the CT  
Figure 6: Cross-section CT images of red sandstone samples. Figure 7: (**a**) Gray value distribution of CT section images; (**b**) distribution of gray values on the specified path of the CT slice image. image are counted and normalized to generate the original image histogram. Subsequently, the cumulative histogram distribution is calculated using the formula  
\[C_{i}=\sum_{j=0}^{i}P_{j} \tag{1}\]  
The gray value is represented by \(i\), \(P_{j}\) denotes the frequency of pixels with gray value \(j\) within the image, and \(C_{j}\) signifies the cumulative distribution function. Finally, the following formula is employed to determine the pixel values after equalization and substitute the pixel values in the original image:  
\[H(i)=round(\frac{C_{i}-C_{\text{min}}}{M\times N-1}\times(L-1)) \tag{2}\]  
where \(H(i)\) denotes the pixel value following the mapping process; \(M\) and \(N\) correspond to the image width and height, respectively; \(L\) signifies the range of pixel values, and min refers to the smallest pixel point in the original image. On the basis of the equalization of the gray histogram of CT images, the overall gray value of the image is nonlinearly stretched, so that the gray interval of the darker part of the image is enlarged, and the difference between the pores and the matrix in the image is more clear, as shown in Figure 8. Based on the equalization of the gray histogram of CT images, the overall gray value of the image undergoes nonlinear stretching, resulting in an enlarged gray interval for the darker regions of the image. This enhancement clarifies the distinction between the pores and the matrix in the image, as illustrated in Figure 8. Prior to this, a logarithmic transformation is applied to the original image to accentuate the contrast of prominent dark areas:  
\[g(x,y)=n\lg[f(x,y)+1] \tag{3}\]  
where \(g(x,y)\) represents the grayscale value, \(f(x,y)\) denotes the pixel value, and \(n\) serves as the scaling coefficient that adjusts the dynamic range of the transformed grayscale value. The application of thresholding was utilized to segment the CT image of the red sandstone and differentiate the pore component from the matrix component. The image binarization segmentation methodology was employed to establish a gray value threshold, resulting in the division of the image into two distinct parts. The gray value of the region  
Figure 8: (**a**) Before gray stretching; (**b**) after gray stretching.