Skip to content

redhat123456/RockFracture_DeepLabv3-_Pattern

Repository files navigation

RockFracture_DeepLabv3-_Pattern

This code repository is the official implementation of the manuscript Enhanced Rock Fracture Detection: Integrating DeepLabv3+ Segmentation with Geometric Pattern Analysis submitted to The Visual Computer.

Project Overview

This project implements an automated rock fracture detection framework integrating an enhanced DeepLabv3+ semantic segmentation with triangular scatter point geometric pattern analysis. It performs pixel-level segmentation, sine curve fitting, geometric parameter extraction, and fracture zone delineation for borehole imaging, addressing challenges such as irregular fracture morphology, significant background interference, and low detection robustness in complex geological contexts.

Core Functions:

  • Specialized preprocessing pipeline for drill hole images (grayscaling, bilateral filtering, CLAHE enhancement, high-pass filtering, image fusion, batch augmentation);

  • DeepLabv3+ fissure segmentation model integrating ASPP multi-scale convolutions with Edge-Aware CBAM attention mechanism;

  • Nonlinear least-squares sine curve fitting based on Hough transform + FFT initialization for extracting slit geometric parameters (amplitude, period, phase, center position);

  • Automatic slit region segmentation, iterative noise point removal, and slit pattern clustering;

  • Model training and testing scripts incorporating evaluation metrics such as Accuracy, Dice, and IoU.


Figure 1: DeepLabv3+ fissure segmentation model integrating ASPP multi-scale convolutions with Edge-Aware CBAM attention mechanism

Figure 2: Nonlinear least-squares sine curve fitting based on Hough transform + FFT initialization for extracting fracture geometric parameters

Experimental Results:

Compared to traditional methods and existing deep learning models, this approach achieves a 10% improvement in Dice coefficient. It demonstrates enhanced robustness under conditions of noise, non-uniform rock texture, and varying illumination, enabling engineering-grade quantitative analysis of rock fracture geometry.

Model Architecture

Overall Architecture Design

This project adopts DeepLabV3+ as the core segmentation network, integrating multiple advanced techniques to achieve high-precision rock fracture detection:

Core Module Details

1. ResNet50 Backbone Network

  • Function: Multi-scale hierarchical feature extraction
  • Characteristics: Uses dilated convolution in the last two layers to expand receptive field while maintaining resolution and increasing global context understanding
  • Output: Feature pyramid with 4 different resolutions

2. ASPP (Atrous Spatial Pyramid Pooling) Module

This module leverages 4 parallel branches with different dilation rates to perform multi-scale convolution, capturing fracture features at different scales:

Advantages:

  • ✓ Multi-scale receptive field fusion, capturing fine fractures to overall fracture texture
  • ✓ Lossless spatial information, preserving fine fracture boundaries

3. Edge-Aware CBAM Attention Mechanism

An enhanced attention module based on channel attention and spatial attention, additionally fusing image edge information:

Channel Attention

  • Adaptive average pooling + adaptive max pooling
  • 2-layer FC layers learning inter-channel importance
  • Sigmoid-weighted original features

Function: Learn the relative importance of features in each channel, enhancing feature channels related to fractures

Spatial Attention

  • Average pooling and max pooling along channel dimension
  • 7×7 convolution fusing two pooling results
  • Learning feature weights in spatial dimension

Function: Emphasize fracture regions, suppress background noise

Edge-Aware Enhancement:

  • Use Sobel operator to compute edge gradients of input image
  • Multiply edge map with spatial attention to enhance boundary fineness
  • Formula: $S_{out} = SA(x) \times (1 + E_{edge})$

where $E_{edge}$ is edge detection result, $(1 + E_{edge})$ ensures non-boundary regions maintain original weight

Image Preprocessing Pipeline

Before entering the model, raw borehole images undergo the following preprocessing steps:

Raw image
    ↓
Grayscale conversion (RGB → Gray)
    ↓
CLAHE adaptive contrast enhancement
    [clipLimit=3.0, tileGridSize=(8,8)]
    Function: Enhance local contrast, highlight fine fractures
    ↓
Bilateral filtering
    [d=9, sigmaColor=75, sigmaSpace=75]
    Function: Edge-preserving denoising, smooth background while preserving fracture edges
    ↓
High-pass filtering
    [kernel: [-1,-1,-1; -1,8,-1; -1,-1,-1]]
    Function: Enhance edges and texture details
    ↓
Image fusion
    final = bilateral × 1.0 + highpass × 0.7
    ↓
Data augmentation (circular shift concatenation)
    [Divide image into 10 parts, cyclically shift and combine to generate variant samples]
    ↓
256×256 normalized input

Evaluation Metrics

The model training and validation stages employ the following metrics to measure segmentation performance:

