A method and system for detecting casting surface defects

By constructing a multi-scale contrast feature cube and calculating the defect saliency score, the problem that a single window size is difficult to take into account different defect features in the surface defect detection of castings is solved, and more accurate defect identification and improved reliability of the detection system are achieved.

CN120976216BActive Publication Date: 2025-12-30NINGBO LIGU MASCH MFG CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511484635.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-10-17
Publication Date
2025-12-30
Estimated Expiration
2045-10-17

AI Technical Summary

Technical Problem

In existing technologies, the size of surface defects in castings varies greatly, and a single fixed window size is insufficient to take into account different defect characteristics. This makes it difficult to balance missed detections and false alarms, affecting the practicality and reliability of the detection system.

Method used

A multi-scale contrast feature cube construction method is adopted. Multi-scale feature spectral lines are obtained through a predefined set of analysis window scales. Defect saliency scores are calculated by combining peak saliency and scale locality, and a defect saliency map is constructed and binarized.

Benefits of technology

It improves adaptability to defects of different sizes, effectively balances missed detections and false alarms, and enhances the detection system's identification capability and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120976216B_ABST
    Figure CN120976216B_ABST
Patent Text Reader

Abstract

The present application relates to the field of image processing, more particularly, the present application relates to a kind of casting surface defect detection method and system, method includes: the color image of casting surface is converted into gray scale image;A multi-scale contrast feature cube is constructed on gray scale image using different scale analysis window;The contrast feature sequence of each pixel point is analyzed, and its peak saliency and scale locality are extracted, the defect saliency score is calculated in combination with the two indexes, and the defect saliency map is formed;The defect saliency map is binarized, and the pixel point with score higher than the preset threshold is judged as defect point, and the defect region is constructed, the position of defect on gray scale image is marked, and defect detection is completed.The present application effectively captures the specific response of casting surface defect in scale space by multi-scale contrast analysis, and realizes accurate positioning and visualization of defect by combining binarization and region marking.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing. More specifically, this invention relates to a method and system for detecting defects on casting surfaces. Background Technology

[0002] Casting is a fundamental and crucial process in manufacturing. Among numerous manufacturing processes, casting occupies a starting or vital supporting position, providing basic components or semi-finished products for subsequent product manufacturing. The quality of castings directly affects the safety and reliability of the final product. Castings may contain minute defects such as cracks and porosity. These defects are extremely subtle and difficult to detect with the naked eye.

[0003] In automated inspection technology based on machine vision, gray-level co-occurrence matrix is ​​a commonly used texture analysis tool. It calculates the gray-level spatial distribution of pixel pairs in a local area of ​​an image and extracts feature parameters such as contrast, energy, and homogeneity. Based on these parameters, it determines whether there are defects on the surface of the object being inspected.

[0004] However, the size of surface defects in castings varies greatly, and a single fixed window size cannot simultaneously take into account the characteristics of defects of different sizes. This makes it difficult to achieve an ideal balance between missed detections and false alarms, thus affecting the practicality and reliability of the detection system. Summary of the Invention

[0005] To address the technical problems mentioned above, such as the large differences in the dimensions of surface defects in castings, the difficulty in taking into account different defect characteristics with a single fixed window size, the difficulty in balancing missed detections and false alarms, and the impact on the practicality and reliability of the detection system, this invention provides solutions in the following aspects.

[0006] In a first aspect, a method for detecting defects on a casting surface includes:

[0007] Obtain a grayscale image of the casting surface to be inspected, and construct a multi-scale contrast feature cube on the grayscale image based on a predefined set of analysis window scales;

[0008] Based on each pixel in the cube, the contrast feature sequence of the pixel is extracted along the scale dimension to form the multi-scale feature spectral line of the pixel, and the peak significance and scale locality of the multi-scale feature spectral line are calculated.

[0009] The peak saliency and the scale locality are combined to calculate the defect saliency score of each pixel. The defect saliency scores of all pixels are combined to construct a defect saliency map. The defect saliency map is binarized. Pixels with defect saliency scores higher than a preset threshold are identified as defect points and defect regions are constructed. The location of the defect is marked on the grayscale image according to the defect regions.

[0010] Preferably, the set is defined as a set containing multiple odd-numbered side lengths as the scale of the analysis window.

[0011] Preferably, the construction process of the cube includes:

[0012] For each scale in the set, an analysis window is constructed with each pixel in the grayscale image as the center, the grayscale co-occurrence matrix within the analysis window is obtained, the contrast feature value of the analysis window is calculated based on the grayscale co-occurrence matrix, and all pixels in the grayscale image are traversed to generate a complete contrast feature map under the analysis window.

[0013] Stack the complete contrast feature maps under all analysis windows along the scale dimension, record the contrast feature values ​​of each spatial location under all analysis windows, and form a multi-scale contrast feature cube.

[0014] Preferably, the process of obtaining the peak significance includes:

[0015] Calculate the average Pearson correlation coefficient between the multi-scale feature spectral lines of a pixel and the multi-scale feature spectral lines of its eight neighbors, and use this as the spatial consistency of the pixel; obtain the local maximum points of the multi-scale feature spectral lines according to preset recognition conditions; and statistically analyze the maximum value and median of the multi-scale feature spectral lines.

[0016] The peak significance of the multi-scale feature line at a pixel is calculated as the product of the ratio of the maximum value to the median of the eigenvalues ​​on the multi-scale feature line, the spatial consistency, and the number of local maxima on the multi-scale feature line.

[0017] Preferably, the process of obtaining the scale locality includes:

[0018] Based on the distribution of contrast eigenvalues ​​on multi-scale feature spectral lines, the product of the calculated half-peak width and the high-value non-uniform distribution coefficient is used as the scale locality of the multi-scale feature spectral lines of the pixel.

[0019] Preferably, the process of obtaining the scale locality includes:

[0020] The distribution of contrast feature energy at each scale is calculated, and then the scale entropy is calculated. The reciprocal of the scale entropy is used as the scale locality of the multi-scale feature spectral lines of the pixel.

[0021] Preferably, the process for obtaining the defect salience score is as follows:

[0022] The product of the peak significance and the scale locality is used as the defect significance score.

[0023] Preferably, the process for obtaining the defect salience score is as follows:

[0024] The peak significance and the scale locality are assigned corresponding weights respectively, and the peak significance and the scale locality are weighted and summed to obtain the defect significance score.

[0025] In a second aspect, a casting surface defect detection system includes a processor and a memory, wherein the memory stores computer program instructions that, when executed by the processor, implement any of the casting surface defect detection methods described above.

[0026] The present invention has the following beneficial effects:

[0027] 1. This invention constructs a multi-scale contrast feature cube and utilizes a predefined set of analysis window scales to cover multiple different scales (especially including multiple odd-numbered side lengths as analysis window scales), avoiding the problem that a single fixed window size cannot adequately capture surface defect features of different sizes. Analysis windows of different scales can capture defect information from multiple dimensions, improving adaptability to defects of various sizes.

[0028] 2. Contrast feature sequences of pixels are extracted along the scale dimension to form multi-scale feature spectra, and peak saliency and scale locality are calculated. Peak saliency comprehensively considers the spatial consistency between multi-scale feature spectra and neighboring spectra, the number of local maxima, and the ratio of the maximum eigenvalue to the median, highlighting the significant features of true defect regions at multiple scales. Scale locality measures the concentration of features along the scale dimension using different methods (such as the product of half-peak width and high-value non-uniform distribution coefficient, the inverse of scale entropy, etc.). Peak saliency and scale locality are combined (product or weighted summation) to calculate the defect saliency score, constructing a defect saliency map and performing binarization. This comprehensive calculation method, integrating multi-scale features and multiple indicators, can more accurately determine whether a pixel is a defect point, effectively balancing false negatives and false negatives, and improving the detection system's ability to identify different defect features. Attached Figure Description

[0029] Figure 1 This is a flowchart of steps S1-S3 in a casting surface defect detection method according to an embodiment of the present invention.

[0030] Figure 2 This is a structural block diagram of a casting surface defect detection system according to an embodiment of the present invention. Detailed Implementation

[0031] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are some embodiments of the present invention, but not all embodiments.

