Download PDF
Research Article  |  Open Access  |  24 Mar 2026

Quantification and rating of casting blowhole defects using an instance segmentation algorithm

Views: 243 |  Downloads: 4 |  Cited:  0
J. Mater. Inf. 2026, 6, 14.
10.20517/jmi.2025.77 |  © The Author(s) 2026.
Author Information
Article Notes
Cite This Article

Abstract

Casting blowhole defects seriously affect product quality and performance. Accurate detection, segmentation, and measurement of these defects are essential for quality control. To solve problems such as the varying sizes of blowholes in castings, segmentation uncertainty caused by texture overlap, and the subjectivity of manual rating, this paper proposes a rating strategy for casting blowhole defects based on image instance segmentation results. In the preprocessing stage, contrast-limited adaptive histogram equalization (CLAHE) is applied to enhance defect features. You Look Only Once version 8 (YOLOv8), YOLOv11, YOLOv13, and semantic segmentation models are compared, and YOLOv13 is chosen as the main model for segmentation. Its mean Average Precision (mAP) at an IoU threshold of 0.5 (mAP50) reaches 0.964, showing the best performance. Based on the segmentation results, the pixel area and percentage of the segmented regions are calculated. The actual defect size is then converted using the practical sampling area, and rating is performed according to the GB/T 11346-2018 standard. Validation through manual measurement in Photoshop and physical sectioning confirms that the proposed strategy reduces the maximum error by 17.1% compared with traditional manual rating. The method significantly enhances the automation and accuracy of blowhole defect rating and provides reliable technical support for casting quality control.

Keywords

Blowhole defects, defect rating, instance segmentation algorithm, defect detection and segmentation

INTRODUCTION

In modern industrial production, machine learning-aided material design is transforming traditional research and development (R&D) models. It can accurately predict material properties, optimize composition ratios, and improve molding processes. These capabilities enhance the efficiency of material design and push the performance limits of materials in high-end fields, such as aerospace, automotive manufacturing, and precision instrumentation. Nevertheless, even with intelligent design, defects may still arise during complex production processes due to fluctuations in raw material purity or deviations in process parameters[1,2]. In applications that require extremely high material performance, even minor defects can lead to serious safety hazards and economic losses. Blowhole defects are a common quality problem in the forming of industrial products, including metal castings and composite components. These defects affect the mechanical properties, sealing performance, and service life of materials through their shape, size, and distribution. Therefore, accurate detection and scientific rating of blowhole defects are of significant engineering importance[3,4].

Traditional detection and rating of blowhole defects mainly rely on manual visual inspection or simple image processing techniques. Manual inspection is inefficient and is easily influenced by inspectors’ experience and fatigue, often resulting in missed detections, false detections, and inconsistent rating criteria. Traditional image processing methods usually locate defect positions using edge detection algorithms[5], extract specific defect features with techniques such as local binarization[6] or the curvelet transform[7], and then classify defects via machine learning algorithms, including Support Vector Machines[8] or shallow neural networks[9,10]. These feature extraction methods depend on manual design, so they cannot accurately identify and separate defects when blowholes have irregular shapes, the background has noise, or defects are closely spaced. As a result, significant errors occur in subsequent area measurements and rating results, failing to meet the requirements of high-precision quality control.

The rapid development of computer vision and deep learning has greatly promoted their applications in areas such as material design and casting process optimization[11,12]. Deep learning-based object detection and image segmentation methods have provided a brand-new solution for industrial defect detection. Single-stage network structures, such as the You Only Look Once (YOLO) series[13-17] and Single Shot Multibox Detector (SSD) series[18-20], as well as two-stage network structures, such as faster region-based convolutional neural network (R-CNN)[21,22], have demonstrated excellent performance in defect detection. In particular, Wang et al. proposed an improved steel surface defect detection method based on the YOLO version 7 (YOLOv7) algorithm[23]. They incorporated a bidirectional feature pyramid network (BiFPN) network module and an Efficient Channel Attention (ECA) mechanism into the original structure. In addition, the complete intersection over union (CIoU) loss function was replaced with the Scylla-Intersection over Union (SIoU) loss function. These changes enhanced feature fusion, reduced information loss, and improved computational speed compared to the original model. Guo et al. incorporated a Transformer-based module (TRANS) into YOLOv5 to achieve multi-scale feature fusion[24]. Combined with data augmentation and multi-level training, the method achieved a real-time detection accuracy of 75.2%. Using a unified dataset, the accuracy increased by 7% and 18% compared with YOLOv5 and Faster R-CNN, respectively. Sun et al. improved Faster R-CNN for hub defect detection[25]. They replaced the last pooling and fully connected layers of the region proposal network (RPN) with a sliding convolution layer, added a fully connected layer of depth 256, and finally connected a regression layer to the softmax layer. After training and testing on 412 defect images, the computation times for the original R-CNN and the improved model were 78 and 0.3 s, respectively. The mean Average Precision (mAP) of the improved model reached 72.9%, compared with 67.7% and 70.39% for the original models. Philip et al. investigated the use of transfer learning for concrete crack detection[26]. They employed five pre-trained CNN models, including Visual Geometry Group 16-layer network (VGG16), VGG19, 50-layer residual network (ResNet50), MobileNet, and Xception, and trained them using the Adam optimizer and cross-entropy loss function on datasets integrated from multiple public sources. The experimental results showed that ResNet50 achieved the best performance, with a training accuracy of 99.91%, a testing accuracy of 99.88%, and a relatively short training time. The study demonstrated the effectiveness of transfer learning in this field, reduced the dependence on newly collected large-scale datasets, and provided an efficient and high-precision approach for automated crack detection, offering valuable references for future research on structural health monitoring.