Metric English Name Formula Description
Accuracy Accuracy $\frac{TP+TN}{TP+TN+FP+FN}$ Proportion of correctly classified pixels
IoU IoU (Intersection over Union) $\frac{\text{TP}}{\text{TP+FP+FN}}$ Overlap degree between predicted and true regions, larger is better (max 1.0)
Dice Dice Coefficient $\frac{2\text{TP}}{2\text{TP+FP+FN}}$ Similar to IoU but more sensitive to FN, emphasizes missed detections
Precision Precision $\frac{\text{TP}}{\text{TP+FP}}$ Proportion of correctly predicted fracture pixels
Recall Recall $\frac{\text{TP}}{\text{TP+FN}}$ Proportion of true fracture pixels correctly detected
F1 Score F1 Score $\frac{2 \times \text{Precision} \times \text{Recall}}{\text{Precision}+\text{Recall}}$ Harmonic mean of Precision and Recall

Where:

  • TP (True Positive): Correctly detected fracture pixels
  • FP (False Positive): Background pixels incorrectly identified as fractures (over-detection)
  • FN (False Negative): Fracture pixels not detected (missed detection)
  • TN (True Negative): Correctly identified background pixels

Data Fitting and Geometric Parameter Extraction

After obtaining the fracture segmentation results, the project employs nonlinear least-squares fitting combined with FFT initialization and iterative outlier removal to comprehensively extract fracture geometric parameters.

Fitting Method

Using parameterized sine function for modeling: $y = A \sin(kx + \phi) + y_0$

Where:

  • A - Amplitude: Maximum deviation distance of waveform
  • k - Wave Number: $k = \frac{2\pi}{T}$, T is period
  • φ - Initial Phase: Horizontal shift of waveform
  • y₀ - Vertical Offset: Vertical position of waveform center

Fitting Process

Stage 1: FFT Initial Parameter Estimation

  • Uniformly interpolate irregular-scale discrete points to 512 sampling points
  • Use FFT transform to find the main peak in frequency spectrum
  • Automatically extract initial parameters without manual adjustment

Stage 2: Iterative Least-Squares Optimization

  • Use Trust Region Reflective (TRF) optimizer
  • Dynamically configure constraints: A > 0, 1e-4 < k < π, -4π < φ < 4π
  • Multiple iteration rounds, removing outliers each round

Stage 3: Outlier Removal Strategy

  • First round: Use P85 percentile (conservative)
  • Subsequent rounds: Use P75 percentile (aggressive)
  • Retention rate threshold: ≥ 30% and ≥ 5 points, otherwise stop iteration

Stage 4: Multi-initialization Candidates

  • FFT estimation, period variation, amplitude variation and other initializations
  • Select result with minimum RMSE as optimal solution

Geometric Parameter Extraction

Parameter Calculation Physical Meaning Unit
Period $T = \frac{2\pi}{k}$ Periodic length of fracture ripples Pixels
Frequency $f = \frac{1}{T}$ Periods per unit length 1/Pixels
Amplitude A Half of maximum fracture width Pixels
Center Position y₀ Vertical position of fracture Pixels
Phase φ Initial position of waveform Radians
Fitting Error RMSE Model-data fit quality Pixels

Diagnostic Visualization

main2.py generates 2×2 diagnostic plots:

  • Top-left, top-right, bottom-left: Show outlier removal process for iterations 0, 1, 2 (blue=retained, red=discarded)
  • Bottom-right: Compare fitting results of different initializations, mark optimal solution

Output Files

Fitting results are saved in JSON format (result/fitting_results.json), containing:

  • Optimal parameters for each fracture region
  • Retention/discard point statistics for each iteration
  • Fitting RMSE and validation metrics

Parameter Adjustment Suggestions

  1. Outlier sensitivity: P85 → P90 for stricter standard
  2. Iteration count: Increase max_iter parameter to improve precision
  3. RMSE threshold: Adjust rmse_limit based on actual data
  4. Stability verification: Similar results across multiple initializations indicate stable fitting

Example Results

Sample segmentation results on typical samples:

Environment Requirements

Hardware Configuration (Experimental setup for thesis; minimum requirements may be appropriately reduced)

  • CPU: Intel Core i5-14600KF @ 3.50 GHz or higher
  • GPU: NVIDIA GeForce RTX 4060 Ti 8G or higher (CUDA-enabled)
  • RAM: 32 GB or higher
  • Storage: 10 GB or more of available space

Software Dependencies

Base Environment

  • OS: Windows 11 / Ubuntu 18.04/20.04
  • Python: 3.9 (experimental version used in the paper; compatible with 3.8-3.10)
  • CUDA: 12.6
  • CUDNN: 12.8
  • NVIDIA Driver: 560.94 or later

Python library (includes experimental version from the paper; one-click installation via requirements.txt)

tensorflow==2.13.0
opencv-python==4.8.0.76
numpy==1.26.0
pandas==2.1.1
matplotlib==3.8.0
scipy==1.11.3
scikit-image==0.21.0
labelme==5.2.0
pillow==10.0.1
tqdm==4.66.1

Install dependencies with a single click

# After cloning the repository, navigate to the root directory.
pip install -r requirements.txt

Note: If GPU environment configuration fails, you may switch to the CPU version (performance will decrease; recommended for testing purposes only).

Quick Start

1. Environment Setup

After cloning the repository, navigate to the project root directory and install dependencies:

git clone git@github.com:XXX/RockFracture_DeepLabv3-_Pattern.git
cd RockFracture_DeepLabv3-_Pattern
pip install -r requirements.txt

