Research on Image Simulation of Sand Foundry Defects

Chapter 1: Introduction

1.1 Background and Motivation

In modern manufacturing, the quality assurance of cast components plays a pivotal role in ensuring product reliability and safety. Among various casting technologies, sand casting remains one of the most widely adopted methods for producing complex metal components, particularly in the automotive industry. However, the inherent nature of the casting process introduces various types of defects that can significantly compromise the mechanical integrity of the final product. The presence of sand foundry defects such as shrinkage cavities and porosity represents a critical concern for manufacturers, as these imperfections directly affect the structural performance of cast components.

The detection and characterization of internal defects in castings have traditionally relied on destructive testing methods, which involve cutting and inspecting sample components. This approach, while straightforward, presents several significant drawbacks: it is time-consuming, wasteful, and cannot guarantee the quality of every individual component. The need for a more comprehensive and efficient inspection method has driven the development of non-destructive testing (NDT) techniques, with X-ray inspection emerging as the most promising solution for internal defect detection in castings.

The application of X-ray inspection in the automotive industry, particularly for quality control of wheel hubs and other critical safety components, has gained substantial momentum over the past decades. Modern X-ray inspection systems can be categorized into two main types: conventional film-based radiography and real-time digital radiography. While film-based systems have been widely used historically, they present several limitations including slow inspection speed, inability to perform 100% inspection due to film costs, and the subjective nature of human interpretation of radiographs. Real-time digital radiography systems, on the other hand, offer significant advantages in terms of speed, accuracy, and the ability to implement automated defect recognition algorithms.

The evolution towards intelligent inspection systems represents a paradigm shift in quality control for sand foundry defects. These systems integrate advanced image processing algorithms with X-ray imaging technology to automatically detect, classify, and quantify internal defects. The development of such intelligent systems requires extensive testing and validation, which in turn demands a large repository of defect images. However, acquiring a comprehensive set of real defect images from production lines is often impractical due to time constraints, storage requirements, and the inherent variability of defects encountered in actual production. This challenge has motivated the development of simulation techniques capable of generating realistic synthetic defect images.

1.2 Overview of Non-Destructive Testing Technologies

Non-destructive testing encompasses a broad range of techniques designed to evaluate the properties of materials, components, or systems without causing permanent damage. The five conventional NDT methods widely used in industrial applications include:

Method Principle Advantages Limitations
Ultrasonic Testing Propagation of high-frequency sound waves through the material; reflections from discontinuities reveal defects Deep penetration, high sensitivity, fast results, harmless to operators Requires surface cleaning, difficult for irregular or rough surfaces, limited for very small components
Radiographic Testing X-rays or gamma-rays penetrate the object and produce an image based on differential attenuation Provides visual image of internal defects, suitable for various materials, good for volumetric defects High equipment cost, radiation safety requirements, limited penetration for thick sections
Eddy Current Testing Electromagnetic induction to detect surface and near-surface defects in conductive materials High speed, no contact required, sensitive to small surface cracks Limited to conductive materials, shallow penetration depth
Magnetic Particle Testing Magnetic flux leakage at surface discontinuities attracts magnetic particles Simple, economical, sensitive to surface cracks Only ferromagnetic materials, surface and shallow subsurface defects only
Penetrant Testing Capillary action draws penetrant into surface-opening defects, then revealed by developer Simple, portable, applicable to most materials Surface defects only, requires clean surfaces

For the specific application of detecting internal defects in aluminum alloy wheel hubs, radiographic testing offers distinct advantages. The ability to visualize internal defects directly, combined with the capability to perform quantitative analysis of defect characteristics, makes X-ray inspection the preferred choice. The inherent contrast between defect regions and the surrounding material in X-ray images enables both qualitative assessment of defect type and quantitative measurement of defect dimensions.

1.3 Classification Standards for Sand Foundry Defects

In the context of aluminum alloy wheel hub castings, defects are typically classified into seven categories: gas porosity, high-density inclusions, low-density inclusions, shrinkage porosity, shrinkage cavities, elliptical pinholes, and round pinholes. Each defect category is further graded on a scale of 1 to 8, with grade 1 representing the least severe manifestation and grade 8 the most severe. This classification system provides a standardized framework for quality assessment and facilitates communication between manufacturers, suppliers, and customers regarding defect acceptance criteria.

Shrinkage cavities and shrinkage porosity represent particularly challenging categories of sand foundry defects. Shrinkage cavities are large, concentrated voids that form during the solidification process when molten metal contracts and insufficient liquid metal is available to compensate for the volume reduction. In X-ray images, these defects appear as large, bright regions with irregular, jagged boundaries. Shrinkage porosity, in contrast, consists of numerous small, dispersed voids that also result from solidification shrinkage but manifest as distributed micro-porosity. On radiographs, shrinkage porosity appears as scattered small bright spots, each exhibiting characteristics similar to larger shrinkage cavities.

