Shrinkage Cavity Casting Defect Image Generation

I study the generation of synthetic images for shrinkage cavity casting defects because automated casting defect detection systems require large, diverse, and well-annotated training samples. In industrial X-ray inspection, a casting defect such as a shrinkage cavity is a common internal discontinuity that can reduce mechanical performance, fatigue life, and safety. However, real casting defect samples are often scarce, imbalanced, and expensive to collect. Therefore, I propose a multi-stage algorithm that generates realistic shrinkage cavity casting defect images and fuses them into real X-ray backgrounds. The method combines an improved Diamond-Square algorithm, gray-level mapping, histogram equalization, modified Otsu thresholding, gray stretching, Gaussian filtering, and pixel-level image fusion. I evaluate the generated casting defect images by comparing their gray-level and texture features with those of real shrinkage cavity casting defect images, and I further verify them with a deep-learning-based casting defect detector.

Background and Industrial Motivation

Casting is one of the most economical and flexible manufacturing processes. It can produce complex shapes, can use many types of metals, and often requires fewer processing steps than alternative methods. In automotive and heavy-equipment manufacturing, castings are widely used for wheels, engine blocks, housings, and structural components. Because casting defect formation is influenced by pouring temperature, mold filling capacity, solidification rate, alloy composition, and mold design, some level of casting defect occurrence is difficult to eliminate completely. A casting defect can appear on the surface or inside the material, and internal casting defects are especially difficult to detect by visual inspection. For this reason, X-ray imaging is widely used for non-destructive casting defect inspection. In an X-ray image, a casting defect appears as a region whose intensity differs from the surrounding material because the defect has different density or thickness. The contrast between a casting defect and its background can be described by the relation

$$ \frac{\Delta I}{I} = \frac{\mu \Delta T}{1+n} $$

where \(\Delta I/I\) is the object contrast, \(\mu\) is the linear attenuation coefficient, \(\Delta T\) is the casting defect size along the beam direction, and \(n\) is the ratio of scattered radiation to primary radiation. This relation shows that a casting defect becomes visible when it produces sufficient contrast. However, manual X-ray inspection is subjective, fatiguing, and inconsistent. Therefore, automated casting defect detection is necessary, and the performance of such detection algorithms depends strongly on the quantity and diversity of casting defect samples.

Common Casting Defect Categories

I consider the main casting defect categories that appear in aluminum and other castings. These categories include shrinkage cavity, sponge porosity, elongated gas porosity, round gas porosity, gas holes, high-density foreign material, and low-density foreign material. A shrinkage cavity casting defect is a concentrated void caused by inadequate feeding during solidification. It is often larger than porosity and tends to appear in hot spots, thick sections, and regions that solidify last. The following table summarizes typical casting defect categories and their visual or spatial characteristics.

Casting Defect Type Typical Origin Image Appearance Spatial Tendency
Shrinkage cavity Solidification contraction without sufficient liquid feeding Concentrated dark or bright region depending on imaging polarity Hot spots, thick walls, last solidification zones
Sponge porosity Dispersed shrinkage during solidification Fine scattered texture Interdendritic regions
Elongated gas porosity Gas entrapment combined with shrinkage Elongated dark traces Grain boundaries and flow paths
Round gas porosity Gas bubbles trapped in melt Small round dark spots Randomly distributed
Gas holes Gas evolution or air entrapment Distinct rounded cavities Near surfaces or internal pockets
High-density inclusion Foreign particles with higher density Bright irregular spots Depends on flow and settling
Low-density inclusion Foreign particles with lower density Dark irregular spots Depends on flow and floating

Formation Mechanism of Shrinkage Cavity Casting Defect

The formation of a shrinkage cavity casting defect is closely related to volume contraction during cooling and solidification. When liquid metal enters a mold, it undergoes liquid contraction, solidification contraction, and solid contraction. The total volume change can be expressed as

$$ V_{\mathrm{total}} = V_{\mathrm{liquid}} + V_{\mathrm{freeze}} + V_{\mathrm{solid}} $$

where \(V_{\mathrm{total}}\) is the total volume reduction, \(V_{\mathrm{liquid}}\) is the liquid contraction volume, \(V_{\mathrm{freeze}}\) is the solidification contraction volume, and \(V_{\mathrm{solid}}\) is the solid contraction volume. The liquid contraction stage occurs from the pouring temperature \(T_{\mathrm{pour}}\) to the freezing temperature \(T_{\mathrm{freeze}}\), and it can be approximated by

$$ \Delta V_{\mathrm{liquid}} = \beta_{\mathrm{liquid}} V_0 \left(T_{\mathrm{pour}} – T_{\mathrm{freeze}}\right) $$

The solidification contraction stage occurs from \(T_{\mathrm{freeze}}\) to the solidification completion temperature \(T_{\mathrm{solid}}\), and it is often the main cause of shrinkage cavity casting defect formation:

$$ \Delta V_{\mathrm{freeze}} = \beta_{\mathrm{freeze}} V_0 \left(T_{\mathrm{freeze}} – T_{\mathrm{solid}}\right) $$

The solid contraction stage occurs after solidification and continues to room temperature. It is more closely related to linear contraction, residual stress, distortion, and cracking:

$$ \Delta V_{\mathrm{solid}} = \alpha_{\mathrm{solid}} L_0 \left(T_{\mathrm{solid}} – T_{\mathrm{normal}}\right) $$

If the liquid contraction and solidification contraction are not compensated by additional liquid metal, a concentrated void forms. This void is the shrinkage cavity casting defect. If the void is dispersed, it becomes shrinkage porosity. Therefore, the feeding ability of the gating system, the solidification gradient, and the thermal profile of the mold determine whether a casting defect becomes a concentrated shrinkage cavity or a dispersed porosity.

Shrinkage Cavity Type Location Typical Shape Inspection Difficulty
Open shrinkage cavity Exposed to surface Open depression or cavity Relatively easy visually
Re-entrant shrinkage cavity Concave corner Internal corner void Moderate
Core-surface shrinkage cavity Core surface region Irregular cavity near core Moderate to high
Internal shrinkage cavity Inside the casting Concentrated internal void High; requires X-ray or NDT

Digital Image Features of Shrinkage Cavity Casting Defect

To generate a realistic casting defect image, I first analyze real shrinkage cavity casting defect images from X-ray inspection. The features I use include gray-level distribution, texture, and spatial relation. Because X-ray images are grayscale images, the color feature is equivalent to the gray feature. I use the gray histogram to describe the intensity distribution, the gray contour map to describe spatial intensity variation, and Fourier spectrum analysis to describe texture direction and periodicity. I also compute statistical texture measures such as mean, contrast, smoothness, and entropy.

Let \(z_i\) be a gray level in an image with \(L\) possible levels, and let \(p(z_i)\) be the normalized frequency of that gray level. The mean gray level is

$$ m = \sum_{i=0}^{L-1} z_i p(z_i) $$

The variance or second moment about the mean is

$$ \sigma^2 = \sum_{i=0}^{L-1} (z_i – m)^2 p(z_i) $$

The smoothness measure is

$$ R = 1 – \frac{1}{1+\sigma^2} $$

The entropy of the gray-level distribution is

$$ H = -\sum_{i=0}^{L-1} p(z_i)\log_2 p(z_i) $$

For texture analysis, I transform the image into the frequency domain. Let \(S(r,\theta)\) be the spectrum in polar coordinates, where \(r\) is the radial frequency and \(\theta\) is the direction. The radial and directional spectrum functions are

$$ S(r) = \sum_{\theta=0}^{\pi} S(r,\theta) $$

$$ S(\theta) = \sum_{r=1}^{R_0} S(r,\theta) $$

where \(R_0\) is the radius of the frequency-domain region under consideration. The peaks of \(S(r)\) indicate dominant texture periods, while peaks of \(S(\theta)\) indicate dominant texture directions. For real shrinkage cavity casting defect images, I observe that the gray values are concentrated in the high-intensity range, approximately from 150 to 250. The gray contour map usually has a central peak, and the intensity decreases from the center toward the boundary. The boundary often appears as a soft ribbon-like region. The Fourier spectrum shows energy spreading from the center, with stronger components near \(0^\circ\), \(90^\circ\), and \(180^\circ\). The \(S(r)\) curve usually has a peak near \(r=3\), and the \(S(\theta)\) curve indicates that horizontal and vertical orientations are dominant.