2. Data Preparation and Preprocessing

Step 1: Prepare Raw Data

Place borehole images in the dataset/origin/ directory and corresponding label JSON files in dataset/json/:

dataset/
├── origin/          # Original borehole images (jpg/png)
├── json/            # Corresponding LabelMe label files (json)
└── mask/            # Directory for generated binary masks

Step 2: Run Preprocessing Script

python pre.py

This script will:

  • Read raw images and perform enhancement processing (CLAHE, bilateral filtering, high-pass filtering)
  • Generate binary masks from JSON labels (fracture=black, background=white)
  • Generate segmented dataset, saved to dataset/images_split/ and dataset/masks_split/

3. Model Training

Run the training script to train the DeepLabV3+ model:

python deeplab3_train.py

Training process will:

  • Automatically load preprocessed data
  • Train on GPU (automatically switches to CPU if GPU not available)
  • Save training checkpoints to training_outputs/checkpoints/
  • Save best model as training_outputs/checkpoints/best_model.pth

Training Parameter Adjustment: Modify learning rate, batch size, number of epochs, etc. in deeplab3_train.py

Note: If you don't want to train it yourself, you can download my model: best_model.pth and place it in the /training_outputs/checkpoints folder in the root directory.

4. Model Prediction and Visualization

Use the trained model to predict on new samples:

python predict_model.py

This script will:

  • Load the best model (training_outputs/checkpoints/best_model.pth)
  • Predict all images in dataset/origin/
  • Generate four-column comparison images (original, ground truth, raw prediction, denoised prediction) saved to prediction_results/
  • Generate binary masks saved to output/
  • Output noise removal rate statistics

5. Parameter Extraction and Analysis

Run curve fitting script to extract fracture geometric parameters:

python main2.py

This script will:

  • Perform sine curve fitting on predicted fracture regions
  • Extract geometric parameters (amplitude, period, phase, center position, etc.)
  • Save fitting results to result/fitting_results.json

Quick Test (Optional)

To quickly test the entire workflow, run the following commands in sequence:

python pre.py                    # 1. Data preprocessing
python deeplab3_train.py         # 2. Model training (optional, can use pretrained weights)
python predict_model.py          # 3. Prediction and visualization
python main2.py                  # 4. Parameter extraction

Note: If you already have a trained model, you can skip step 2 and start from step 3.

6. Visualization of Image Processing Process (Optional)

To visualize the stages of image preprocessing and model training process curves, use the plot.py script:

python plot.py

This script will generate detailed visualization plots, including:

📊 Single Metric Curve Plots

  • Loss Curve - Training loss function variation trend
  • Accuracy Curve - Accuracy variation process
  • IoU Curve - Intersection over Union (most important metric, marked with best value)
  • Dice Coefficient Curve - Dice coefficient evolution
  • F1 Score Curve - F1 score variation

📈 Comprehensive Overview Plot

6 subplots showing all key metrics on one figure: Loss, Accuracy, IoU, Dice, F1, and Epoch Time for easy comparison

🔗 Correlation Analysis Plots

  • Loss vs IoU - Shows correspondence between loss and performance
  • Loss vs Multiple Metrics - Simultaneously compares loss with accuracy, Dice, F1 and other metrics

📊 Precision and Recall

Shows Precision and Recall evolution during training process

📊 Other Analysis Plots

  • Training process statistical summary
  • Performance distribution and trend analysis

Output Directory Structure:

training_outputs/figures/
├── single_metrics/      # Single metric curve plots
│   ├── 01_loss.png
│   ├── 02_accuracy.png
│   ├── 03_iou.png
│   ├── 04_dice.png
│   └── 05_f1.png
├── comparison/          # Comparative analysis plots
│   ├── 06_comprehensive.png
│   └── 07_loss_vs_metrics.png
├── analysis/            # Statistical analysis plots
└── process/             # Process plots

Tip: plot.py depends on data files generated during training (training_history.pkl and training_history.csv), so you need to complete step 2 model training first

Citation

If you find this work useful, please cite our preprint:

APA Style:

Tan, Q., & Qin, Y. (2026). Enhanced Rock Fracture Detection: Integrating DeepLabv3+ Segmentation with Geometric Pattern Analysis. Research Square. https://doi.org/10.21203/rs.3.rs-9160848/v1

BibTeX:

@article{tan2026enhanced,
  title={Enhanced Rock Fracture Detection: Integrating DeepLabv3+ Segmentation with Geometric Pattern Analysis},
  author={Tan, Qiancheng and Qin, Yonghui},
  journal={Research Square (Preprint)},
  year={2026},
  month={March},
  day={18},
  version={1},
  doi={10.21203/rs.3.rs-9160848/v1},
  url={[https://doi.org/10.21203/rs.3.rs-9160848/v1](https://doi.org/10.21203/rs.3.rs-9160848/v1)}
}

📄 License

This project is licensed under the MIT License. See the LICENSE file for details.

Copyright (c) 2026 Qiancheng Tan & Yonghui Qin.

About

DeepLabv3-based deep learning framework for rock fracture segmentation.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages