In the rapidly advancing landscape of modern industry, the foundry sector remains a cornerstone of high-end equipment manufacturing. The quality of cast components is paramount, with surface roughness standing as a critical metric that directly influences performance characteristics such as wear resistance, fatigue strength, and vibration damping. For sand casting services, where typical surface roughness ranges from Ra 3.2 to 50 μm, traditional assessment methods present significant limitations. The widely used tactile method, involving stylus profilometers, is often impractical due to spatial constraints and its limited measurement range. Conversely, the visual comparison against standard roughness specimens is highly subjective and lacks quantitative precision. Therefore, the development of a rapid, accurate, and non-contact measurement technique is an urgent need for quality control within sand casting services, promising to enhance objectivity, efficiency, and consistency in surface finish evaluation.
This research delves into the application of machine vision, specifically combining advanced image processing with deep convolutional neural networks (CNNs), to establish a robust system for the non-contact assessment of surface roughness on sand-cast components. The core methodology involves training a sophisticated neural network on images of standardized roughness specimens and subsequently deploying this model to evaluate real-world castings. This approach aims to minimize human error, accelerate the inspection process, and provide a reliable digital tool for foundries specializing in sand casting services.
The technical pathway is systematically structured, progressing from data acquisition and preparation to model development and final validation. Initial efforts focus on creating a high-quality dataset by capturing images from standard roughness blocks, which serve as the ground truth. These images undergo a rigorous preprocessing pipeline to normalize conditions and enhance relevant texture features. Subsequently, a powerful CNN architecture, enhanced with an attention mechanism, is constructed and trained on this dataset. Finally, the trained model is integrated into a dedicated software application coupled with an image acquisition module, forming a complete system that is validated against actual sand castings.
Data Set Preparation: Foundation for Learning
The efficacy of any machine learning model is fundamentally tied to the quality and relevance of its training data. For this study, the dataset was constructed using standard casting surface roughness comparison blocks, the very benchmarks used in conventional quality assessment for sand casting services.
Image Acquisition System
A consistent and controlled imaging environment is crucial for extracting meaningful texture information related to roughness. A dedicated image acquisition module was developed, centered around a DYVCAM-W20246 V22 macro camera with a CMOS sensor, providing an output resolution of 640×480 pixels. To ensure stable and uniform illumination—a critical factor for texture analysis—a ring of LED lights was integrated into a custom-designed, 3D-printed black enclosure. This housing minimizes ambient light interference and maintains a fixed working distance and lighting angle, ensuring that all captured images are directly comparable. The device connects via USB for seamless image transfer to a processing computer. Images were collected from two types of standard blocks (iron sand-cast and aluminum die-cast) across five roughness grades: Ra 3.2, 6.3, 12.5, 25, and 50 μm.
Image Preprocessing Pipeline
Raw images require preprocessing to standardize inputs and accentuate the texture features correlated with surface roughness, while suppressing irrelevant variations. The pipeline consists of several key steps, summarized in the table below.
| Step | Purpose | Key Parameters/Algorithm |
|---|---|---|
| 1. Cropping | Remove blurred peripheral regions from the macro lens. | Center crop to 480×480 pixels. |
| 2. Grayscale Conversion | Reduce computational load; roughness is expressed in luminance texture, not color. | $$ f(i, j) = 0.30R(i, j) + 0.59G(i, j) + 0.11B(i, j) $$ |
| 3. Contrast Enhancement | Improve global contrast to make texture patterns more distinct. | Contrast Limited Adaptive Histogram Equalization (CLAHE). Clip Limit=200, Grid=8×8. |
| 4. Noise Reduction | Remove sensor noise and minor impurities without blurring texture edges. | Median Filter with a 7×7 kernel. |
The choice of CLAHE over standard Histogram Equalization (HE) is particularly important. HE applies a global transformation, which can exacerbate non-uniform lighting. CLAHE operates on small, localized regions (tiles), equalizing their contrast independently and then bilinearly interpolating the results. This local approach prevents the over-amplification of noise and effectively handles the slight illumination gradients present in side-lit images. The final preprocessed images exhibit normalized brightness and significantly enhanced texture details directly corresponding to the Ra value, providing an ideal input for the neural network.
Data Augmentation and Splitting
To improve the model’s ability to generalize and prevent overfitting, the dataset was expanded using data augmentation techniques. The primary method employed was horizontal flipping, effectively doubling the number of available training samples. A total of 6,956 images were prepared. The dataset was then strategically partitioned into three mutually exclusive sets to ensure a rigorous training and evaluation process, crucial for developing a reliable tool for sand casting services.
| Data Subset | Purpose | Number of Images (per Ra grade, per block type) | Total Images |
|---|---|---|---|
| Training Set | Used to adjust the neural network’s internal weights (parameters). | ~490 per grade/type | 4,916 |
| Validation Set | Used during training to monitor performance and select the best model, preventing overfitting. | 104 per grade/type | 1,040 |
| Test Set | Used only once, after training is complete, to provide an unbiased final evaluation of the model’s accuracy. | 100 per grade/type | 1,000 |
Neural Network Architecture and Training
Convolutional Neural Networks (CNNs) are the state-of-the-art for image recognition tasks due to their ability to automatically learn hierarchical spatial features. For this application, a deep network capable of discerning subtle textural differences between roughness grades is required.
Enhanced Network Design: ResNet50 with SE Attention
The core network is based on the ResNet50 architecture, renowned for its depth and effectiveness facilitated by residual learning. Residual blocks solve the vanishing gradient problem in deep networks by using “skip connections” that allow gradients to flow directly through. The fundamental operation within a residual block can be expressed as:
$$ \mathbf{y} = \mathcal{F}(\mathbf{x}, {W_i}) + \mathbf{x} $$
where $\mathbf{x}$ and $\mathbf{y}$ are the input and output vectors, and $\mathcal{F}(\mathbf{x}, {W_i})$ represents the residual mapping to be learned.
To further boost performance, a Squeeze-and-Excitation (SE) attention module was integrated into each residual block. The SE mechanism enhances the network’s representational power by explicitly modeling interdependencies between the channels of its convolutional features. It operates through two sequential operations:
- Squeeze: Global spatial information is compressed into a channel descriptor using global average pooling: $$ z_c = \frac{1}{H \times W} \sum_{i=1}^{H} \sum_{j=1}^{W} u_c(i, j) $$
- Excitation: A simple self-gating mechanism, based on channel-wise dependencies, produces activations to recalibrate the original feature map: $$ \mathbf{s} = \sigma(\mathbf{W}_2 \delta(\mathbf{W}_1 \mathbf{z})) $$ where $\sigma$ is the Sigmoid function, $\delta$ is the ReLU function, and $\mathbf{W}_1$ and $\mathbf{W}_2$ are learned weight matrices. The final output is obtained by rescaling the original feature map $u_c$ with the activations $s_c$: $$ \tilde{x}_c = s_c \cdot u_c $$
This “SE-ResNet50” model allows the network to focus more on the most informative texture features for roughness discrimination, a significant advantage for the nuanced patterns found in sand casting services surfaces.
| Network Component | Function in Roughness Assessment |
|---|---|
| Convolutional Layers | Extract low-level features (edges, blobs) and combine them into higher-level texture patterns. |
| Residual Blocks with SE | Enable training of very deep networks and adaptively emphasize important feature channels related to roughness scale. |
| Global Average Pooling & Fully Connected Layer | Aggregate the learned high-level features into a final descriptor for classification. |
| Softmax Output Layer | Produces a probability distribution over the five roughness classes (Ra 3.2, 6.3, 12.5, 25, 50). |
Model Training and Performance
The model was trained using the Adam optimizer with a cross-entropy loss function, an initial learning rate of 0.1, and a batch size of 64. Training was conducted for a maximum of 2000 epochs with early stopping based on validation accuracy. The training converged efficiently after approximately 90 epochs, taking about 391 minutes on a system with an NVIDIA GeForce RTX 3060 GPU.
The model’s performance was meticulously tracked using the validation sets. The final selected model, from epoch 81, achieved exceptional validation accuracies of 99.04% and 99.23% on the iron sand-cast and aluminum die-cast standard block images, respectively. The ultimate test of generalization was performed on the completely unseen test sets. The model achieved a remarkable 99.00% accuracy on the iron sand-cast test set and 99.60% on the aluminum die-cast test set. The confusion matrices for both test sets confirmed near-perfect classification across all five roughness grades, demonstrating the model’s profound capability to learn and distinguish the textural signatures associated with each Ra value.
System Integration and Validation on Actual Castings
The true measure of this technology’s value for sand casting services lies in its application to real, production-line components. A dedicated desktop software application was developed to operationalize the research. This software interfaces directly with the image acquisition module, captures live video, and allows the user to freeze a frame for analysis. With a single click, the captured image is routed through the identical preprocessing pipeline, fed into the loaded SE-ResNet50 model, and receives a roughness prediction in real-time.
Experimental Validation Protocol
To validate the system’s practical efficacy, two distinct sand-cast parts were selected: a stainless steel pump casing (typically with finer finishes: Ra 3.2-12.5 μm) and an aluminum alloy volute (typically with coarser finishes: Ra 12.5-50 μm). At 16 randomly selected key locations on each casting, surface roughness was assessed using two methods in parallel:
- Traditional Method: Visual and tactile comparison by a trained inspector using standard roughness blocks.
- Proposed Machine Vision Method: Using the developed software and imaging module at the same location.
The results were then compared to determine the accuracy of the automated system against the industry-standard practice.
Results and Analysis
The validation yielded highly promising results for implementation in sand casting services. Out of the 32 total measurement points, the machine vision system agreed with the traditional assessment at 28 points, resulting in an overall accuracy of 87.5%. Perhaps more impactful for production environments is the measurement speed: the average inference time per image, including preprocessing, was a mere 0.086 seconds. The detailed results are summarized below.
| Casting Component | Measurement Point | Standard Block Result (Ra μm) | Machine Vision Result (Ra μm) | Agreement |
|---|---|---|---|---|
| Stainless Steel Pump Casing | 1 | 6.3 | 6.3 | Yes |
| 2 | 12.5 | 12.5 | Yes | |
| 3 | 6.3 | 6.3 | Yes | |
| 4 | 6.3 | 6.3 | Yes | |
| 5 | 3.2 | 3.2 | Yes | |
| 6 | 3.2 | 3.2 | Yes | |
| 7 | 3.2 | 6.3 | No | |
| 8 | 12.5 | 12.5 | Yes | |
| … | … | … | … | … |
| 16 | 12.5 | 12.5 | Yes | |
| Aluminum Alloy Volute | 17 | 50 | 50 | Yes |
| 18 | 50 | 50 | Yes | |
| 19 | 50 | 50 | Yes | |
| 20 | 25 | 25 | Yes | |
| 21 | 12.5 | 12.5 | Yes | |
| 22 | 12.5 | 12.5 | Yes | |
| 23 | 25 | 50 | No | |
| 24 | 50 | 50 | Yes | |
| … | … | … | … | … |
| 32 | 25 | 25 | Yes | |
| Overall Accuracy | 28/32 = 87.5% | |||
| Average Inference Time | 0.086 seconds | |||
The discrepancies (e.g., point 7: 3.2 vs. 6.3, point 23: 25 vs. 50) likely stem from the inherent subjectivity of the manual comparison method and potentially from localized surface conditions not fully represented in the training data. Nevertheless, an 87.5% correlation with the standard method, achieved in a fraction of a second, represents a transformative advancement for quality assurance in sand casting services.
Conclusion and Future Outlook
This research successfully demonstrates a complete, functional system for the non-contact assessment of surface roughness tailored for sand casting services. By harnessing a meticulously designed image preprocessing pipeline and a deep convolutional neural network enhanced with channel attention (SE-ResNet50), the system learns the complex mapping between surface texture and roughness grade with over 99% accuracy on standardized specimens. When deployed on actual sand-cast components, the system maintains a high correlation (87.5%) with traditional assessment methods while offering unparalleled speed and objectivity.
The implications for the foundry industry, particularly providers of sand casting services, are substantial. This technology enables:
- Rapid In-Line Inspection: Near-instantaneous measurements facilitate 100% inspection of critical features without bottlenecking production.
- Digital Quality Records: Each measurement can be stored with its corresponding image, creating an auditable digital trail for quality management and process control.
- Reduced Subjectivity: Minimizes reliance on individual inspector experience and judgment, standardizing quality assessment across shifts and personnel.
- Feedback for Process Optimization: Rapid, quantitative data can be fed back to molding and core-making processes to proactively control surface finish.
Future work will focus on expanding the robustness of the system for sand casting services. This includes enriching the training dataset with images from a wider variety of casting alloys (e.g., ductile iron, bronze) and surface conditions (e.g., as-cast, shot-blasted, coated). Furthermore, exploring regression-based neural networks to predict a continuous Ra value, rather than a discrete grade, would provide even finer granularity. Integration of this vision system into robotic inspection cells or handheld devices could further revolutionize quality control workflows in foundries worldwide, solidifying the role of advanced machine vision as an indispensable tool for modern, high-quality sand casting services.