Chapter 2: Intelligent X-ray Inspection System for Sand Foundry Defects

2.1 System Architecture

The intelligent X-ray inspection system developed in this research represents a comprehensive solution for automated detection of sand foundry defects in wheel hub castings. The system architecture is divided into two main sections: the radiation shielding room housing the front-end components, and the control room containing the back-end processing and analysis systems. This separation ensures operator safety while enabling automated inspection workflows.

The front-end components within the shielding room include:

  • X-ray Source: Generates X-ray radiation with intensity controlled by voltage and current parameters. The intelligent system automatically adjusts these parameters based on the specific component being inspected to achieve optimal image quality.
  • Position Adjustment Mechanism: Enables precise positioning of the X-ray source to accommodate different inspection angles and positions, controlled by signals from the lower computer.
  • Image Intensifier: Converts the invisible X-ray pattern into a visible light image. This component consists of an input conversion screen (typically CsI crystal) that absorbs incident X-rays and converts them to fluorescence, a photoelectric layer that converts fluorescence to electrons, and an output screen that converts electron energy back to visible light.
  • CCD Camera: Captures the intensified image and converts it to a video signal. High-resolution, low-noise CCD cameras are employed to ensure optimal image quality.
  • Signal Processing Circuitry: Processes the analog video signal through amplification and denoising operations.
  • Analog-to-Digital Converter: Converts the processed analog signal to digital format for transmission to the upper computer.
  • Control Circuitry: Manages camera operation and other hardware components under command from the lower computer.
  • Lower Computer: Typically implemented using programmable logic controllers (PLCs), this component manages hardware sequencing and coordinates actions between various mechanical and electronic components.

The back-end control room houses the upper computer system, which serves as the central processing hub for the entire inspection system. The upper computer performs three primary functions:

  1. Hardware Control: Coordinates with the lower computer to manage X-ray source parameters, positioning systems, and image acquisition devices
  2. Image Processing and Defect Recognition: Executes sophisticated image processing algorithms to detect, classify, and quantify defects within the acquired X-ray images
  3. Data Management: Handles image storage, parameter configuration for different workpiece types, and historical data retrieval for quality analysis

The inspection workflow is organized into five distinct operational zones, each with specific functions in the inspection process:

Zone Name Function
Zone 1 Workpiece Preparation Zone Entry point where operators place components on the conveyor system
Zone 2 Centering and Dimension Data Collection Automated centering of components and acquisition of dimensional data through optical cameras
Zone 3 X-ray Inspection Zone Primary defect detection through X-ray imaging with multiple angle acquisition
Zone 4 Defective Component Marking Automatic paint marking of non-conforming components
Zone 5 Inspected Component Sorting Collection and separation of inspected components

2.2 Image Processing Pipeline for Defect Detection

The image processing pipeline for detecting sand foundry defects in X-ray images follows a systematic sequence of operations designed to progressively isolate and characterize potential defect regions. The pipeline is organized as follows:

First, image segmentation divides the acquired X-ray image into distinct regions based on the known distribution characteristics of defects within the wheel hub structure. This segmentation step is critical for several reasons: it reduces the computational burden by limiting processing to the regions of interest, it simplifies the background complexity that could interfere with defect detection, and it enables region-specific algorithm parameterization for optimal detection performance. Different views of the wheel hub—such as spoke images, rim images, and hub images—require different processing strategies due to their distinct structural characteristics.

Second, image preprocessing enhances the quality of the segmented images through contrast stretching and noise reduction operations. Contrast stretching maps the narrow gray level range containing defect information to a wider range, thereby enhancing the contrast between defects and their surrounding background. This operation also serves to standardize image characteristics, allowing fixed detection parameters to be applied across different inspection scenarios. The noise reduction step is essential for eliminating spurious signals that could interfere with defect extraction; this is where the diffusion-based filtering techniques described in Chapter 3 come into play.

Third, defect extraction identifies potential defect regions through a multi-step process:

The first step employs Laplacian of Gaussian (LoG) edge detection to identify closed contours that may represent defect boundaries. The LoG operator combines Gaussian smoothing with Laplacian edge detection, providing adjustable noise suppression while identifying zero-crossing points that correspond to edge locations. The mathematical formulation of the LoG operator is:

$$LoG(x,y) = -\frac{1}{\pi\sigma^4}\left(1 – \frac{x^2 + y^2}{2\sigma^2}\right)e^{-\frac{x^2 + y^2}{2\sigma^2}}$$