Feature Meaning Real Shrinkage Cavity Casting Defect Observation
Gray histogram Frequency of gray levels Concentrated in [150, 250]
Gray contour Spatial intensity distribution Central peak with radial decay
Spectrum energy Texture energy distribution Center-outward spread
\(S(r)\) peak Dominant texture period Peak near \(r=3\)
\(S(\theta)\) peak Dominant texture direction Energy near \(0^\circ\), \(90^\circ\), \(180^\circ\)
Texture Measure Symbol Statistical Result for Real Casting Defect Images
Mean brightness \(m\) 195.226
Mean contrast \(\sigma\) 19.266
Smoothness \(R\) 0.006
Entropy \(H\) 6.534

These statistics form the reference for evaluating my generated casting defect images. If a synthetic shrinkage cavity casting defect has similar gray-level and texture statistics to real casting defect images, then I can conclude that the generation algorithm is effective. Spatial relation is also important because a shrinkage cavity casting defect tends to appear in hot spots and last-solidification regions. I therefore keep the defect region concentrated and place it in a controlled region during fusion.

Overall Generation Framework

My proposed casting defect image generation method has three main stages. The first stage generates an initial synthetic casting defect image from random height data. The second stage transforms the initial image so that its gray-level and texture properties become closer to those of a real shrinkage cavity casting defect. The third stage fuses the transformed casting defect into a real X-ray background. The following table summarizes the framework.

Stage Input Main Operations Output
Stage 1: Simulation generation Random height data Improved Diamond-Square algorithm, normalization, gray mapping Initial synthetic casting defect image
Stage 2: Transformation Initial synthetic casting defect image Histogram equalization, modified Otsu thresholding, gray stretching, Gaussian filtering Transformed casting defect image
Stage 3: Background fusion Transformed casting defect image and real X-ray background Pixel-level fusion with intensity mapping Final synthetic casting defect image

Stage 1: Improved Diamond-Square Algorithm

The Diamond-Square algorithm is a two-dimensional random midpoint displacement method. It was originally used to generate height maps for natural terrain. I adapt it to generate a shrinkage cavity casting defect because a real shrinkage cavity casting defect has a central peak and a radial gray-level decay, which resembles a height map with a dominant mountain. The algorithm starts with a square array of size \((2^n+1)\times(2^n+1)\). The four corners receive initial height values. Then the diamond step and square step are applied recursively until every point has a height value.

For one-dimensional random midpoint displacement, the midpoint value is computed as

$$ X\left(\frac{t_1+t_2}{2}\right) = \frac{1}{2}\left[X(t_1)+X(t_2)\right]+\Delta_n $$

where \(\Delta_n\) is a Gaussian random displacement. The variance of the displacement decreases with recursion depth \(n\) according to

$$ \sigma_n = k 2^{-nH} $$

where \(k\) is a scale factor and \(H\) is the Hurst exponent. This decreasing variance ensures that fine details have smaller fluctuations than coarse structures.

In the diamond step, four corner points \(A\), \(B\), \(C\), and \(D\) determine the center point \(M\). If their height values are \(g_A\), \(g_B\), \(g_C\), and \(g_D\), then

$$ g_M = \frac{g_A+g_B+g_C+g_D}{4} + r_M $$

In the square step, the edge midpoints \(E\), \(F\), \(G\), and \(H\) are computed from the surrounding points. Their height values are

$$ g_E = \frac{g_A+g_B+g_M}{3}+r_E $$

$$ g_F = \frac{g_B+g_C+g_M}{3}+r_F $$

$$ g_G = \frac{g_C+g_D+g_M}{3}+r_G $$

$$ g_H = \frac{g_A+g_D+g_M}{3}+r_H $$

Here \(r_M\), \(r_E\), \(r_F\), \(r_G\), and \(r_H\) are random displacements. In the standard algorithm, these displacements are statistically similar except for the decreasing scale. In my improved version, I introduce a center bias so that the highest region is more likely to appear near the center of the synthetic casting defect image. I define a center-weight function

$$ P(x,y)=\exp\left(-\frac{(x-c_x)^2+(y-c_y)^2}{2s^2}\right) $$

where \((c_x,c_y)\) is the array center and \(s\) controls the spatial extent of the bias. The random displacement is then

$$ r(x,y)=\sigma_n \left[1+\lambda P(x,y)\right] N(0,1) $$

where \(\lambda\) controls the strength of the center bias and \(N(0,1)\) is a standard normal random variable. This modification increases the probability that the central region receives a larger positive displacement, which produces a concentrated central peak similar to a shrinkage cavity casting defect.