These object detection algorithms can locate defects and identify their categories. However, they have significant limitations in extracting precise contours, making it difficult to meet the requirements of quantitative analysis in industrial defect detection.

Deep learning-based image segmentation has become a key technology for overcoming the limitations of object detection in precise contour extraction. Since Long et al. proposed the Fully Convolutional Network (FCN) model in 2015, it has served as the first classic architecture to apply CNNs to pixel-level prediction, pioneering the use of deep learning for pixel-level image segmentation[27]. Subsequently, researchers have continuously optimized network architectures based on FCN, resulting in representative models such as U-Net[28,29], DeepLab[30], and SegNet[31]. These improved models have been specifically designed to address critical challenges in industrial scenarios, including multi-scale semantic information extraction[32], segmentation in complex backgrounds[30], and small-sized defect segmentation[33]. As a result, they have achieved significant performance improvements[34]. Although U-Net, DeepLab, and SegNet perform well in fine defect segmentation, they share common limitations, such as insufficient real-time performance and poor adaptability to industrial processes. These issues make them less suitable for industrial defect detection than YOLO-based object detection methods[35].

Regarding real-time performance, all three segmentation models rely on complex encoder-decoder architectures and require computations such as transposed convolution and multi-branch feature fusion. Consequently, their inference speeds cannot meet the requirements of high-speed industrial detection. In contrast, YOLO uses a single-stage architecture, removes redundant processing steps, and enables millisecond-level inference, which easily matches production processes. In terms of process adaptability, the core outputs of the three models are pixel-level masks, which require additional post-processing to obtain defect localization information. This contradicts the industrial workflow of “screening first, quantifying later” and reduces efficiency. In contrast, YOLO directly outputs defect localization and category information, thereby fully supporting preliminary defect screening. These limitations prevent segmentation models from performing the preliminary stage of industrial defect detection. YOLO fills this gap and has become the preferred choice for the initial detection stage.

It is worth noting that image segmentation technology includes different technical branches. Semantic segmentation is a basic task that distinguishes different object categories at the pixel level (e.g., separating “defects” from “background”) with the abovementioned models; however, it cannot differentiate between individual objects within the same category. In contrast, instance segmentation algorithms overcome this limitation. They can accurately locate each defect, similar to object detection, and also outline the contours of individual defects of the same category at the pixel level. This capability provides a reliable regional basis for quantitative analysis of defects[36]. This feature gives instance segmentation unique advantages when handling complex industrial images with overlapping or adherent blowholes. It can effectively prevent statistical errors caused by the unclear differentiation of individual defects in traditional methods[37-39], making it an important approach for precise industrial defect detection.

Given the advantages of instance segmentation in defect contour extraction and individual differentiation, as well as the practical need for precise quantitative analysis of blowhole defects, this paper proposes a casting blowhole defect rating strategy based on image instance segmentation results. The proposed strategy focuses on the accurate segmentation and quantitative analysis of blowhole defects using instance segmentation algorithms. Advanced instance segmentation models are employed to achieve pixel-level identification of casting blowhole defects. By assigning unique category labels to each pixel, the method enables automated, high-precision segmentation while capturing complete contour information for each defect instance. Based on these segmentation results, the algorithm calculates the area of each defect and its proportion relative to the total area. This information is then combined with preset defect rating standards to provide objective and accurate ratings of blowhole defects. This approach offers a reliable machine learning-based solution for the intelligent detection and quantitative analysis of casting defects. It improves automation and detection accuracy, reduces uncertainty caused by manual inspection, and provides data support for quality traceability and process optimization. Consequently, it contributes to the advancement of intelligent and digital transformation in industrial quality control.

MATERIALS AND METHODS

Defect image enhancement

The images used in this study were partly obtained from our team’s experimental records and partly from published papers. A total of 264 images containing blowhole defects were collected, each with a resolution of 512 pixels × 512 pixels. Due to the different publication years of the papers, the clarity of some images cannot be guaranteed. To improve image quality, the collected casting defect images were preprocessed. The main steps included Gaussian filtering for noise reduction, adaptive histogram equalization (AHE), and normalization[40]. Gaussian filtering is a commonly used image smoothing technique. It works by convolving the image with a Gaussian function to suppress high-frequency noise. The mathematical equation is:

$$ H(i,j)=\frac{1}{2\pi \sigma ^2}e^{-\frac{i^2+j^2}{2\sigma ^2}} $$

Where H (i, j) represents the value of the Gaussian filter, i and j denote the filter position, and σ is the standard deviation of the Gaussian function. The size of the filter can be controlled by adjusting σ, which allows a balance between noise reduction and the preservation of image details.

Principles of instance segmentation algorithms

Instance segmentation is considered the most challenging task among the four classic computer vision tasks. It shares characteristics with semantic segmentation, requiring pixel-level classification of images, while also incorporating object detection by locating individual instances, even when they belong to the same category. In summary, the main challenge of instance segmentation lies in accurately detecting targets while simultaneously segmenting each instance[36,41].