where $\sigma$ controls the degree of smoothing applied before edge detection.

The second step involves finding all closed regions within the edge map. Theoretically, all genuine defects should exhibit closed boundaries; therefore, this operation identifies all closed contours as potential defect candidates. The region-filling algorithm employed for this purpose is computationally efficient, which is crucial for real-time inspection. The third step is region truncation, which separates elongated closed contours into smaller segments at one-pixel-wide bottlenecks. This operation does not compromise defect detection accuracy but significantly improves the discrimination between genuine and false defects. The final step is candidate region filtering, which uses two key criteria to distinguish genuine defects from noise artifacts:

  • Local Contrast: The average gray level within each candidate region is compared to that of its immediate surroundings. If the relative difference exceeds a preset threshold (typically around 1.015), the region is retained for further analysis; otherwise, it is rejected as a false defect.
  • Strong Edge Percentage: This criterion leverages the observation that genuine defect boundaries exhibit strong edge responses across a significant portion of their perimeter. The strong edge percentage is defined as the proportion of strong edge points along a closed contour, where strong edge points are zero-crossings in the LoG response that exceed a specified gradient threshold.

Fourth, defect analysis computes statistical parameters for each detected defect, including area, diameter, and spatial density. These parameters serve as inputs for the final classification step. Fifth, component classification determines whether the inspected component meets quality standards by comparing the computed defect statistics against established acceptance criteria.

2.3 Convex Hull Algorithm for Defect Diameter Calculation

Accurate measurement of defect diameter is a critical aspect of defect characterization, as this parameter directly influences the severity assessment of sand foundry defects. The diameter of an irregularly shaped defect is defined as the maximum distance between any two points on the defect boundary. While the definition is straightforward, computing this parameter efficiently presents computational challenges, particularly when numerous defects must be analyzed in real-time applications.

The traditional approach to calculating the diameter of irregular shapes involves computing the distance between every pair of boundary points and selecting the maximum value. For a defect boundary containing $n$ points, this requires:

$$C(n,2) = \frac{n(n-1)}{2}$$

distance computations, which becomes prohibitively expensive for defects with complex boundaries containing hundreds of edge points.

However, geometric reasoning reveals a key insight: the two points that define the defect diameter must both lie on the convex hull of the defect. The convex hull of a point set $S$ is defined as the minimal convex polygon that contains all points in $S$. Points interior to the convex hull cannot define the maximum distance because at least one convex hull vertex must be farther from any other hull vertex than any interior point could be.

The Graham scan algorithm provides an efficient method for computing the convex hull with computational complexity $O(n \log n)$. The algorithm proceeds as follows:

  1. Identify the point with the minimum y-coordinate (and leftmost among ties), denoted as $p_1$, which is guaranteed to be a convex hull vertex
  2. Sort the remaining points by polar angle relative to $p_1$ in counterclockwise order
  3. Initialize a stack with the first three points $p_1, p_2, p_3$
  4. For each subsequent point $p_i$, determine whether the turn formed by ($p_{top-1}$, $p_{top}$, $p_i$) is a left turn or right turn:
    • While the turn is not a left turn, pop the stack top
    • Push $p_i$ onto the stack
  5. After processing all points, the stack contains the convex hull vertices

The left-turn test for three points $p_0(x_0,y_0)$, $p_1(x_1,y_1)$, and $p_2(x_2,y_2)$ is efficiently computed using the determinant:

$$A(T) = \begin{vmatrix} x_0 & y_0 & 1 \\ x_1 & y_1 & 1 \\ x_2 & y_2 & 1 \end{vmatrix}$$

If $A(T) > 0$, point $p_2$ is strictly to the left of the directed line from $p_0$ to $p_1$, indicating a left turn. If $A(T) = 0$, the points are collinear. If $A(T) < 0$, a right turn is indicated.

Once the convex hull vertices are identified, the defect diameter is calculated as the maximum distance between any pair of hull vertices. Since the number of convex hull vertices is typically much smaller than the total number of boundary points, this approach dramatically reduces the computational cost while guaranteeing accurate results.

Chapter 3: Image Denoising Using Diffusion-Based Techniques

3.1 Noise Models in X-ray Imaging

X-ray images acquired during inspection of sand foundry defects are subject to various types of noise that degrade image quality and interfere with defect detection algorithms. Understanding the statistical characteristics of these noise sources is essential for developing effective denoising strategies. The primary noise types encountered in X-ray imaging include:

Additive noise is independent of the image signal and can be modeled as:

$$g(x,y) = f(x,y) + n(x,y)$$

where $g$ is the observed image, $f$ is the clean image, and $n$ is the noise. The most common statistical model for additive noise is Gaussian noise with probability density function:

$$p(n) = \frac{1}{\sqrt{2\pi\sigma^2}}e^{-\frac{(n-\mu)^2}{2\sigma^2}}$$

Multiplicative noise is signal-dependent and can be modeled as:

$$g(x,y) = f(x,y) \cdot n(x,y)$$

This type of noise is particularly problematic because its magnitude scales with the local signal intensity, making it difficult to distinguish from genuine image features. Quantization noise arises from the conversion of continuous analog signals to discrete digital values and is related to the quantization step size. Salt-and-pepper noise, also known as impulse noise, appears as random white or black pixels in the image and is often caused by defects in the sensor array or transmission errors.

3.2 Partial Differential Equation Models for Image Denoising

Partial differential equation (PDE) based methods have emerged as powerful tools for image denoising, offering an elegant mathematical framework that naturally integrates smoothing with feature preservation. The fundamental concept underlying these methods is to view the image as a continuous function $u(x,y,t)$ that evolves over time $t$ according to a diffusion-type PDE. The solution at an appropriate stopping time provides the denoised image.

The simplest PDE-based denoising approach is derived from the heat equation:

$$\frac{\partial u}{\partial t} = \Delta u = \frac{\partial^2 u}{\partial x^2} + \frac{\partial^2 u}{\partial y^2}$$

$$u(x,y,0) = u_0(x,y)$$

where $u_0$ is the initial noisy image. The solution of this equation is equivalent to convolving the initial image with a Gaussian kernel having variance $\sigma = \sqrt{2t}$:

$$u(x,y,t) = u_0(x,y) * G_{\sqrt{2t}}(x,y)$$

While this isotropic diffusion effectively reduces noise, it also blurs edges and other important image features because the diffusion coefficient is constant in all directions. The heat equation cannot distinguish between noise fluctuations and genuine edges, treating both identically.

To address this limitation, Perona and Malik proposed a nonlinear anisotropic diffusion model in 1990, which represents a landmark contribution to the field. Their model is:

$$\frac{\partial u}{\partial t} = \text{div}\left[c(|\nabla u|)\nabla u\right]$$

where the diffusion coefficient $c(\cdot)$ is a non-negative decreasing function of the gradient magnitude. Two commonly used forms of the diffusion coefficient are:

$$c(|\nabla u|) = \exp\left[-\left(\frac{|\nabla u|}{\beta}\right)^2\right]$$

$$c(|\nabla u|) = \frac{1}{1 + \left(\frac{|\nabla u|}{\beta}\right)^2}$$

where $\beta$ is a threshold parameter that controls the diffusion behavior. In regions where the gradient is small (flat areas), the diffusion coefficient is large, promoting strong smoothing. Conversely, at edges where the gradient is large, the diffusion coefficient becomes small, preserving edge sharpness. This adaptive behavior enables the P-M model to achieve noise removal with significantly better edge preservation compared to linear diffusion methods.

However, the P-M model has limitations. The gradient information is inherently corrupted by noise in the early iterations, affecting edge detection accuracy. Furthermore, while diffusion is suppressed at edges, noise near these edges is not effectively removed. Subsequent research has addressed these issues through various enhancements, including coherence-enhancing diffusion and diffusion tensor approaches.

3.3 Improved Diffusion Model with Time-Delay Regularization

The enhanced diffusion model employed in this research combines the advantages of both isotropic and geometric diffusion through a formulation based on diffusion tensors and time-delay regularization. The model is formulated as:

$$\frac{\partial u}{\partial t} = \text{div}(L\nabla v) – \lambda(u – u_0)$$

$$v_t + \tau v = \nabla u_{\sigma}$$

where $u_0$ represents the initial image and $v$ is a time-delay adjusted version of $u$. The parameter $\tau$ controls the temporal averaging, and $u_{\sigma} = G_{\sigma} * u$ denotes the image convolved with a Gaussian kernel. The matrix $L$ is an $2 \times 2$ diffusion tensor that controls both the speed and direction of diffusion.

The time-delay equation can be solved explicitly as:

$$v(t) = \frac{t}{\tau}e^{-t/\tau} \int_0^t u(s,x) e^{s/\tau} ds$$

This formulation applies temporal averaging to the gradient information, effectively smoothing the gradient estimates and reducing noise-induced spurious edge responses.

For the diffusion tensor $L$, we can construct a symmetric positive semi-definite matrix with eigenvectors aligned with gradient and isophote directions. Specifically, we define $L$ with orthonormal eigenvectors $w_1$ and $w_2$:

$$w_1 = \frac{\nabla u_{\sigma}}{|\nabla u_{\sigma}|}, \quad w_2 = \frac{\nabla u_{\sigma}^{\perp}}{|\nabla u_{\sigma}^{\perp}|}$$

where $w_1$ aligns with the gradient direction and $w_2$ aligns with the level set direction (perpendicular to gradient). The corresponding eigenvalues $\lambda_1$ and $\lambda_2$ control the diffusion strength in each direction. By choosing $\lambda_1$ to be small and $\lambda_2$ to be larger, diffusion is primarily directed along edges rather than across them, achieving simultaneous denoising and edge preservation.

An important practical consideration is the stopping criterion for iteration. In this work, we employ a correlation-based optimal stopping approach, which monitors the correlation between the evolving image and the original noisy image during iterations. When this correlation begins to increase after a minimum point, the optimal iteration number has been reached, preventing over-smoothing artifacts.

3.4 Experimental Evaluation of Denoising Performance

To evaluate the denoising performance of the proposed diffusion-based approach for sand foundry defects, we conducted comparative experiments using several state-of-the-art denoising algorithms including NL-Means, BM3D, and the classical P-M model. The comparison criteria included visual quality, preservation of defect characteristics, and computational efficiency.

Method Processing Time (s) Visual Quality Defect Preservation Noise Reduction
PDE (time-delay + tensor) 0.62 (20 iter) Good Excellent Good
P-M Model 0.45 (7 iter) Moderate Good Moderate
NL-Means 1.38 Excellent Poor Excellent
BM3D 35.0 Excellent Poor Excellent

Results demonstrate that while NL-Means and BM3D achieve excellent noise reduction, they significantly degrade the visibility of subtle defect features that are critical for automated detection of sand foundry defects. The defect regions become nearly invisible in the denoised images, potentially causing missed detections in the automated inspection pipeline. Moreover, the computational complexity of BM3D makes it unsuitable for real-time inspection applications.

In contrast, the proposed diffusion-based approach effectively removes noise while maintaining the critical characteristics of defect regions. This is particularly important for defects with low contrast against the background, where excessive smoothing could eliminate the subtle gray level differences that indicate the presence of a defect. Furthermore, experimental evaluations on actual wheel hub X-ray images demonstrated that the improved denoising performance translates directly into more accurate and complete defect detection, with fewer missed detections and false positives compared to conventional filtering techniques.

Chapter 4: Simulation of Shrinkage Cavity and Porosity in X-ray Images

4.1 Introduction to Defect Simulation

The development and evaluation of automated defect detection algorithms for sand foundry defects require comprehensive testing using images containing a wide variety of defect types, sizes, and severity levels. While collecting defect images from real production lines provides the most authentic test data, this approach has significant practical limitations. The acquisition of a representative defect dataset requires extensive time and storage resources, and the resulting dataset may not cover all possible defect variations. Moreover, when new product types are introduced, additional image collection campaigns are necessary to validate algorithm performance for the new product geometry.

Defect simulation techniques address these challenges by generating synthetic defect images that faithfully reproduce the characteristics of real defects. The simulated images can be generated on-demand with precise control over defect parameters such as size, shape, density, and location, providing unlimited test samples without the constraints of production line sampling.

The general approaches to defect simulation in casting inspection can be categorized into two main classes: invasive methods and non-invasive methods. Table 4.1 summarizes the characteristics of these approaches.

Method Type Approach Description Advantages Disadvantages
Invasive Drilling Physical creation of holes on the object surface Authentic X-ray imaging, real defect images Cannot create crack-type defects, requires X-ray system
Spherical hole Combining two parts with internal holes Real internal defects Destroys the object, no cracks, requires X-ray system
Non-invasive Template superposition Multiplying gray levels by a factor to modify image Real object image, simple implementation Requires X-ray system, limited defect types
Full CAD simulation Simulating entire X-ray system with CAD model No X-ray system needed, full 3D control Complex software, time-consuming
Defect CAD simulation Simulating only defects and superimposing on real images Real object X-ray, efficient, 3D defect models Complex software, requires X-ray system

Among the non-invasive methods, the template superposition approach offers the most favorable trade-off between simplicity and practical utility. This method involves superimposing idealized defect shapes with appropriate gray level modifications onto real X-ray images. However, the resulting defects often lack the natural irregularity and diversity of genuine sand foundry defects, limiting their utility for algorithm testing.

4.2 Gray Level Distribution Characteristics of Wheel Hub X-ray Images

To develop realistic defect simulation algorithms, a thorough understanding of the gray level distribution characteristics in wheel hub X-ray images is essential. This understanding guides the selection of appropriate background regions for defect placement and ensures that simulated defects blend naturally with the surrounding image content.

Local gray level characteristics: Within small regions of approximately $100 \times 100$ pixels (excluding boundaries, defects, and text), the gray level variation in wheel hub X-ray images is generally minimal. Statistical analysis of such regions reveals that gray levels typically fall within a narrow range (e.g., 131-140), with the pixel count distribution across gray levels being relatively uniform. This uniformity reflects the homogeneous material composition and consistent thickness of the wheel hub structure in localized areas.

Global gray level characteristics: On a larger scale, wheel hub X-ray images exhibit systematic gray level variations that correspond to structural features. For example, in the outer diameter region of the hub, the image gray level shows periodic bright-dark variations along the circumferential direction due to the rotational symmetry of the wheel structure. Similarly, in the rim region, alternating bright and dark fine stripes are observed, reflecting the periodic structural elements in that area.

These gray level distribution characteristics have important implications for defect simulation. When generating synthetic defects, it is essential to select background regions with appropriate local statistics to ensure that the simulated defects appear natural and are detected by the algorithm with expected characteristics.

4.3 Characteristics of Shrinkage Cavity and Porosity Defects

Shrinkage cavities and porosity, two common categories of sand foundry defects, result from the volumetric contraction that occurs during the solidification of molten metal. When the solidification process is not adequately compensated by liquid metal flow, voids form within the casting. These defects exhibit distinct radiographic characteristics that serve as criteria for their classification and quantification.

Shrinkage cavities are characterized as large, concentrated voids with high volumetric extent. In X-ray images, they appear as large, intensely bright regions with irregular boundaries that show no consistent geometric pattern. The perimeter of these defects meanders without predictable direction, reflecting the complex thermal and flow phenomena during solidification. In engineering practice, the severity of shrinkage cavities is quantified by the diameter of their circumscribed circle.

Shrinkage porosity, in contrast, consists of numerous small, dispersed voids distributed throughout a region of the casting. On radiographs, shrinkage porosity manifests as scattered small bright spots, each exhibiting morphological characteristics similar to shrinkage cavities but on a much smaller scale. The severity of shrinkage porosity is quantified by the defect density, defined as the ratio of total defect area to the containing region area.

4.4 Simulation Algorithm for Shrinkage Cavities

The simulation of shrinkage cavities follows a systematic procedure consisting of four main stages: template construction, defect shape generation, defect size adjustment, and gray level assignment. The overall workflow is illustrated in the following process.

Stage 1: Template Construction

To ensure that simulated defects exhibit the irregular morphology of genuine shrinkage cavities, we employ a nested template approach. Three templates of different sizes and shapes are designed, with the constraint that when their centers are aligned, the white region of each template is contained within the white region of the next larger template. The template size is set to $78 \times 46$ pixels to match the maximum defect area required by the application. For each template $i$ ($i = 1, 2, 3$), the corresponding base pixel image $f_i’$ is extracted from the original X-ray image at the desired defect location.

Stage 2: Defect Shape Generation

The shape of the simulated defect is extracted from the base pixel image using an adaptive thresholding approach. Let $e_i$ denote the mean gray level of the base pixel image $f_i’$ corresponding to template region $p_i$. By selecting an appropriate value for $x_i \in (0,1)$, we can identify pixels with gray levels exceeding $(1 + x_i)e_i$. These pixels typically form continuous clusters resembling shrinkage cavity morphology.

To improve robustness against gray level non-uniformity and to simulate the growth behavior of shrinkage cavities, the threshold incorporates a spatial coordinate term:

$$f(x,y) = \begin{cases} 1, & \text{if } f'(x,y) \geq (1 + x_i)e_i – \lambda\sqrt{x_m^2 + y_n^2} \\ 0, & \text{otherwise} \end{cases}$$

where $x_m$ and $y_n$ are the spatial coordinates relative to the template center, $\sqrt{x_m^2 + y_n^2} \in [1.414, \, 90.554]$ for the given template size, and $\lambda$ is a weighting factor balancing the relative contributions of gray level and spatial position.

Stage 3: Defect Size Determination

The combined three-layer defect shape obtained from Stage 2 may not have the exact diameter required by the application specification. To adjust the defect size while preserving its shape characteristics, we employ nearest-neighbor interpolation for image scaling. The goal of scaling is to transform the source image to a target image with the desired dimensions:

For scaling to a new size, the pixel coordinates in the target image are mapped back to the source image coordinates, and the corresponding pixel values are determined. Nearest-neighbor interpolation, while producing images with slightly rougher edge characteristics, is preferred in this application due to its minimal computational cost and its ability to preserve the rough, irregular boundary characteristics that are typical of shrinkage cavities.

Stage 4: Gray Level Assignment

