Surface Roughness Detection of Sand Casting Based on Machine Vision

Abstract: Surface roughness is crucial indicator for assessing the quality of sand casting surfaces, impacting wear resistance, fatigue strength, and vibration noise. Traditional measurement methods, such as standard specimen comparison and stylus profilometry, have limitations in terms of accuracy, speed, and applicability. This study proposes a non-contact measurement method for sand casting surface roughness based on machine vision, combining image processing and convolutional neural networks (CNNs). We trained a residual convolutional neural network integrated with an attention mechanism using surface images of standard roughness blocks and developed detection software. The method achieved an accuracy of 87.5% with a single measurement time of 0.086 s, providing fast and convenient measurement results in actual production. This study offers a significant approach for the rapid, accurate, and convenient measurement of casting roughness in the foundry industry.

Keywords: Machine Learning; Sand Casting; Surface Roughness; Image Processing; Convolutional Neural Network

1. Introduction

With the rapid development of technology, the foundry industry is increasingly becoming an important part of high-end equipment manufacturing, playing a pivotal role in the industrial modernization and equipment manufacturing development of China. Surface roughness, closely related to wear resistance, fatigue strength, and vibration noise, is a vital factor affecting the performance and service life of components. For sand castings, the surface roughness typically ranges from Ra3.2 to Ra50. Traditional measurement methods, such as the standard specimen comparison method, are susceptible to subjective factors, while contact measurement methods like stylus profilometry have limited measurement ranges and are spatially constrained, making them unsuitable for measuring the surface roughness of sand castings. Therefore, there is an urgent need for a means to rapidly, accurately, and conveniently measure casting roughness in actual production.

2. Literature Review

Previous studies have explored the relationship between image features and surface roughness. For example, Dai et al. [7] found a correlation between features such as histogram mean, variance, and kurtosis extracted from casting surface images and surface roughness, achieving automated extraction of surface roughness-related features and confirming the feasibility of calculating surface roughness from captured images. Neural networks, especially convolutional neural networks (CNNs), have been widely used in image recognition, segmentation, and pattern recognition due to their effective utilization of spatial information and reduced number of learnable parameters. Shao [9] constructed a fully connected neural network using extracted surface image features as input parameters and trained it to achieve mapping from casting surface roughness images to surface roughness values. However, these studies have limitations due to the limited number of manually extracted image features and the loss of other important roughness-related information contained in the images. Furthermore, they only focused on the accuracy of dataset recognition without validating on actual castings.

3. Methodology

3.1 Image Acquisition and Preprocessing

Standard specimens for casting surface roughness, in accordance with national standards, were used for surface image acquisition and preprocessing to create the dataset. Images of five roughness grades (Ra3.2 to Ra50) for both steel sand-molded and aluminum-zinc-magnesium die-cast specimens were collected. Image preprocessing involved converting color images to grayscale to improve system operation speed, using the formula:

where f is the grayscale value, and R, G, B represent the red, green, and blue channels, respectively. To address uneven overall brightness during image acquisition due to unilateral side lighting, Contrast Limited Adaptive Histogram Equalization (CLAHE) was used instead of traditional histogram equalization (HE) to enhance image contrast while inhibiting local noise generation. The CLAHE algorithm was applied with clipping limited to 200 and a grid size of 8×8. Median filtering with a filter size of 7 was used for denoising to remove random noise and pulse interference while preserving edge information.

Table 1: Dataset Composition

Dataset CategorySpecimen TypeRa3.2Ra6.3Ra12.5Ra25Ra50Total
Training SetSteel Sand4844924844925042456
Aluminum-Zn-Mg4845164844844922460
Validation SetSteel Sand104104104104104520
Aluminum-Zn-Mg104104104104104520
Test SetSteel Sand100100100100100500
Aluminum-Zn-Mg100100100100100500

3.2 Neural Network Construction and Training

A residual convolutional neural network integrated with the Squeeze-and-Excitation (SE) attention mechanism was constructed based on the ResNet50 architecture. The SE module enhances the representation of important features by globally averaging pooled input feature maps, using two 1×1 convolutional layers and a ReLU layer to learn feature correlations, and generating an attention weight vector through a Sigmoid function. This weight vector is then multiplied by the original feature map. The network was trained using the mixed training set of both specimen types, with the validation sets used to monitor model learning and the test sets used to evaluate model performance.

3.3 Detection Software Development

Based on Python, a surface roughness detection software was developed, capable of capturing real-time images from the image acquisition device, preprocessing the images, and outputting detection results by loading the trained neural network model for single-step computation.

4. Results and Discussion

4.1 Model Performance

During training, the model’s accuracy on the validation sets for both steel sand-molded and aluminum-zinc-magnesium die-cast specimens reached 99.04% and 99.23%, respectively, at 81 epochs. The final model selected achieved recognition accuracies of 99.00% and 99.60% on the two test sets.

4.2 Test Results on Casting Specimens

The detection software was tested on stainless steel pump housing and aluminum alloy volute casing sand castings, with surface roughness mainly distributed in the ranges of Ra3.2 to Ra12.5 and Ra12.5 to Ra50, respectively. A total of 32 test points were selected, with 4 misidentifications, resulting in an overall recognition accuracy of 87.5%. The average inference time for a single image was 0.086 s, demonstrating high recognition accuracy and speed.

Table 2: Test Results of Casting Surface Roughness

Seq. No.Stainless Steel Pump HousingSeq. No.Aluminum Alloy Volute CasingStandard SpecimenSE-ResNet-50Correct?Standard SpecimenSE-ResNet-50Correct?
1Ra6.317Ra50Ra50Ra50YesRa25Ra25Yes
2Ra12.518Ra50Ra50Ra50YesRa12.5Ra12.5Yes
3Ra6.319Ra50Ra50Ra50YesRa50Ra50Yes
4Ra6.320Ra25Ra25Ra25YesRa12.5Ra12.5Yes
5Ra3.221Ra12.5Ra12.5Ra12.5YesRa6.3Ra6.3Yes
6Ra3.222Ra12.5Ra12.5Ra12.5YesRa3.2Ra3.2Yes

To further validate the effectiveness of the proposed method, the trained neural network model was utilized to measure the surface roughness of actual sand-castings. Specifically, stainless steel pump casing castings and aluminum alloy volute casing castings were selected for testing. The surface roughness of these castings was predominantly within the ranges of Ra3.2 to Ra12.5 for the stainless steel pump casing and Ra12.5 to Ra50 for the aluminum alloy volute casing.

For each casting, 16 sampling points were randomly selected across different critical areas, and surface roughness measurements were obtained using both the standard specimen comparison method and the proposed machine vision-based method. A total of 32 measurements were taken, with 4 discrepancies identified between the two methods. Consequently, the overall recognition accuracy of the proposed method was calculated to be 87.5%.

Additionally, the proposed method demonstrated a rapid measurement speed, with an average inference time of 0.086 seconds per image. This rapid response time is crucial for practical applications in the casting industry, where timely and accurate surface roughness measurements are essential for ensuring product quality and reducing production costs.

In conclusion, the machine vision-based surface roughness detection method developed in this study has demonstrated high recognition accuracy and fast measurement speed on both test sets and actual casting specimens. These results suggest that the proposed method has the potential to revolutionize surface roughness measurement in the casting industry by providing a rapid, accurate, and non-contact alternative to traditional measurement techniques.

Scroll to Top