For segmenting blowhole defect instances, YOLOv8, YOLOv11, and YOLOv13 were introduced for comparison. These three models evolved gradually along the “Backbone-Neck-Head” framework. YOLOv8 introduces the C2f module, removes the convolutional structure of Path Aggregation Network - Feature Pyramid Network (PAN - FPN), and adopts a decoupled head and an anchor-free design. It uses Varifocal Loss (VFLLoss) and Distribution Focal Loss (DFLLoss) + CIoULoss (Complete Intersection over Union Loss) as loss functions and improves training efficiency by freezing layers in pre-trained models[42,43]. YOLOv11 enhances accuracy, speed, and generalization through lightweight modules (C3k2, a lightweight module that adopts small convolution kernels to improve speed and gradient propagation) and an improved attention mechanism (C2PSA, an enhanced attention module to strengthen feature extraction and representation).[44,45]. YOLOv13 introduces the Hyper-dimensional Adaptive Context Enhancement (HyperACE) mechanism to explore the correlations between high-order and low-order features. It also incorporates the Full Pipeline Adaptive Distribution (FullPAD) architecture to improve coordination of information flow and feature representation across the entire pipeline. Additionally, it proposes a lightweight depthwise separable C3k2 (DSC3k2) block, which helps reduce computational cost while maintaining stable model performance[46]. By comparing the segmentation results of these three models, the most suitable method for blowhole defect segmentation was selected based on segmentation accuracy, edge consistency, and real-time performance.

Defect rating principles and rating standards

The blowhole defect segmentation process is developed based on the YOLO instance segmentation algorithm. In this method, defects are detected at the pixel level, and a category label is assigned to each pixel in the image. The output is a mask matrix representing the target object. In this mask, pixels belonging to the defect region are assigned a value of 1, while background pixels are set to 0 or to other predefined categories, as shown in Figure 1.

Quantification and rating of casting blowhole defects using an instance segmentation algorithm

Figure 1. Schematic of defect segmentation and rating tasks.

In this study, the instance segmentation method is applied to obtain the total number of pixels in the target region (Category 1) under the same defect image standard, as well as the ratio of target region pixels to the total image pixels. Accordingly, the pixel area of the target region and its proportion within the image can be determined. The actual area of the target region is then calculated using Equation (2).

$$ \frac{S_{actual\ defect\ area}}{S_{sampling\ area}}=\frac{S_{segmentation}}{S_{resolution}} $$

After calculating the actual defect area, the defect level is determined according to the ranges defined in the rating standard. The defect rating mainly follows the standard GB/T 11346-2018 Radiograpial testing for aluminum alloy castings - Defect levels[47] and the related work of Wu et al.[48]. The corresponding criteria are shown in Table 1.

Table 1

Defect rating standards[48]

Defect Rating standard Level 1 Level 2 Level 3 Level 4 Level 5 Level 6 Level 7 Level 8
Blowhole Rating range
(mm2)
0-7 7-9 9-15 15-24 24-40 40-80 80-144 > 144

RESULTS AND DISCUSSION

Defect image data enhancement and segmentation model screening

For the collected 264 images, LabelMe was used for manual defect annotation. Among these, 254 images were selected for model training, with a training-to-test set ratio of 4:1, and 10 images were used as the validation set.

The statistical results of the defect-labeled images are shown in Figure 2. Figure 2A illustrates the size and relative distribution of defect bounding boxes after center alignment, reflecting the spatial distribution characteristics of different defects. Figure 2B summarizes the size and distribution patterns of the defects. Based on the scatter and density distributions, the relative sizes of most target defects are concentrated within the range of 0-0.20. Considering the ratio between the bounding box and the defect, along with the quantitative data on defect size distribution, it can be concluded that the dataset mainly consists of small-scale casting defect images.

Quantification and rating of casting blowhole defects using an instance segmentation algorithm

Figure 2. Relative size distribution of casting blowhole defects: (A) Size of defect bounding boxes; (B) Defect size distribution.

Due to the complex background textures in casting defect images, the large amount of information extracted from color images causes data imbalance problems. To improve image quality, several image equalization methods were compared and combined with Gaussian filtering and image normalization to enhance local defect features and optimize the defect images.

Histogram equalization transformed the histogram of the original defect image [Figure 3A] from a relatively concentrated grayscale range into a uniform distribution across the entire grayscale range, achieving global equalization [Figure 3B]. This process produced a flatter histogram but reduced the effective grayscale levels and sometimes led to the degradation or even loss of image details.

Quantification and rating of casting blowhole defects using an instance segmentation algorithm

Figure 3. Image preprocessing results[47]: (A) Original image; (B) Histogram equalization; (C) Adaptive histogram equalization; (D) Contrast-limited adaptive histogram equalization. (Reproduced with permission[47]. Copyright 2018, Standardization Administration of China).

The AHE algorithm divides the image into several small blocks, calculates the local histogram of each block, and redistributes the brightness accordingly. This approach is more effective in improving local contrast and preserving fine details in the image [Figure 3C]. The contrast-limited adaptive histogram equalization (CLAHE) algorithm was developed based on AHE. It introduces a threshold to limit the amplitude of the histogram computed for each image sub-block (i.e., contrast limiting), thereby alleviating the problem of noise amplification [Figure 3D]. By comparing different image enhancement methods, the most suitable method for this model was selected. The comparison results are shown in Figure 3.

In the figure, the blowhole in the upper-left corner of the original image exhibits low grayscale contrast, resulting in insufficiently prominent features. Although histogram equalization (HE) stretches the contrast globally, it over-enhances the background texture, making the area around the blowhole appear cluttered and thereby interfering with defect identification. AHE causes excessive noise amplification due to its local enhancement mechanism, producing a strong grainy texture and leading to the blowhole being obscured by background noise. In contrast, CLAHE not only enhances local contrast but also effectively suppresses noise. This improvement makes the grayscale difference between the blowhole and its surrounding area clearer while keeping the background relatively clean. Combined with histogram analysis, CLAHE optimizes the grayscale distribution: it widens the dynamic range while preventing the excessive spread of extreme grayscale values, thereby enabling more accurate highlighting of blowhole defects. Therefore, CLAHE was selected as the preferred image enhancement method.