The final stage assigns appropriate gray levels to the simulated defect region. Based on observations of real sand foundry defects, the gray level of shrinkage cavities is typically 5-10 gray levels brighter than the surrounding local background. Moreover, the central portion of a shrinkage cavity tends to be brighter than its periphery. To model this characteristic, we employ a graduated gray level assignment strategy:

Region Gray Level Increment
Outermost layer ($p_3$) $a_3 \in [5, 10]$
Middle layer ($p_2$) $a_3 + a_2$, where $a_2 \in [3, 5]$
Core layer ($p_1$) $a_3 + a_2 + a_1$, where $a_1 \in [3, 5]$

After gray level assignment, a linear diffusion process is applied to the defect region to achieve natural gray level transitions between the defect and its background, eliminating any artificial discontinuity that might betray the synthetic nature of the defect.

4.5 Simulation Algorithm for Shrinkage Porosity

The simulation of shrinkage porosity follows a distinct procedure optimized for the dispersed, small-scale nature of these defects. The algorithm comprises five stages: base pixel selection, dispersed pixel extraction, morphological dilation, density adjustment, and gray level assignment.

Stage 1: Base Pixel Selection

For shrinkage porosity, a single template (template 3 from the shrinkage cavity case) is employed to extract the base pixel image $f’$. Since porosity defects are distributed across a wider area with relatively uniform brightness, the extraction approach differs from the cavity case.

Stage 2: Dispersed Pixel Extraction

To extract pixels suitable for forming dispersed porosity defects, we first transform the base pixel image to equalize gray level distribution across spatial locations:

$$f'(x,y) = f'(x,y) \times [1 + \sin(\sqrt{x_m^2 + y_n^2})]$$

This transformation exploits the oscillatory and periodic properties of the sine function to alter gray levels in a spatially varying manner, promoting more uniform dispersion of the extracted pixels. After this transformation, pixels satisfying the condition $|f'(x,y) – e_s| < v$ are selected, where $e_s$ is the mean gray level of the transformed base image and $v$ is a threshold parameter (typically 0.5 to 3). This criterion identifies pixels whose gray levels deviate from the local mean by less than the threshold, ensuring that they are representative of the local background characteristics.

Stage 3: Morphological Dilation

The dispersed pixels extracted in Stage 2 appear as small isolated spots. To create connected regions with the appearance of micro-porosity, morphological dilation is applied. A disk-shaped structuring element with radius $R$ (typically 4-6 pixels) is chosen to match the approximately circular shape of individual porosity cavities:

$$D = A \oplus S$$

where $A$ is the binary dispersed pixel image, $S$ is the disk structuring element, and $\oplus$ denotes the dilation operation. The dilation expands each pixel into a circular region whose size is controlled by the structuring element radius.

Stage 4: Density Adjustment

The density of the dilated porosity pattern often exceeds the user-specified requirement. To achieve the target density while preserving the morphological characteristics of the porosity, we implement an edge-preserving density reduction algorithm. The procedure works as follows:

  1. Compute the initial defect density $M_0$ and determine the required reduction ratio:

$$r = \frac{M_0 – M_1}{M_0}$$

where $M_1$ is the target defect density.

  1. Identify all connected regions in the defect image. For a region $u$ containing $A_u$ pixels, the number of pixels to be removed is:

$$T_u = A_u \times r$$

  1. Apply iterative erosion with a $3 \times 3$ cross-shaped structuring element to remove the outermost pixels of each region:

$$E_k = \Omega_u^{k-1} \ominus S_{cross}$$

where $\Omega_u^k$ represents the region $u$ after $k$ erosion iterations, and $\ominus$ denotes morphological erosion.

  1. After the cumulative number of removed pixels $Z_T$ reaches or exceeds $T_u$, calculate the excess removal:

$$t = Z_T – T_u$$

and randomly select $t$ pixels from the last erosion boundary $b_l$ to be restored to the eroded region:

$$\Omega_u^{final} = E_k \cup \{t \text{ random pixels from } b_l\}$$

This “erosion with pixel restoration” strategy ensures the defect density achieves the target while minimizing shape distortion.

Stage 5: Gray Level Assignment

For shrinkage porosity, gray level assignment is straightforward. Since individual porosity defects are small with minimal internal gray level variation, the gray level of each defect region is uniformly increased by 5-10 gray levels relative to the local background. This uniform increment is consistent with the radiographic appearance of real porosity defects.

4.6 Experimental Results and Analysis

The proposed simulation algorithms were implemented in MATLAB and evaluated on a dataset of wheel hub X-ray images. The experimental setup used the following parameter values: for shrinkage cavity generation, $\lambda = 0.5$, $x_1 = 0.6$, $x_2 = 0.65$, and $x_3 = 0.68$; for shrinkage porosity generation, $v = 1.5$ and structuring element radius $R = 5$ pixels.