Parameter Role in Casting Defect Generation Typical Setting
\(n\) Controls array size and detail level 5 to 8
Array size Defines the spatial resolution of the casting defect \((2^n+1)\times(2^n+1)\)
Initial corner values Sets the base height field [-1, 1]
Hurst exponent \(H\) Controls roughness persistence 0.5 to 0.9
Scale factor \(k\) Controls overall displacement magnitude 0.5 to 1.0
Center bias \(\lambda\) Encourages central peak formation 0.2 to 0.8
Gaussian width \(s\) Controls the width of the center bias 0.2 to 0.5 of array size

After the height data are generated, I normalize the array to the gray-level range. Let \(A(i,j)\) be the height value at pixel \((i,j)\). I compute

$$ A_{\min} = \min_{i,j} A(i,j), \quad A_{\max} = \max_{i,j} A(i,j) $$

Then the gray-level image is

$$ G(i,j) = 255 \frac{A(i,j)-A_{\min}}{A_{\max}-A_{\min}} $$

This mapping converts the random height field into an 8-bit grayscale image. The result is an initial synthetic casting defect image with a cloud-like shape. The brightest region corresponds to the highest height value, and the darkest region corresponds to the lowest height value. Because the improved algorithm biases the center, the main peak of the casting defect is usually located near the image center, which is consistent with the gray-level distribution of a real shrinkage cavity casting defect.

Stage 2: Transformation of the Initial Casting Defect Image

The initial synthetic casting defect image is not yet suitable for direct fusion. Its gray-level distribution is too broad, its contrast may be insufficient, and its boundary may contain unwanted low-intensity regions. Therefore, I apply a sequence of transformations. The purpose is to make the synthetic casting defect more similar to a real shrinkage cavity casting defect in terms of contrast, shape concentration, edge smoothness, and texture statistics.

Histogram Equalization

Histogram equalization redistributes gray levels so that the cumulative distribution becomes approximately uniform. This increases global contrast. For an input image with gray levels \(r_k\) and normalized histogram \(p_r(r_j)\), the output gray level is

$$ s_k = T(r_k) = (L-1)\sum_{j=0}^{k} p_r(r_j) $$

where \(L\) is the number of gray levels, usually 256. I apply histogram equalization to expand the gray-level range of the initial casting defect image. After this operation, the defect region becomes more distinct, and the low-intensity regions are spread over a wider range. This prepares the image for threshold-based removal of unwanted regions.

Modified Otsu Thresholding

Otsu thresholding selects a threshold that maximizes the between-class variance. Let \(\omega_0\) and \(\omega_1\) be the probabilities of the background and foreground classes, and let \(\mu_0\), \(\mu_1\), and \(\mu_T\) be their means and the global mean. The between-class variance is

$$ \sigma_B^2 = \omega_0(\mu_0-\mu_T)^2 + \omega_1(\mu_1-\mu_T)^2 $$

The optimal Otsu threshold is

$$ k^* = \arg\max_{1\le k < L} \sigma_B^2(k) $$

I modify this method by introducing a random dynamic coefficient \(\gamma\) so that the final threshold is not always identical. The modified threshold is

$$ k = \gamma k^*, \quad \gamma \in [1.2,1.5] $$

Then I assign all gray values below \(k\) to \(k\):

$$ G'(i,j)=\begin{cases} G(i,j), & G(i,j)\ge k \\ k, & G(i,j)<k $$=""

This operation removes weak and low-intensity parts of the synthetic casting defect and keeps the more concentrated core. Because \(\gamma\) is random, the retained casting defect region varies across generated samples. This increases the diversity of the synthetic casting defect images while still preserving the main structure of the shrinkage cavity casting defect.

Gray Stretching

After thresholding, the gray-level range is compressed within the retained region. I apply gray stretching to expand the remaining range to the full 8-bit interval. Let \(f(i,j)\) be the thresholded image, and let \(f_{\min}\) and \(f_{\max}\) be its minimum and maximum gray values. The stretched image is

$$ g(i,j)=\frac{f(i,j)-f_{\min}}{f_{\max}-f_{\min}}\times 255 $$

This step increases the contrast of the casting defect region and makes the central peak and surrounding decay more visible. It also helps align the synthetic casting defect statistics with the high-intensity concentration observed in real shrinkage cavity casting defect images.

Gaussian Filtering

Thresholding and stretching can introduce sharp or unnatural boundaries. I therefore apply Gaussian filtering to smooth the casting defect boundary and suppress noise. The two-dimensional Gaussian kernel is