In defect detection and segmentation tasks, the reasonable selection of instance segmentation models has a decisive impact on detection accuracy and segmentation performance. In this study, image data containing blowhole defects were used, and three mainstream instance segmentation models (YOLOv8, YOLOv11, and YOLOv13) were selected for comparative experiments. During the experiments, all models were trained and validated using the same dataset and configuration environment (epoch = 150, batch size = 10, optimizer = auto, device = 4) to ensure the objectivity and reliability of the comparison results. To comprehensively evaluate the performance of each model, multiple key evaluation metrics were considered. The mAP at an IoU threshold of 0.5 (mAP50), as a core indicator for measuring detection and segmentation accuracy, directly reflects the model’s recognition precision for blowhole defects. The Precision-Recall (P-R) curve illustrates the relationship between precision and recall under different confidence thresholds, allowing analysis of model performance under varying recognition strictness levels. The F1 score, representing the weighted harmonic mean of precision and recall, provided a comprehensive assessment of model robustness.

From the training and validation loss curves in Figure 4A and B, it was observed that as the number of epochs increased, the losses of both the training and validation sets decreased, indicating that the learning capability of the instance segmentation model for blowhole defects progressively improved. As shown in Figure 4C and D, the mAP50 metric exhibited a rapid increase during the initial training stage before stabilizing, suggesting that the model’s high-confidence detection performance was optimized and remained consistent. Similarly, mAP50-95 increased gradually with the number of epochs and then stabilized, indicating that detection performance improved and reached stability across different thresholds. Overall, the detection accuracy of each model converged and stabilized during training, demonstrating excellent convergence and performance.

Quantification and rating of casting blowhole defects using an instance segmentation algorithm

Figure 4. Training results of the instance segmentation model: (A) Training set; (B) Test set; (C) mAP50; (D) mAP50-95. YOLO: You Only Look Once; mAP50: mean Average Precision at an IoU threshold of 0.5.

After comparative analysis, the YOLOv13 model demonstrated a clear advantage in the core evaluation metric. Its mAP50 value reached 0.964, surpassing that of YOLOv8 (0.955) and YOLOv11 (0.941). These results indicate that the iterative upgrades improved detection accuracy. The area under the P-R curve in Figure 5A was larger, showing that the model maintained high accuracy even at high recall levels. As shown in Figure 5B, the F1 curve remained stable across different confidence thresholds, demonstrating consistent and balanced performance. Based on these results, the YOLOv13 model was selected as the final segmentation model, providing a reliable foundation for the subsequent precise segmentation and grading of blowhole defects.

Quantification and rating of casting blowhole defects using an instance segmentation algorithm

Figure 5. Evaluation metrics for instance segmentation models: (A) P-R curve; (B) F1 curve. YOLO: You Only Look Once; P-R: Precision-Recall; F1: F1 score.

Defect segmentation and rating based on X-ray images

Figure 6A-H presents typical image samples of B-group blowhole defects at Levels 1-8 defined in the standard[47]. In this study, an instance segmentation algorithm was employed to accurately segment and quantify the areas of these blowhole defects. The actual defect areas shown in Figure 6, calculated using Equation (3), are summarized in Table 2. Among them, “Defect pixel area” refers to the pixel area of the segmented defect regions obtained from the instance segmentation model; “Defect area/mm2” represents the corresponding actual area; “Prediction results” indicate the defect level predicted by the model; and “Error” denotes the deviation of the predicted defect level from the standard rating. The defect levels were determined by comparing the predicted results with the standard rating criteria specified in Table 1. The results show that the blowhole defect ratings obtained using the instance segmentation algorithm [Table 2] are fully consistent with the standard ratings. These findings demonstrate that the proposed instance segmentation algorithm effectively achieves accurate segmentation, area quantification, and rating of blowhole defects, thereby providing a reliable technical basis for defect detection and evaluation.

Quantification and rating of casting blowhole defects using an instance segmentation algorithm

Figure 6. Defect segmentation and quantification results[47]. (Reproduced with permission[47]. Copyright 2018, Standardization Administration of China).

Table 2

Area quantification and rating results of blowhole defects based on the instance segmentation algorithm

Figure 6A Figure 6B Figure 6C Figure 6D Figure 6E Figure 6F Figure 6G Figure 6H
Defect pixel area 586 969 1,137 1,903 2,615 5,744 9,863 18,043
Defect area/mm2 5.5
(6)
9.2
(9)
10.8
(11)
18.1
(18)
24.9
(25)
54.7
(55)
94.0
(94)
135.49(135)
Prediction results Level 1 Level 2 Level 3 Level 4 Level 5 Level 6 Level 7 Level 7
Error 0 0 0 0 0 0 0 -1

$$ S_{actual\ defect\ area}=\frac{S_{segmentation}}{S_{resolution}}\times S_{actual\ area} $$

Where Ssegmentation is the pixel area of the segmentation region; Sresolution is the total pixel area of the defect image; Sactual area is the total actual sampling area; and Sactual defect area is the actual area of the defect region.

Verification of defect quantification accuracy

To achieve quantitative rating and result verification of blowhole defects, this study constructed a three-level verification system consisting of “model prediction - quantitative comparison - physical measurement”. First, based on the confirmed instance segmentation model, automatic segmentation and rating were performed on defect sample images that comply with relevant standards, as shown in Figure 7. The model accurately identified key parameters, including the number and area of blowholes. These parameters were then combined with preset national standard rating rules to calculate and output the corresponding defect levels (e.g., Level 1, Level 2, and Level 3), effectively automating and standardizing the rating process.

