This study presents a non-contact method for measuring surface roughness in sand castings through machine vision and deep learning. By integrating image processing with an attention-enhanced convolutional neural network (CNN), we developed a system capable of rapid and accurate roughness classification for industrial applications.

1. Methodology
1.1 Image Acquisition and Preprocessing
Standard specimens for sand casting surface roughness (GB6060.1-85) were captured using a DYVCAM-W20246 V22 macro camera under controlled lighting. The preprocessing pipeline included:
Gray-scale Conversion:
$$ f(i, j) = 0.30 \times R(i, j) + 0.59 \times G(i, j) + 0.11 \times B(i, j) $$
Contrast Enhancement:
$$ s_k = T(r_k) = (L – 1) \sum_{j=0}^{k} P_r(r_j) = \frac{L – 1}{MN} \sum_{j=0}^{k} n_j \quad (k = 0,1,2,\ldots,L-1) $$
CLAHE (Clip Limit=200, Grid=8×8) outperformed conventional histogram equalization in handling illumination variance. Median filtering (7×7 kernel) effectively reduced noise while preserving texture details.
| Dataset Type | Specimen Class | Ra3.2 | Ra6.3 | Ra12.5 | Ra25 | Ra50 | Total |
|---|---|---|---|---|---|---|---|
| Training | Iron Sand | 484 | 492 | 484 | 492 | 504 | 2,456 |
| Aluminum Alloy | 484 | 516 | 484 | 484 | 492 | 2,460 | |
| Validation | Iron Sand | 104 | 104 | 104 | 104 | 104 | 520 |
| Aluminum Alloy | 104 | 104 | 104 | 104 | 104 | 520 |
1.2 Neural Network Architecture
The SE-ResNet-50 model combined residual learning with channel attention mechanisms:
$$ \text{Attention Weight} = \sigma(W_2\delta(W_1\text{GAP}(X))) $$
Where σ = Sigmoid, δ = ReLU, W = 1×1 convolutions. The network structure featured:
- Input: 480×480 grayscale images
- Base Architecture: ResNet-50 with SE blocks
- Optimizer: Adam (lr=0.1)
- Loss: Cross Entropy
2. Experimental Results
2.1 Model Performance
The trained network achieved exceptional classification accuracy:
| Specimen Type | Ra3.2 | Ra6.3 | Ra12.5 | Ra25 | Ra50 | Overall |
|---|---|---|---|---|---|---|
| Iron Sand | 100% | 99% | 100% | 98% | 98% | 99.0% |
| Aluminum Alloy | 100% | 100% | 100% | 100% | 98% | 99.6% |
2.2 Practical Validation
The system demonstrated 87.5% accuracy on actual sand castings:
| Component | Measurement Points | Correct Classifications | Accuracy | Speed |
|---|---|---|---|---|
| Stainless Steel Pump | 16 | 14 | 87.5% | 0.086s |
| Aluminum Alloy Volute | 16 | 14 | 87.5% |
3. Technical Advantages
This sand casting roughness detection method offers:
$$ \text{Efficiency} = \frac{\text{Accuracy}}{\text{Measurement Time}} = \frac{0.875}{0.086} \approx 10.17 \, \text{units/s} $$
- Non-contact measurement suitable for complex geometries
- Real-time processing capability
- Adaptability to different metal types
4. Conclusion
The integration of machine vision and deep learning enables efficient surface quality control for sand casting production. The developed system achieves comparable accuracy to traditional methods while significantly improving measurement speed and operational flexibility, demonstrating great potential for industrial implementation.