We generated 200 shrinkage cavity defects and 200 shrinkage porosity defects on various wheel hub X-ray images at different locations. For the cavity generation experiments, the user-specified diameter $D_1$ was 55 pixels; for porosity generation, the user-specified density $M_1$ was 0.0027.

Defect realism evaluation

Qualitative evaluation of the simulated defects revealed excellent visual similarity to genuine sand foundry defects. All generated cavities exhibited irregular boundaries and varied shapes, confirming the diversity requirement was satisfied. The gray level transitions between defects and their backgrounds were smooth and natural, without the artificial discontinuities often observed in simpler template-based approaches. Factory experts in casting quality validated the realism of the simulated defects, confirming their suitability for algorithm testing purposes.

Quantitative accuracy evaluation

To quantify the accuracy of diameter control for simulated shrinkage cavities, experiments were conducted for 74 user-specified diameters $D_1$ ranging from 7 to 80 pixels. Similarly, for porosity density control, 80 user-specified density values $M_1$ ranging from 0.0009 to 0.09 were tested. For each parameter value, over 40 wheel hub images were processed, with defects generated at five different locations per image.

The experimental results showed:

Defect Type Parameter Range Tested Typical Error Maximum Error
Shrinkage Cavity Diameter $D_1$ (pixels) 7 – 80 < 3% 9%
Shrinkage Porosity Density $M_1$ 0.0009 – 0.09 < 2% 7%

These accuracy levels satisfy the practical requirement that the relative error between the simulated defect parameter and the user-specified value should not exceed 10%.

Integration with defect detection algorithms

A critical validation of the simulation approach is the performance of defect detection algorithms on simulated images. Using the defect detection pipeline described in Chapter 2, we successfully detected both real and simulated defects. The detection algorithm processed simulated sand foundry defects with comparable performance to real defects, confirming that the simulation technique produces images that are suitable substitutes for real defect images in algorithm evaluation contexts.

This integration capability has significant practical implications. First, it enables systematic testing of detection algorithms across a comprehensive range of defect parameters, ensuring robust performance for the full spectrum of defect severity levels. Second, it dramatically reduces the data collection burden for algorithm development, as synthetic defect images can be generated on demand without requiring production line sampling. Third, it supports algorithm optimization by enabling controlled parameter variations that would be difficult to achieve with heterogeneous real-world defect samples.

Conclusion and Future Directions

This research has addressed several critical aspects of automated detection and simulation of sand foundry defects in X-ray inspection of castings. The work encompasses three main contributions:

First, we proposed a convex hull-based algorithm for efficient computation of defect diameter in irregularly shaped defects. Traditional approaches to computing the maximum distance between any two boundary points scale quadratically with the number of boundary points, making them computationally expensive for defects with complex boundaries. By exploiting the geometric property that the diameter-defining points must lie on the convex hull of the defect, our approach reduces the computational complexity while maintaining accuracy. Experimental results confirm that the method rapidly and accurately measures defect diameters across diverse defect morphologies.

Second, we implemented and evaluated a diffusion-based image denoising technique incorporating time-delay regularization and diffusion tensor concepts. This approach achieves effective noise reduction while preserving the fine structural details of defects that are essential for reliable detection. Comparative evaluations demonstrated the superiority of this method over conventional filtering approaches for X-ray images of wheel hub castings containing sand foundry defects, particularly in terms of maintaining defect visibility while suppressing background noise.

Third, we developed comprehensive simulation algorithms for two major defect categories: shrinkage cavities and shrinkage porosity. These algorithms leverage the spatial characteristics of real X-ray images to generate synthetic defects with authentic morphology, realistic gray level distributions, and precise parameter control. The experimental validation demonstrates that the simulated defects closely approximate the appearance of genuine defects, with parameter errors well within acceptable bounds. The successful integration of the simulation approach into the defect detection pipeline confirms its practical utility for algorithm testing and optimization.

Future research directions could explore several promising avenues. Extension of the simulation methodology to other defect types, such as gas porosity, inclusions, and cracks, would further enhance the applicability of the approach. Additionally, the development of more sophisticated defect models that incorporate the physics of X-ray attenuation could improve the realism of simulated images. Integration of the simulation framework with automated parameter optimization could facilitate self-tuning inspection systems that adapt to new product types with minimal human intervention.

In conclusion, the techniques developed in this research contribute to the advancement of intelligent inspection systems for cast components, addressing both the computational challenges of real-time defect characterization and the data acquisition bottlenecks that limit algorithm development and optimization. The demonstrated capabilities for realistic defect simulation open new possibilities for systematic evaluation and continuous improvement of automated inspection technologies for sand foundry defects.

Scroll to Top