Quantification and rating of casting blowhole defects using an instance segmentation algorithm

Figure 7. Area of blowhole defects manually calculated using Photoshop software[47]. (Reproduced with permission[47]. Copyright 2018, Standardization Administration of China).

Second, a manual quantification method was used for auxiliary verification. Defect sample images that met national standards were processed using Photoshop software. By manually delineating the defect areas, the software automatically calculated the pixel area of the defect, as shown in Figure 7. The results of manual quantification were then compared with the defect areas predicted by the instance segmentation model [Figure 8A], enabling clear identification of the error range between manual measurements and model predictions. According to the calculation data, the error between the defect areas obtained using Photoshop and those predicted by the instance segmentation model remained within 5%, confirming the reliability of the model’s quantification results.

Quantification and rating of casting blowhole defects using an instance segmentation algorithm

Figure 8. Verification of defect quantification accuracy: (A) Quantitative comparison of defect areas (Error bars represent SD); (B) Cross-section of a casting containing blowhole defects; (C) Defect pixel area calculated by the instance segmentation model. SD: Standard deviation.

Finally, the three-level verification loop was completed through physical measurement. Casting samples with typical blowhole defects were selected, and wire electrical discharge machining was used to obtain defect cross-sections. The blowhole defects on the cross-sections were then measured manually using precise measuring tools. As shown in Figure 8B, manual film-based evaluation was conducted on two defects with significantly different sizes. The maximum enclosed areas obtained through manual measurement were 30 and 1.5 mm2, respectively. In contrast, the pixel areas calculated by the instance segmentation model [Figure 8C] were 2,608 and 144. The corresponding actual defect areas, calculated based on Equation 2, were 24.87 and 1.37 mm2, respectively. Compared with the traditional manual maximum boundary quantification method, the errors were reduced by 17.1% and 8.7%, respectively.

This difference arises from the fundamental distinction between the two methods. The instance segmentation model accurately delineates defect contours with pixel-level precision, closely matching the actual defect shapes. In contrast, manual film-based evaluation typically constructs a bounding box based on the maximum length and width of the defect, which may include non-defect regions and thus lead to overestimation of defect areas. These results demonstrate that the instance segmentation model significantly outperforms the traditional manual quantification method in terms of defect contour segmentation accuracy and provides superior accuracy in defect quantification. Furthermore, this approach highlights the core value of the proposed technology in industrial defect detection by achieving both high efficiency and accuracy. Through consistency analysis across the three measurement methods in terms of defect area quantification and rating determination, the reliability of the entire verification system was comprehensively evaluated. Ultimately, the instance segmentation model was confirmed to produce rating results that accurately reflect the actual defect conditions and fully satisfy the requirements of engineering applications.

Performance comparison and applicability analysis of instance segmentation and semantic segmentation

In industrial defect detection and image segmentation tasks, semantic segmentation and instance segmentation are two commonly used approaches, but they differ significantly in their applicability for defect quantification. The primary objective of semantic segmentation is to assign category labels to each pixel, effectively grouping pixels of the same category into a unified region. In contrast, the key advantage of instance segmentation lies in its ability to not only identify defect categories but also distinguish individual instances within the same category, assigning separate contour labels to each blowhole defect.

To identify a segmentation method more suitable for quantifying and rating casting blowhole defects, this study employed the U-Net model for semantic segmentation and the YOLO algorithm for instance segmentation. After 150 epochs, the loss and recall curves of both models converged, as shown in Figure 9.

Quantification and rating of casting blowhole defects using an instance segmentation algorithm

Figure 9. Semantic segmentation and instance segmentation training results: (A) Instance segmentation model; (B) Semantic segmentation model.

For multiple blowhole defects, as shown in Figure 10A, the instance segmentation algorithm accurately delineates the contour of each defect through an optimized boundary prediction mechanism, such as mask-based pixel classification and joint optimization of bounding boxes and masks. The model maintains independent boundaries even for blurred defect edges. In contrast, semantic segmentation focuses on category classification. After processing the images with the U-Net model, a blue mask representing the blowhole regions was obtained (as shown in Figure 10B and C), and the actual area was calculated by counting the number of blowhole defect pixels. This method meets the requirements for macroscopic area statistics in simple scenarios, such as single blowholes. However, in complex cases with multiple defects, semantic segmentation merges them into continuous areas, leading to overlapping errors in area quantification.

Quantification and rating of casting blowhole defects using an instance segmentation algorithm

Figure 10. Blowhole defect segmentation results: (A) Multiple blowhole instance segmentation results; (B) Single blowhole semantic segmentation results; (C) Multiple blowhole semantic segmentation results.

In actual rating, the ability of instance segmentation to distinguish between individual instances provides several advantages. First, it ensures accurate measurement of individual blowhole area, avoiding miscalculations caused by merging multiple defects. Second, it enables precise counting of the number of defects, providing reliable data for rating indicators based on defect density. Third, it captures the morphological characteristics of individual defects, laying the foundation for more detailed defect feature analysis. In the blowhole segmentation and quantification example shown in Figure 10, semantic segmentation identified multiple independent blowholes as a single defect, and the total area of all segmented blowholes was calculated collectively. In contrast, instance segmentation successfully separated each independent blowhole and measured the pixel area of each individual blowhole. This difference directly resulted in a correction of the rating result from “severe defect” to “slight defect”, fully demonstrating the key role of instance segmentation in improving rating accuracy.

In summary, instance segmentation fundamentally solves the “merged labeling” problem of semantic segmentation in multi-defect scenarios. It provides higher-precision contour data for the quantitative analysis of blowhole defects and serves as a key technical foundation for achieving objective and accurate ratings.

CONCLUSIONS

To address the requirements for accurate detection, segmentation, and rating of casting blowhole defects, this study establishes a comprehensive technical framework. The main conclusions are as follows:

(1) In the image preprocessing stage, a comparison of HE, AHE, and CLAHE enhancement methods demonstrates that CLAHE effectively suppresses noise while enhancing the local contrast of blowholes. This improvement provides high-quality image data support for subsequent segmentation tasks.

(2) In the instance segmentation model selection stage, comparative experiments were conducted on YOLOv8, YOLOv11, and YOLOv13 under the same dataset and configuration. The results show that YOLOv13 achieves the best performance in segmentation accuracy, edge consistency, and adaptability to complex backgrounds, with an mAP50 value of 0.964. Therefore, YOLOv13 was selected as the core model for defect segmentation. Based on the defect areas calculated by the model and the rating standards defined in GB/T 11346-2018, automatic classification of blowhole defects into Levels 1-8 was achieved, with results fully consistent with the standard samples. Through a three-level verification system comprising “model prediction - manual quantification comparison - physical measurement”, it was confirmed that the model reduces the area measurement error by up to 17.1% compared with traditional manual boundary methods.

(3) In addition, by comparing the performance differences between semantic segmentation and instance segmentation, this study clarifies the superior capability of instance segmentation in distinguishing individual boundaries in multi-defect scenarios. This approach effectively resolves the area-overlap deviation commonly observed in semantic segmentation and provides high-precision contour data for objective and accurate defect evaluation.

To summarize, the technical solution proposed in this study effectively achieves automated, high-precision detection and rating of casting blowhole defects, providing reliable technical support for the quality evaluation of industrial castings. In future work, two main directions will be pursued. First, the scope of defect detection will be expanded to include more casting defect types, such as cracks, cold shuts, and sand inclusions. A general-purpose defect detection model will be developed through multi-task learning, enabling a single system to perform simultaneous identification and grading of multiple defect types. Second, efforts will focus on promoting real-time industrial deployment of the model. By adapting it to industrial-grade hardware, the model will meet the needs of real-time defect analysis on production lines. In addition, the multi-station adaptability of the system will be enhanced. By dynamically adjusting image acquisition parameters (e.g., exposure and focal length), the system will operate stably under different station conditions, further improving the versatility of the proposed framework and laying a foundation for the intelligent implementation of comprehensive casting quality inspection.

DECLARATIONS

Authors’ contributions

Investigation, writing-original draft, writing-review and editing: Duan Z

Resources, validation, writing-review and editing: Pan Y

Project administration, resources, funding acquisition: Hou H

Methodology, investigation, software, writing, funding acquisition: Zhao Y

Availability of data and materials

The data supporting the findings of this study are available from the corresponding author upon reasonable request.

YOLOv8: https://github.com/ultralytics/ultralytics.

YOLOv11: https://github.com/ultralytics/ultralytics.

YOLOv13: https://github.com/iMoonLab/yolov13.

AI and AI-assisted tools statement

Not applicable.

Financial support and sponsorship

This work was supported by the National Natural Science Foundation of China (Nos. 52375394, 52275390, U23A20628, 52305429) and the Major Project of Science and Technology Project of Shanxi Province (No. 202301050201004).

Conflicts of interest

All authors declared that there are no conflicts of interest.

Ethical approval and consent to participate

Not applicable.

Consent for publication

Not applicable.

Copyright

© The Author(s) 2026.

REFERENCES

1. Zhao, Y.; Xin, T.; Tang, S.; Wang, H.; Fang, X.; Hou, H. Applications of unified phase-field methods to designing microstructures and mechanical properties of alloys. MRS. Bulletin. 2024, 49, 613-25.

2. Li, H.; Zhao, Y.; Song, Z.; et al. Serrated grain boundary modulation inhibits nano cracks propagation in pure magnesium: a phase field crystal and quasi in-situ EBSD study. Acta. Mater. 2025, 301, 121573.

3. Bhatt, P. M.; Malhan, R. K.; Rajendran, P.; et al. Image-based surface defect detection using deep learning: a review. J. Comput. Inf. Sci. Eng. 2021, 21, 1-23.

4. Abbas, M.; Shafiee, M. Structural health monitoring (SHM) and determination of surface defects in large metallic structures using ultrasonic guided waves. Sensors 2018, 18, 3958.

5. Xie, Y.; Li, J.; Tao, Y.; Wang, S.; Yin, W.; Xu, L. Edge effect analysis and edge defect detection of titanium alloy based on eddy current testing. Appl. Sci. 2020, 10, 8796.

6. Yun, J. P.; Choi, D.; Jeon, Y.; Park, C.; Kim, S. W. Defect inspection system for steel wire rods produced by hot rolling process. Int. J. Adv. Manuf. Technol. 2013, 70, 1625-34.

7. Zhang, Y.; Li, T.; Li, Q. Defect detection for tire laser shearography image using curvelet transform based edge detector. Optics. Laser. Technology. 2013, 47, 64-71.

8. Xue-wu, Z.; Yan-qiong, D.; Yan-yun, L.; Ai-ye, S.; Rui-yu, L. A vision inspection system for the surface defects of strongly reflected metal based on multi-class SVM. Expert. Systems. with. Applications. 2011, 38, 5930-9.

9. Ma, G.; Yu, L.; Yuan, H.; Xiao, W.; He, Y. A vision-based method for lap weld defects monitoring of galvanized steel sheets using convolutional neural network. J. Manuf. Process. 2021, 64, 130-9.