$$ G(x,y)=\frac{1}{2\pi\sigma^2}\exp\left(-\frac{x^2+y^2}{2\sigma^2}\right) $$

The filtered image has softer transitions between the casting defect and its surroundings. This is important because a real shrinkage cavity casting defect often has a ribbon-like boundary rather than a hard binary edge. After Gaussian filtering, I sometimes repeat thresholding, gray stretching, and Gaussian filtering once more to further refine the casting defect region. The repetition is controlled by the observed similarity between the synthetic casting defect and the reference statistics.

Transformation Main Purpose Effect on Casting Defect Image
Histogram equalization Increase global contrast Expands gray range and highlights defect body
Modified Otsu thresholding Remove low-intensity regions Keeps concentrated core and increases diversity
Gray stretching Expand retained gray range Enhances contrast after thresholding
Gaussian filtering Smooth boundary and reduce noise Produces softer, more natural casting defect edges
Optional repetition Fine adjustment Improves statistical similarity to real casting defect

Stage 3: Background Fusion

After transformation, the synthetic casting defect image is fused into a real X-ray background. I use pixel-level fusion because it preserves detailed intensity information and is suitable for casting defect image analysis. I select a region of interest in the real X-ray image that does not contain an actual casting defect, and I place the synthetic casting defect into that region. This avoids overlap with real defects and allows controlled evaluation. The fusion process can be summarized by the following steps.

Step Operation Equation or Rule
1 Compute maximum gray value of the real background \(F\) \(\max_F = \max_{i,j} F(i,j)\)
2 Compute transformation limit for synthetic casting defect \(D\) \(T = 255/\max_F\)
3 Compute minimum and maximum gray values of \(D\) \(D_{\min}, D_{\max}\)
4 Map \(D\) to the interval \([1,T]\) \(M(i,j)=\frac{D(i,j)-D_{\min}}{D_{\max}-D_{\min}}(T-1)+1\)
5 Multiply mapped casting defect with background \(R(i,j)=M(i,j)F(i,j)\)

The mapping equation is

$$ T=\frac{255}{\max_F} $$

$$ M(i,j)=\frac{D(i,j)-D_{\min}}{D_{\max}-D_{\min}}(T-1)+1 $$

$$ R(i,j)=M(i,j)F(i,j) $$

where \(D(i,j)\) is the transformed synthetic casting defect image, \(F(i,j)\) is the real X-ray background, and \(R(i,j)\) is the final fused image. This fusion rule preserves the background texture while embedding the synthetic casting defect with controlled intensity. Because \(M(i,j)\) is close to 1 in background regions and increases in the defect region, the fused casting defect appears as a local intensity disturbance similar to a real casting defect.

Quality Evaluation Criteria

I evaluate the final synthetic casting defect images using both subjective and objective criteria. The subjective criterion is visual similarity: a human observer should see a cloud-like casting defect with a central core, a smooth boundary, and a natural transition into the X-ray background. The objective criteria are the gray-level and texture statistics defined earlier: mean brightness, mean contrast, smoothness, and entropy. I also use Fourier-based features such as the \(S(r)\) peak and \(S(\theta)\) energy distribution. Finally, I use a deep-learning-based casting defect detector to verify whether the generated casting defect can be recognized as a shrinkage cavity casting defect.

Evaluation Type Metric Purpose
Subjective Visual similarity to real casting defect Check natural appearance and fusion quality
Objective gray-level Mean brightness, contrast, smoothness, entropy Compare statistical distributions
Objective texture Fourier \(S(r)\), \(S(\theta)\) Compare texture periodicity and direction
Detection-based Deep-learning casting defect recognition Verify semantic validity as shrinkage cavity casting defect

Experimental Setup

I implemented the generation stage in a C++ environment and the transformation and fusion stages in a numerical computing environment. The experiments used X-ray images of castings containing real shrinkage cavity casting defects as reference data. I collected and analyzed 400 real casting defect regions to build the reference statistics. I then generated multiple synthetic casting defect images and fused them into real X-ray backgrounds. Finally, I tested 80 fused images with a deep-learning casting defect detector based on Faster R-CNN. The detector includes a region proposal network, a Fast R-CNN refinement stage, and a classification and localization output. The input images are preprocessed with window-width and window-level selection, contrast stretching, and normalization.

Results of Stage 1: Initial Casting Defect Generation

