## 2 Methods
### Algorithm Design and Validation for Tunnel Blasting Evaluation
#### 2.2.1 Algorithm Selection and Workflow  
The selected algorithmic workflow was designed to systematically process and refine spatial data in three main stages: 3D reconstruction, feature matching, and data refinement. This workflow is particularly suited for tunnel environments, where low lighting, airborne particulates, and irregular surfaces are common. The algorithms work synergistically to produce a highly accurate representation of tunnel conditions post-blast, providing a robust tool for evaluating half porosity as a key metric of blasting effectiveness. **1. 3D Reconstruction using Structure-from-Motion (SfM)**  
The initial stage of evaluation involves reconstructing a 3D model of the tunnel face following a blast, utilizing the SfM technique. SfM processes multiple 2D images taken from various angles to create a 3D spatial model, taking advantage of perspective shifts. In this study, images were captured using a Nikon Z50 camera with a 50-80 mm lens from a distance of 6-8 meters. The SfM process includes:  
1. Image Overlap: Ensuring at least 30% overlap between images to facilitate effective feature matching and depth calculation. 2. Pre-Capture Calibration: Correcting lens distortion prior to image capture to improve accuracy. SfM is traditionally employed in fields such as archaeology and geosciences, where environmental challenges such as lowlight conditions and irregular surfaces also prevail. Its adaptation here to the unique conditions of tunnel environments--specifically, its resilience to dust and lighting inconsistencies--demonstrates the technique's versatility and capacity for providing detailed spatial information in demanding engineering contexts. By accurately capturing the geometry of the post-blast tunnel face, SfM provides the foundational data required for assessing blast-induced structural changes with precision. **2. Feature Matching with Scale-Invariant Feature Transform (SIFT)**  
To improve the precision of the 3D reconstruction process, SIFT was used to match features across the image set. SIFT detects and describes stable image features that are invariant to changes in scale, rotation, and lighting--an essential quality in tunnels, where lighting is uneven and often limited. The SIFT process includes:  
1. Key Point Detection: Identifying distinct, reliable points within each image that can be matched consistently. 2. Orientation Assignment: Assigning an orientation to each key point based on local image gradients, ensuring the descriptors remain rotation invariant. 3. Descriptor Generation: Creating robust feature descriptors that encode local gradient information, enhancing the reliability of feature matching. Originally developed for object recognition in computer vision applications, SIFT's implementation here allows for accurate feature tracking across images taken under challenging conditions. This adaptation to tunnel blasting evaluation highlights SIFT's capacity for handling environmental variability, ensuring a coherent and detailed 3D model of the tunnel surface. This model subsequently allows for precise analysis of residual voids and blast induced changes in rock integrity. **3. Noise Filtering and Outlier Rejection using Random Sample Consensus (RANSAC)**  
Following 3D reconstruction, the RANSAC algorithm was applied to filter out noise and reject outliers, refining the quality of the point cloud data. RANSAC iteratively identifies the most relevant data points, fitting them to a geometric model while discarding those that fall outside of a defined threshold. The process operates as follows:  
1. Random Selection: Randomly selecting subsets of points from the 3D point cloud. Model Fitting: Fitting a model (e.g., plane or cylinder) to these subsets. 3. Consensus Set Formation: Counting inliers (points that fit the model within a threshold). 4. Iteration: Repeating the process to maximize the inlier count, ultimately selecting the best fitting model.