10. Westphal, E.; Seitz, H. A machine learning method for defect detection and visualization in selective laser sintering based on convolutional neural networks. Addit. Manuf. 2021, 41, 101965.

11. Zhao, Y. Understanding and design of metallic alloys guided by phase-field simulations. npj. Comput. Mater. 2023, 9, 94.

12. Pei, X.; Pei, J.; Hou, H.; Zhao, Y. Optimizing casting process using a combination of small data machine learning and phase-field simulations. npj. Comput. Mater. 2025, 11, 27.

13. Jung, D.; Oh, Y.; Kim, N. A study on GAN-based car body part defect detection process and comparative analysis of YOLO v7 and YOLO v8 object detection performance. Electronics 2024, 13, 2598.

14. Zhang, Y.; Zhang, H.; Huang, Q.; Han, Y.; Zhao, M. DsP-YOLO: an anchor-free network with DsPAN for small object detection of multiscale defects. Expert. Syst. Appl. 2024, 241, 122669.

15. Xiong, C.; Zayed, T.; Abdelkader, E. M. A novel YOLOv8-GAM-Wise-IoU model for automated detection of bridge surface cracks. Constr. Build. Mater. 2024, 414, 135025.

16. Kou, X.; Liu, S.; Cheng, K.; Qian, Y. Development of a YOLO-V3-based model for detecting defects on steel strip surface. Measurement 2021, 182, 109454.

17. Liu, M.; Chen, Y.; Xie, J.; He, L.; Zhang, Y. LF-YOLO: a lighter and faster YOLO for weld defect detection of X-Ray image. IEEE. Sensors. J. 2023, 23, 7430-9.

18. Liu, J.; Liu, J.; Liu, C.; Wang, Y. 3D dark-field confocal microscopy for subsurface defects detection. Opt. Lett. 2020, 45, 660-3.

19. Ma, C.; Li, Z.; Xue, Y.; Li, S.; Sun, X. High-frequency dual-branch network for steel small defect detection. Arab. J. Sci. Eng. 2024, 50, 7409-21.

20. Zhang, J.; Xu, J.; Zhu, L.; et al. An improved mobileNet-SSD algorithm for automatic defect detection on vehicle body paint. Multimed. Tools. Appl. 2020, 79, 23367-85.

21. Hao, R.; Lu, B.; Cheng, Y.; Li, X.; Huang, B. A steel surface defect inspection approach towards smart industrial monitoring. J. Intell. Manuf. 2020, 32, 1833-43.

22. Liu, W.; Hu, J.; Qi, J. Resistance spot welding defect detection based on visual inspection: improved faster R-CNN model. Machines 2025, 13, 33.

23. Wang, Y.; Wang, H.; Xin, Z. Efficient detection model of steel strip surface defects based on YOLO-V7. IEEE. Access. 2022, 10, 133936-44.

24. Guo, Z.; Wang, C.; Yang, G.; Huang, Z.; Li, G. MSFT-YOLO: improved YOLOv5 based on transformer for detecting defects of steel surface. Sensors 2022, 22, 3467.

25. Sun, X.; Gu, J.; Huang, R.; Zou, R.; Giron Palomares, B. Surface defects recognition of wheel hub based on improved faster R-CNN. Electronics 2019, 8, 481.

26. Philip, R. E.; Andrushia, A. D.; Nammalvar, A.; Gurupatham, B. G. A.; Roy, K. A comparative study on crack detection in concrete walls using transfer learning techniques. J. Compos. Sci. 2023, 7, 169.

27. Long, J.; Shelhamer, E.; Darrell, T. Fully convolutional networks for semantic segmentation. In 2015 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), June 7-12, 2015, Boston, MA, USA; IEEE: 2015; pp 3431-3440.

28. Siddique, N.; Paheding, S.; Elkin, C. P.; Devabhaktuni, V. U-Net and its variants for medical image segmentation: a review of theory and applications. IEEE. Access. 2021, 9, 82031-57.

29. Azad, R.; Aghdam, E. K.; Rauland, A.; et al. Medical image segmentation review: the success of U-Net. IEEE. Trans. Pattern. Anal. Mach. Intell. 2024, 46, 10076-95.

30. Chen, L. C.; Papandreou, G.; Kokkinos, I.; Murphy, K.; Yuille, A. L. DeepLab: semantic image segmentation with deep convolutional nets, atrous convolution, and fully connected CRFs. IEEE. Trans. Pattern. Anal. Mach. Intell. 2018, 40, 834-48.

31. Badrinarayanan, V.; Kendall, A.; Cipolla, R. SegNet: a deep convolutional encoder-decoder architecture for image segmentation. IEEE. Trans. Pattern. Anal. Mach. Intell. 2017, 39, 2481-95.

32. Ronneberger, O.; Fischer, P.; Brox, T. U-Net: convolutional networks for biomedical image segmentation. In Medical Image Computing and Computer-Assisted Intervention - MICCAI 2015; Navab, N., Hornegger, J., Wells, W., Frangi, A., Eds.; Lecture Notes in Computer Science, Vol. 9351; Springer: Cham, 2015.

33. Chen, L. C.; Zhu, Y.; Papandreou, G.; Schroff, F.; Adam, H. Encoder-decoder with atrous separable convolution for semantic image segmentation. arXiv 2018.

34. Akhyar, A.; Asyraf Zulkifley, M.; Lee, J.; et al. Deep artificial intelligence applications for natural disaster management systems: a methodological review. Ecol. Indic. 2024, 163, 112067.