The improved Diamond-Square algorithm generated height maps with a central tendency. The initial synthetic casting defect images appeared cloud-like, with a bright central region and darker surroundings. The gray-level histograms were concentrated in the high-intensity range, approximately from 150 to 250. This is qualitatively similar to real shrinkage cavity casting defect images. However, the initial images still contained many high-intensity regions that did not belong to a concentrated casting defect core. The contour maps showed multiple peaks or broad elevated areas rather than a single dominant peak. Therefore, the initial images required transformation before fusion.

Property Initial Synthetic Casting Defect Real Shrinkage Cavity Casting Defect
Overall shape Cloud-like random region Concentrated cloud-like with core
Gray range Mostly [150, 250] Mostly [150, 250]
Peak location Often central after improvement Central core
Boundary Sometimes broad or irregular Soft ribbon-like boundary
Readiness for fusion Not directly suitable Reference target

Results of Stage 2: Transformation of the Casting Defect Image

Histogram equalization redistributed the gray levels and increased contrast. The modified Otsu thresholding removed low-intensity regions and retained the core of the casting defect. Because the threshold coefficient \(\gamma\) was randomly selected from [1.2, 1.5], each generated casting defect had a different retained area. Gray stretching then expanded the remaining gray range and increased the contrast of the defect body. Gaussian filtering smoothed the boundary and reduced sharp transitions. After one or two repetitions of thresholding, stretching, and filtering, the synthetic casting defect became visually closer to a real shrinkage cavity casting defect.

Processing Step Observed Effect Contribution to Casting Defect Realism
Histogram equalization Gray levels spread across a wider range Improves contrast and separates defect from background
Modified Otsu thresholding Low-intensity regions removed Concentrates the casting defect core
Gray stretching Retained gray range expanded Enhances internal contrast of the casting defect
Gaussian filtering Boundary smoothed Reduces unnatural sharp edges
Repetition Further refinement Improves similarity to real casting defect statistics

Results of Stage 3: Background Fusion and Feature Comparison

After fusion, the synthetic shrinkage cavity casting defect appeared as a natural local intensity variation in the X-ray background. I extracted the fused casting defect regions and computed their gray-level and texture statistics. The following tables compare representative generated casting defect images with the reference statistics from real casting defect images.

Image Source Mean Brightness Mean Contrast Smoothness Entropy
Real casting defect sample A 206.326 22.846 0.008 5.549
Real casting defect sample B 187.098 20.099 0.006 6.155
400 real casting defect average 195.226 19.266 0.006 6.534
Generated Casting Defect Stage Mean Brightness Mean Contrast Smoothness Entropy
Before final refinement, sample A 215.626 22.237 0.017 6.439
Before final refinement, sample B 219.556 28.223 0.015 6.162
Final fused sample A 191.958 19.153 0.006 6.238
Final fused sample B 196.604 18.752 0.005 6.165
400 final fused images average 193.219 18.863 0.006 6.235

The final fused casting defect images have mean brightness, contrast, smoothness, and entropy values that are close to the real casting defect reference statistics. The average brightness is approximately 193.219 compared with 195.226 for real casting defects. The average contrast is approximately 18.863 compared with 19.266. The smoothness is approximately 0.006, which matches the real reference. The entropy is approximately 6.235 compared with 6.534. These results indicate that my transformation and fusion stages produce synthetic casting defect images with statistical properties similar to real shrinkage cavity casting defect images.

In the Fourier domain, the final fused casting defect images show a center-outward energy distribution. The \(S(r)\) curve has a dominant peak near \(r=3\), and the \(S(\theta)\) curve shows stronger energy near \(0^\circ\), \(90^\circ\), and \(180^\circ\). This matches the texture orientation and periodicity observed in real shrinkage cavity casting defect images. The gray contour maps of the final fused casting defects show a central peak with radial decay, which is consistent with the spatial gray-level distribution of a real shrinkage cavity casting defect. The boundary appears soft and ribbon-like, and the transition to the background is natural.

Texture Feature Real Casting Defect Final Synthetic Casting Defect
\(S(r)\) peak location Near \(r=3\) Near \(r=3\)
Number of dominant \(S(r)\) peaks One main peak One main peak
Dominant \(S(\theta)\) directions Near \(0^\circ\), \(90^\circ\), \(180^\circ\) Near \(0^\circ\), \(90^\circ\), \(180^\circ\)
Gray contour pattern Central peak with radial decay Central peak with radial decay
Boundary appearance Soft and ribbon-like Soft and ribbon-like