[0032] Reference Figure 1 A method for detecting defects on casting surfaces includes steps S1-S7, as detailed below:

[0033] S1: Obtain the grayscale image of the casting surface to be inspected, and construct a multi-scale contrast feature cube on the grayscale image based on a predefined set of analysis window scales.

[0034] In one embodiment, a high-resolution industrial camera is used to vertically image the surface of a casting fixed at the inspection station under uniform and controllable ring-shaped LED lighting conditions. The resolution of the image acquisition system is set according to the casting size and the minimum detectable defect requirement, ensuring that the smallest defect in the image occupies at least a 3×3 pixel area so that minute defects can be accurately detected subsequently.

[0035] The acquired images are denoised and homogenized to create grayscale images suitable for subsequent analysis. The image's 256 grayscale levels (0-255) are then mapped to 16 levels (0-15) to reduce computation while retaining sufficient grayscale information for analysis.

[0036] It should be noted that surface defects in castings often have unique local characteristics, such as abrupt changes in grayscale at the edge of cracks or localized reductions in grayscale in pores. Window analysis can quantify these local characteristics by setting a fixed-size window, sliding it across the image, and statistically analyzing the pixels within the window.

[0037] However, defects on the surface of castings vary in size, ranging from microcracks at the micrometer level to porous areas at the millimeter level. Defects of different scales require windows of different sizes for accurate detection. A single-scale analysis window cannot simultaneously accommodate defects of different scales, while multi-scale analysis can calculate the contrast characteristics at each scale by setting windows of different sizes, thereby comprehensively capturing information about defects at different scales.

[0038] In one embodiment, a set of analysis window scales is defined, which is a set of multiple odd-numbered side lengths used as analysis window scales. This set should cover a range characterizing from the smallest defects to larger background textures. For example, this set includes side lengths of 3, 5, 7, 9, 11, 13, and 15. The selection of the scale set is optimized based on the typical defect size distribution and surface texture characteristics of the casting to be inspected, with the minimum scale slightly smaller than the size of the target smallest defect, and the maximum scale covering the period of typical background textures.

[0039] Furthermore, for each scale in the above set, an analysis window corresponding to each pixel in the grayscale image is constructed at each scale. For any pixel within an analysis window, grayscale co-occurrence matrices in four directions (0 degrees, 45 degrees, 90 degrees, and 135 degrees) are calculated. These grayscale co-occurrence matrices describe the spatial dependencies of grayscale levels in the grayscale image and reflect the texture information of the image.

[0040] Furthermore, the gray-level co-occurrence matrices in the four directions are averaged to obtain a rotation-invariant gray-level co-occurrence matrix. This is because defects on the casting surface can appear in any direction. If only the gray-level co-occurrence matrix in a single direction is calculated, the detection results will heavily depend on the relative angle between the defect and the analysis direction, leading to directional missed detections. By averaging the gray-level co-occurrence matrices in the four main directions, the influence of image orientation on texture feature extraction is eliminated, making the feature description rotationally invariant and improving the reliability and applicability of the detection. At the same time, this processing method maintains feature robustness while avoiding the excessive computational complexity caused by calculating all possible directions, achieving an optimal balance between detection performance and computational efficiency.

[0041] Based on the averaged gray-level co-occurrence matrix, the contrast feature value of the corresponding analysis window is calculated. The contrast feature value is used to quantify the intensity of gray-level changes in local areas of the image. A larger contrast value indicates that the gray-level changes in the local area are drastic, with obvious edge or texture abrupt changes, usually corresponding to surface defect areas such as crack edges or pore boundaries; a smaller contrast value indicates that the gray-level changes in the local area are gradual, with uniform texture, usually corresponding to normal casting surface areas.

[0042] By traversing all pixels in the grayscale image, a complete contrast feature map is generated for each analysis window.

[0043] Finally, all complete contrast feature maps are stacked along the scale dimension to obtain a multi-scale contrast feature cube, which fully records the contrast feature values ​​of each spatial location in the grayscale image under all analysis windows.

[0044] In summary, the above operations ultimately yield a grayscale image of the casting surface to be inspected, and a multi-scale contrast feature cube is constructed on the grayscale image.

[0045] S2: Based on each pixel in the cube, extract the contrast feature sequence of the pixel along the scale dimension to form the multi-scale feature spectrum of the pixel, and calculate the peak significance and scale locality of the multi-scale feature spectrum.

[0046] After obtaining the multi-scale contrast feature cube, multi-scale feature analysis is performed on each pixel, that is, the feature change pattern of each pixel under different observation ranges (scales) is observed to identify possible surface defects. By recording the feature changes of each point under multiple observation ranges from fine to broad, the difference in feature changes between real defects and normal surface areas is utilized to improve the accuracy and reliability of defect identification.

[0047] In one embodiment, a specific pixel is selected and its spatial position is kept unchanged. The contrast feature value of the pixel at each scale is obtained in the order of each scale in the analysis window scale set. The feature values ​​corresponding to all scales are arranged in ascending order of scale to form a one-dimensional vector, i.e., multi-scale feature spectral lines.

[0048] Furthermore, the average Pearson correlation coefficient between the multi-scale feature spectral lines of the pixel and the multi-scale feature spectral lines of its eight neighboring pixels is calculated as the spatial consistency of the pixel. Real defects typically exhibit spatial continuity, with their feature spectral lines showing high similarity within their neighborhood; random noise, on the other hand, lacks this spatial consistency. This metric can eliminate the interference of random noise and improve the accuracy of defect identification.

[0049] Furthermore, in order to assess whether the feature changes of each pixel form a significant single-peak abrupt change, the difference between the feature intensity of that point at the optimal observation scale and the overall average level is compared, and the consistency of the surrounding area is used for verification to determine whether there is a significant abrupt change.

[0050] In one embodiment, for a certain scale (excluding the first and last points) on a multi-scale feature spectrum, the following two identification conditions must be met simultaneously to be determined as a local extremum point:

[0051] 1. Left saliency condition: The feature value of the current scale must be significantly greater than the feature value of the left neighboring scale, and the difference between the feature value of the current scale and the feature value of the left neighboring scale must be at least 20% of the maximum feature value of the left and right neighbors (default ratio).

[0052] 2. Right-side saliency condition: The eigenvalue at the current scale must be significantly greater than the eigenvalue at the right-side adjacent scale, and the difference between the eigenvalue at the current scale and the eigenvalue at the right-side adjacent scale must be at least 20% of the maximum eigenvalue in the left and right neighborhoods (default ratio).

[0053] Since the characteristic spectral lines of the defect region exhibit obvious narrow-band spike characteristics at specific scales, and high values ​​only appear at a few scales that match the defect size, the possible defect scale can be preliminarily located by identifying local extreme points.

[0054] Additionally, obtain the maximum and median values ​​of the eigenvalues ​​on the multi-scale characteristic spectrum.

[0055] Furthermore, the product of the ratio of the maximum value to the median of the eigenvalues ​​on the multi-scale feature spectrum, the spatial consistency, and the number of local maximum points of the multi-scale feature spectrum is taken as the peak significance of the multi-scale feature spectrum of the pixel.

[0056] The ratio of the maximum to the median eigenvalue on a multi-scale feature spectral line measures whether the contrast peak of the pixel is significantly higher than the background baseline at multiple scales. The contrast of a defective region will suddenly increase at a specific scale, with this ratio being much greater than 1, while the background will fluctuate smoothly, with this ratio close to 1. The number of local maxima on the multi-scale feature spectral line is used to determine whether the spectral line is single-peaked or double-peaked. By calculating the peak significance, a comprehensive judgment can be made as to whether a pixel in the grayscale image belongs to a minor defect or background texture. The larger the peak significance, the more likely the point is to be a defect; conversely, the smaller the significance, the more likely the point corresponds to background or noise.

[0057] In one embodiment, half of the maximum eigenvalue on the multi-scale characteristic spectral line is first selected as the first reference. This is because this value represents half the height of the peak of the multi-scale characteristic spectral line, objectively reflecting the main distribution range of the characteristic energy, effectively distinguishing narrow peaks from broad peaks, and is unaffected by overall contrast. Then, the number of scales with eigenvalues ​​greater than or equal to the first reference is counted, and the concentration of characteristic energy at different scales is measured based on the statistical results, satisfying the following relationship:

[0058]

[0059] In the formula, For pixels The half-width of the multi-scale characteristic spectral lines. For pixels The eigenvalues ​​on the multi-scale characteristic spectral lines are greater than or equal to the number of scales of the first reference set above. It is a constant to prevent the denominator from being 0.

[0060] True defect spectral lines exhibit sharp pulses at specific scales, appearing as narrow peaks. The value is large; the background spectral lines are distributed gently across multiple scales, exhibiting broad peaks. The value is small.

[0061] Furthermore, a second reference is set, namely 0.7 of the maximum eigenvalue on the multi-scale characteristic spectral line. This setting corresponds to the truly significant part of the multi-scale characteristic spectral line, which can more rigorously identify the key scale without being disturbed by minor fluctuations. It is high enough to exclude background noise, but not too high to miss minor defects, thus forming an ideal balance point.

[0062] Furthermore, based on the aforementioned second reference, the distribution density of high-value features across scales satisfies the following relationship:

[0063]

[0064] In the formula, For pixels High non-uniform distribution coefficients on multi-scale characteristic spectral lines For pixels The eigenvalues ​​on the multi-scale characteristic spectral lines are greater than the number of scales of the second reference. This represents the total number of scales on the multi-scale characteristic spectral lines.

[0065] High values ​​of defect spectral lines only appear at a few key scales. If the value is small, such as when only the first scale is significant, then... The values ​​are large; the high values ​​of the background spectral lines are evenly distributed across multiple scales.

[0066] Furthermore, the product of the calculated half-peak width and the high-value non-uniform distribution coefficient is used as the scale locality of the multi-scale feature spectral lines of the pixel.

[0067] When scale locality approaches 1, it indicates that the energy of the feature spectral lines of the pixel is highly concentrated in a few key scales, which is very likely a defect; when scale locality approaches 0, it indicates that the energy is dispersed or not significantly concentrated, which is mostly background or noise.

[0068] In another embodiment, the distribution of contrast feature energy at each scale is calculated, and then the scale entropy is calculated. The reciprocal of the scale entropy is used as the scale locality of the multi-scale feature spectral lines of the pixel. The energy proportion at small scales is significantly higher than that at neighboring scales, the entropy value drops sharply, and the reciprocal increases dramatically, highlighting the defect.

[0069] Finally, based on the above operations, the peak significance and scale locality of the multi-scale feature spectral lines of all pixels are obtained.

[0070] S3: Combine the peak saliency and the scale locality to calculate the defect saliency score of each pixel, combine the defect saliency scores of all pixels to construct a defect saliency map, perform binarization processing on the defect saliency map, determine the pixels with defect saliency scores higher than a preset threshold as defect points, construct defect regions, and mark the position of the defect on the grayscale image according to the defect regions.

[0071] In one embodiment, the product of the peak saliency of the multi-scale feature spectral lines of a pixel and the scale locality is used as the defect saliency score of that pixel.

[0072] In another embodiment, corresponding weights are assigned to peak significance and scale locality, such as assigning a weight value of 0.6 to peak significance and a weight value of 0.4 to scale locality. These two weights are the initial weights and can be adjusted to the optimal values ​​through cross-validation.

[0073] Alternatively, a defect saliency map can be constructed by combining the defect saliency scores of all pixels.

[0074] Then, the mean and standard deviation of the defect saliency scores of all pixels are calculated. A threshold based on the normal distribution assumption is set according to the mean and standard deviation. The defect saliency map is then binarized according to the threshold, and pixels with defect saliency scores higher than the threshold are identified as defect points.

[0075] The binarized image is further labeled with connected components to extract independent defect regions. For each defect region, its minimum bounding rectangle is calculated and drawn on the grayscale image to mark the location of the defect.

[0076] This completes the defect detection of the casting surface. Subsequent analysis and maintenance operations can be formulated based on the location of the defects.

[0077] Reference Figure 2 The system includes a processor and a memory, the memory storing computer program instructions, which, when executed by the processor, implement the casting surface defect detection method according to the first aspect of the present invention.

[0078] The system also includes other components well known to those skilled in the art, such as communication buses and communication interfaces, the settings and functions of which are known in the art and will not be described in detail here.

[0079] It should be noted that those skilled in the art can make various modifications and improvements without departing from the inventive concept, and these all fall within the scope of protection of this invention. Therefore, the scope of protection of this patent should be determined by the appended claims.

Claims

1. A method of casting surface defect detection, characterized by, The method comprises the following steps: acquiring a gray image of a casting surface to be detected, and constructing a multi-scale contrast feature cube on the gray image based on a pre-defined set of analysis window scales; based on each pixel point in the cube, extracting a contrast feature sequence of the pixel point along the scale dimension to form a multi-scale feature spectrum line of the pixel point, and calculating a peak saliency and a scale locality of the multi-scale feature spectrum line; combining the peak saliency and the scale locality to calculate a defect saliency score of each pixel point, combining defect saliency scores of all pixel points to construct a defect saliency map, performing binary processing on the defect saliency map, determining pixel points with a defect saliency score higher than a pre-set threshold as defect points, and constructing a defect region, and marking the position of the defect on the gray image according to the defect region.

2. The method of claim 1, wherein The set is defined as a set containing multiple odd side lengths as analysis window scales.

3. The method of claim 2, wherein the step of determining the surface defect is performed by using a neural network. The construction process of the cube comprises the following steps: for each scale in the set, constructing an analysis window with each pixel point in the gray image as the center, acquiring a gray level co-occurrence matrix in the analysis window, calculating a contrast feature value of the analysis window based on the gray level co-occurrence matrix, and traversing all pixel points in the gray image to generate a complete contrast feature map under the analysis window; stacking the complete contrast feature maps under all analysis windows along the scale dimension to record the contrast feature values of each spatial position under all analysis windows, and thus forming a multi-scale contrast feature cube.

4. The method of claim 3, wherein The peak saliency acquisition process comprises the following steps: calculating the mean of the Pearson correlation coefficients of the multi-scale feature spectrum line of the pixel point and the multi-scale feature spectrum lines of the eight-neighborhood of the pixel point as the spatial consistency of the pixel point, obtaining the local maximum value point of the multi-scale feature spectrum line according to a pre-set identification condition, and counting the maximum value and the median on the multi-scale feature spectrum line; multiplying the ratio of the maximum value to the median of the feature values on the multi-scale feature spectrum line, the spatial consistency, and the number of the local maximum value points of the multi-scale feature spectrum line to obtain the peak saliency of the multi-scale feature spectrum line of the pixel point.

5. A method of casting surface defect detection according to claim 4, wherein, The scale locality acquisition process comprises the following steps: based on the distribution of the contrast feature values on the multi-scale feature spectrum line, multiplying the calculated half-peak width and the high-value non-uniform distribution coefficient to obtain the scale locality of the multi-scale feature spectrum line of the pixel point.

6. The method of claim 4, wherein the step of determining the surface defect is performed by using a neural network. The scale locality acquisition process comprises the following steps: calculating the distribution of the contrast feature value energy at each scale, and then calculating the scale entropy, and taking the inverse of the scale entropy as the scale locality of the multi-scale feature spectrum line of the pixel point.

7. The method of claim 1, wherein The defect saliency score acquisition process comprises the following steps: multiplying the peak saliency and the scale locality to obtain the defect saliency score.

8. The method of claim 1, wherein, The defect saliency score acquisition process comprises the following steps: assigning corresponding weights to the peak saliency and the scale locality respectively, and obtaining the defect saliency score by weighted summation of the peak saliency and the scale locality.

9. A casting surface defect detection system characterized by, The method comprises the following steps: a processor and a memory, the memory storing computer program instructions, when the computer program instructions are executed by the processor, realizing the casting surface defect detection method according to any one of claims 1-8.

Citation Information

Patent Citations

  • Defect detection method for high-strength stamping part

    CN117830139A

  • Visual detection method and system for parts for powder metallurgy processing

    CN120672747A