35. Yu, Y.; Wang, C.; Fu, Q.; et al. Techniques and challenges of image segmentation: a review. Electronics 2023, 12, 1199.

36. Tian, D.; Han, Y.; Wang, B.; Guan, T.; Gu, H.; Wei, W. Review of object instance segmentation based on deep learning. J. Electron. Imag. 2021, 31, 041205.

37. Chennupati, S.; Narayanan, V.; Sistu, G.; Yogamani, S.; Rawashdeh, S. A. Learning Panoptic Segmentation from Instance Contours. In 2021 IEEE International Conference on Robotics and Automation (ICRA), Xi’an, China, May 30-June 5, 2021; IEEE, 2021; pp 9586-9593.

38. Yin, C.; Tang, J.; Yuan, T.; Xu, Z.; Wang, Y. Bridging the gap between semantic segmentation and instance segmentation. IEEE. Trans. Multimedia. 2022, 24, 4183-96.

39. Urtans, E.; Bumanis, K.; Vecins, V.; et al. Detection of knots in oak wood planks: instance versus semantic segmentation. In 2022 IEEE 5th International Conference on Big Data and Artificial Intelligence (BDAI), Fuzhou, China, July 8-10, 2022; IEEE, 2022; pp 163-168.

40. Pei, X.; Zhao, Y. H.; Chen, L.; et al. Robustness of machine learning to color, size change, normalization, and image enhancement on micrograph datasets with large sample differences. Mater. Des. 2023, 232, 112086.

41. Minaee, S.; Boykov, Y.; Porikli, F.; Plaza, A.; Kehtarnavaz, N.; Terzopoulos, D. Image segmentation using deep learning: a survey. IEEE. Trans. Pattern. Anal. Mach. Intell. 2022, 44, 3523-42.

42. Vijayakumar, A.; Vairavasundaram, S. YOLO-based object detection models: a review and its applications. Multimed. Tools. Appl. 2024, 83, 83535-74.

43. Hussain, M. YOLOv1 to v8: unveiling each variant-a comprehensive review of YOLO. IEEE. Access. 2024, 12, 42816-33.

44. Rasheed, A. F.; Zarkoosh, M. YOLOv11 optimization for efficient resource utilization. J. Supercomput. 2025, 81, 1085.

45. Wang, Z.; Ding, T.; Liang, S.; Cui, H.; Gao, X. Workpiece surface defect detection based on YOLOv11 and edge computing. PLoS. ONE. 2025, 20, e0327546.

46. Lei, M., Li, S., Wu, Y., et al. Yolov13: real-time object detection with hypergraph-enhanced adaptive visual perception. arXiv 2004, arXiv:2506.17733.

47. National public service platform for standards inforrnation. GB/T 11346-2018 Radiograpial testing for aluminum alloy castings - defect levels. (in Chinese). Available from: https://openstd.samr.gov.cn/bzgk/std/newGbInfo?hcno=7D7A57065BCFDEF9DB686A8477F14661. [Last accessed on 20 Mar 2026].

48. Wu, C.; Hou, M.; Li, M.; et al. Defect rating technology for aluminum casting X-ray flaw detection image based on feature extraction. Spec. Cast. Nonferrous. Alloys. 2024, 44, 605-13. (in Chinese).

Cite This Article

Research Article
Open Access
Quantification and rating of casting blowhole defects using an instance segmentation algorithm

How to Cite

Download Citation

If you have the appropriate software installed, you can download article citation data to the citation manager of your choice. Simply select your manager software from the list below and click on download.

Export Citation File:

Type of Import

Tips on Downloading Citation

This feature enables you to download the bibliographic information (also called citation data, header data, or metadata) for the articles on our site.

Citation Manager File Format

Use the radio buttons to choose how to format the bibliographic data you're harvesting. Several citation manager formats are available, including EndNote and BibTex.

Type of Import

If you have citation management software installed on your computer your Web browser should be able to import metadata directly into your reference database.

Direct Import: When the Direct Import option is selected (the default state), a dialogue box will give you the option to Save or Open the downloaded citation data. Choosing Open will either launch your citation manager or give you a choice of applications with which to use the metadata. The Save option saves the file locally for later use.

Indirect Import: When the Indirect Import option is selected, the metadata is displayed and may be copied and pasted as needed.

About This Article

Disclaimer/Publisher’s Note: All statements, opinions, and data contained in this publication are solely those of the individual author(s) and contributor(s) and do not necessarily reflect those of OAE and/or the editor(s). OAE and/or the editor(s) disclaim any responsibility for harm to persons or property resulting from the use of any ideas, methods, instructions, or products mentioned in the content.
© The Author(s) 2026. Open Access This article is licensed under a Creative Commons Attribution 4.0 International License (https://creativecommons.org/licenses/by/4.0/), which permits unrestricted use, sharing, adaptation, distribution and reproduction in any medium or format, for any purpose, even commercially, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license, and indicate if changes were made.

Data & Comments

Data

Views
243
Downloads
4
Citations
0
Comments
0
0

Comments

Comments must be written in English. Spam, offensive content, impersonation, and private information will not be permitted. If any comment is reported and identified as inappropriate content by OAE staff, the comment will be removed without notice. If you have any queries or need any help, please contact us at support@oaepublish.com.

0
Download PDF
Share This Article
Scan the QR code for reading!
See Updates
Contents
Figures
Related
Journal of Materials Informatics
ISSN 2770-372X (Online)
Follow Us

Portico

All published articles are preserved here permanently:

https://www.portico.org/publishers/oae/

Portico

All published articles are preserved here permanently:

https://www.portico.org/publishers/oae/