Deep-Learning-Based Casting Defect Detection Verification

To further verify the semantic validity of my generated casting defect images, I used a deep-learning casting defect detector. The detector processes the fused image, proposes candidate regions, refines them, and classifies each region into a casting defect category. I tested 80 fused images containing synthetic shrinkage cavity casting defects. The detector successfully detected the synthetic casting defect in all 80 images and classified each as a shrinkage cavity casting defect. The average confidence for the correct class was 89.2%. This result supports the conclusion that my generated casting defect images are not only statistically similar to real casting defect images but also recognizable by a modern casting defect detection model.

Detection Experiment Value
Number of tested fused images 80
Images with detected casting defect 80
Images classified as shrinkage cavity casting defect 80
Missed casting defect count 0
Average classification confidence 89.2%

Discussion

My method has several advantages. First, the improved Diamond-Square algorithm can generate casting defect shapes with high randomness and diversity, while the center bias ensures that the main peak of the casting defect is usually concentrated near the center. Second, the transformation stage adjusts the gray-level distribution, contrast, boundary smoothness, and texture so that the synthetic casting defect approaches the statistics of real shrinkage cavity casting defect images. Third, the modified Otsu threshold introduces randomness into the retained region, which prevents all generated casting defects from looking identical. Fourth, the fusion stage embeds the synthetic casting defect into a real X-ray background with controlled intensity, producing a natural appearance. Fifth, the deep-learning detector confirms that the generated casting defect can be recognized as a shrinkage cavity casting defect, which is a strong semantic validation.

However, my method also has limitations. It currently focuses on shrinkage cavity casting defect images and does not explicitly model other casting defect types such as gas holes, inclusions, or dispersed porosity. The fusion stage uses a manually selected region of interest to avoid overlap with real defects, so the spatial placement of the casting defect is not fully automatic. The method operates in two dimensions and does not reconstruct the three-dimensional geometry of the casting defect. The computational cost of generating many high-resolution casting defect images may also be significant in large-scale training data production. In addition, although the statistical similarity is high, there may still be subtle visual differences that a human expert can notice.

Strength Limitation Possible Improvement
Random shape generation with central tendency Mainly validated for shrinkage cavity casting defect Extend to porosity, gas holes, and inclusions
Statistical similarity to real casting defect Two-dimensional only Integrate 3D casting defect geometry
Random threshold improves diversity Manual region of interest for fusion Automate defect placement using casting geometry
Deep-learning detection validation Computational cost for high-resolution generation Use GPU acceleration and parallel generation
Natural fusion with X-ray background Subtle visual differences may remain Add adversarial or perceptual refinement

Future Work

I plan to extend the algorithm in several directions. First, I will adapt the height-field generation and transformation pipeline to other casting defect categories, including sponge porosity and gas holes. This will require different center-bias functions, different threshold rules, and different texture statistics. Second, I will study the spatial distribution of real casting defects in castings and build a placement model that predicts likely hot spots and last-solidification regions. This will make the fusion stage more automatic and more physically meaningful. Third, I will implement GPU acceleration for the Diamond-Square recursion and the transformation operations so that large batches of casting defect images can be generated quickly. Fourth, I will explore generative models and adversarial refinement to improve the perceptual realism of the synthetic casting defect images while preserving the interpretability of the statistical pipeline. Fifth, I will evaluate the generated casting defect images on larger and more diverse casting defect datasets, including different alloys, thicknesses, and X-ray imaging conditions.

Conclusion

I have presented a multi-stage algorithm for generating shrinkage cavity casting defect images. The algorithm begins with an improved Diamond-Square method that produces random height data with a central bias. The height data are normalized and mapped to gray levels to form an initial synthetic casting defect image. A transformation stage then applies histogram equalization, modified Otsu thresholding, gray stretching, and Gaussian filtering to make the synthetic casting defect more similar to a real shrinkage cavity casting defect. A pixel-level fusion stage embeds the transformed casting defect into a real X-ray background. I evaluated the generated casting defect images using gray-level statistics, texture statistics, Fourier features, and a deep-learning casting defect detector. The final synthetic casting defect images achieved mean brightness, contrast, smoothness, and entropy values close to those of 400 real casting defect samples. The detector identified all tested synthetic casting defects as shrinkage cavity casting defects with an average confidence of 89.2%. These results show that the proposed method can generate realistic and semantically valid shrinkage cavity casting defect images for automated casting defect detection research.

Scroll to Top