Visual inspection method for mold defects

By analyzing the gradient amplitude difference and quantifying artifact index of mold images, the image degradation problem caused by mechanical vibration and high-contrast texture in the visual inspection of mold defects was solved, achieving high-quality defect detection and improving the reliability and accuracy of the inspection.

CN120953279AActive Publication Date: 2025-11-14LIMING VOCATIONAL UNIV

Patent Information

Application Number
CN202511476328.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-16
Publication Date
2025-11-14
Estimated Expiration
2045-10-16

Smart Images

  • Figure CN120953279A_ABST
    Figure CN120953279A_ABST
Patent Text Reader

Abstract

The invention discloses a mold defect visual inspection method, particularly relates to the technical field of industrial machine visual inspection, and is used for solving the technical problem of image spatial variation blurring caused by mechanical vibration under a mobile shooting condition. The method comprises the following steps: acquiring a to-be-detected image on the surface of a mold, analyzing the gradient magnitude of each region, determining the fuzzy characteristics of different regions in the to-be-detected image according to the difference of the gradient magnitudes, evaluating the expected confidence of each region for executing the deblurring operation based on the fuzzy characteristics, and executing the deblurring operation on the regions to obtain a preliminary restored image; an artifact index is calculated in the uniform background area of the preliminary restored image, the distribution concentration degree of image components in each local feature area in the frequency domain is analyzed in the preliminary restored image, and the distribution concentration degree is compared with a preset defect judgment threshold value adjusted according to the artifact index; judging whether the corresponding local feature region is a defect region or not; accurate recognition of mold surface defects under complex imaging conditions is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of industrial machine vision inspection technology, and in particular to a method for visual inspection of mold defects. Background Technology

[0002] In the industrial manufacturing sector, the health of molds directly determines the quality of the final product. To achieve real-time monitoring and predictive maintenance of mold conditions during production, online automatic inspection methods based on machine vision have become an industry trend. This method typically uses image acquisition devices mounted on robotic arms or mobile platforms to capture images of the mold cavity surface within the production line cycle, and then uses image processing and analysis algorithms to identify various defects. The effectiveness of this method is highly dependent on the quality of the acquired images.

[0003] However, during online inspection, the image acquisition unit is in continuous motion. Its highly dynamic start-up, shutdown, and positioning processes introduce broadband mechanical vibrations. These vibrations are transmitted to the image sensor, causing unpredictable and non-uniform relative micro-motions between the sensor and the target on the mold surface at the moment of exposure. More importantly, the high-contrast micro-textures inherent on the mold cavity surface (such as machining marks) interact with the aforementioned complex micro-motions, resulting in significant spatial heterogeneity in the generated image degradation model (i.e., point spread function). This severely damages the integrity of key discriminative features such as the edges and contours of the defect target, leading to a significant reduction in the detection rate and classification accuracy of subsequent recognition algorithms for minor defects, failing to meet the stringent reliability requirements of industrial inspection. Summary of the Invention

[0004] This invention addresses the technical problems existing in the prior art by providing a visual inspection method for mold defects.

[0005] The technical solution of the present invention to solve the above-mentioned technical problems is as follows: A visual inspection method for mold defects includes: S1. Obtain the image of the mold surface to be inspected through the image acquisition device mounted on the mobile platform; S2. Analyze the gradient magnitude of each region in the image to be detected, and determine the blur characteristics of different regions in the image to be detected based on the differences in gradient magnitude. S3. Evaluate the expected confidence level of each region based on its blur characteristics to perform deblurring operation, and perform deblurring operation on each region based on the expected confidence level to obtain a preliminary restored image; S4. Calculate the information entropy values ​​of multiple local windows in different directions in the uniform background region of the initially restored image, and calculate the anisotropy ratio of local entropy based on the information entropy values. Quantify the anisotropy ratio into an artifact index. S5. Delineate multiple local feature regions in the preliminary restored image and analyze the degree of concentration of image components in the frequency domain within each local feature region. S6. Compare the degree of distribution concentration with the preset defect judgment threshold adjusted according to the artifact index to determine whether the corresponding local feature region is a defect region.

[0006] Furthermore, the image to be inspected on the surface of the mold is acquired through an image acquisition device mounted on the mobile platform, including: Control the mobile platform to move along the preset scanning path to the detection point on the mold surface; When the mobile platform is stably stationed at the detection site, the image acquisition device is triggered to acquire the image of the mold surface to be inspected with predetermined exposure parameters.

[0007] Furthermore, the process of acquiring the image to be detected includes controlling the light source to illuminate the mold surface at a constant illuminance and angle.

[0008] Furthermore, the gradient magnitude of each region in the image to be detected is analyzed, and the blurring characteristics of different regions in the image to be detected are determined based on the differences in gradient magnitude, including: The Sobel operator is used to calculate the horizontal and vertical gradient values ​​of each pixel in the image to be detected. Calculate the gradient magnitude of the corresponding pixel based on the horizontal and vertical gradient values ​​of each pixel; The image to be detected is divided into multiple rectangular regions of the same size, and the average gradient magnitude of all pixels in each rectangular region is calculated. The blur characteristics of different regions in the image to be detected are determined based on the difference in the average gradient magnitude of multiple rectangular regions.

[0009] Furthermore, based on the differences in the average gradient magnitudes of multiple rectangular regions, the blurring characteristics of different regions in the image to be detected are determined, including: Regions with average gradient magnitude below a first preset threshold are defined as highly blurred regions, regions with average gradient magnitude between the first preset threshold and the second preset threshold are defined as moderately blurred regions, and regions with average gradient magnitude above the second preset threshold are defined as lowly blurred regions.

[0010] Furthermore, the expected confidence level of performing deblurring operations on each region based on its blurring characteristics is evaluated. Based on the expected confidence level, deblurring operations are performed on each region to obtain a preliminary restored image, including: For each region with determined fuzzy characteristics, calculate its structure tensor at multiple different integral scales; Eigenvalue decomposition is performed on the structural tensor at each integral scale to extract the principal eigenvalues ​​of each structural tensor. Arrange all principal eigenvalues ​​under the integral scale in scale order to form the eigenvalue trajectory; The standard deviation of the eigenvalue trajectory is calculated as a quantitative indicator of trajectory stability; The quantitative index of trajectory stability is compared with the stability threshold. Regions where the quantitative index of trajectory stability is less than or equal to the stability threshold are given a high confidence rating, while regions where the quantitative index of trajectory stability is higher than the stability threshold are given a low confidence rating. Standard deblurring is performed on high-confidence-rating regions, while weakened deblurring is performed on low-confidence-rating regions, ultimately yielding a preliminary restored image.

[0011] Furthermore, the Lucy-Richardson deconvolution algorithm is used to perform standard deblurring for high-confidence rating regions, while the Lucy-Richardson deconvolution algorithm with reduced iterations is used to perform weakened deblurring for low-confidence rating regions.

[0012] Furthermore, the information entropy values ​​of multiple local windows in different directions are calculated in the uniform background region of the initially restored image, and the anisotropy ratio of the local entropy is calculated based on the information entropy values. The anisotropy ratio is quantified into an artifact index, including: In the preliminary restored image, regions with gray-level variance lower than the variance threshold are selected as uniform background regions. Multiple local windows are arranged in a sliding manner within a uniform background area; For each local window, calculate its gray-level co-occurrence matrix in the four directions of 0 degrees, 45 degrees, 90 degrees and 135 degrees; Calculate the information entropy value for each direction based on the gray-level co-occurrence matrix in each direction; For each local window, calculate the standard deviation of its information entropy values ​​in four directions; The average standard deviation of all local windows is quantified as an artifact index.

[0013] Furthermore, multiple local feature regions are delineated in the initially restored image, and the degree of concentration of image components in the frequency domain within each local feature region is analyzed, including: The initially restored image is divided into multiple non-overlapping rectangular regions as local feature regions; A two-dimensional fast Fourier transform is performed on the image grayscale values ​​within each local feature region to obtain the corresponding frequency domain spectrum; Calculate the energy distribution of each frequency domain spectrum; Calculate the entropy value of the energy distribution of the corresponding frequency domain spectrum based on the energy distribution of each frequency domain spectrum; The calculated energy distribution entropy value is used as a quantitative indicator of the degree of concentration of image components in the frequency domain within the corresponding local feature region.

[0014] Furthermore, the degree of distribution concentration is compared with a preset defect judgment threshold adjusted according to the artifact index to determine whether the corresponding local feature region is a defect region, including: The energy distribution entropy value corresponding to each local feature region is obtained as a quantitative indicator of the degree of distribution concentration; Obtain artifact metrics; Multiply the artifact index by the normalized weighting coefficient to obtain the normalized artifact impact factor; The adjusted judgment threshold is obtained by adding the preset defect judgment threshold to the normalized artifact influence factor. Compare the energy distribution entropy value of each local feature region with the adjusted judgment threshold; When the energy distribution entropy value of a local feature region is lower than the adjusted judgment threshold, the corresponding local feature region is judged as a defect region.

[0015] The beneficial effects of this invention are: 1. By analyzing the gradient amplitude differences in different regions of the image to be detected, the fuzzy characteristics of spatial changes can be accurately identified, effectively solving the problem of non-uniform fuzziness caused by mechanical vibration. Based on the fuzzy characteristics, the expected confidence of the defuzzing operation is evaluated, realizing differentiated processing of different regions. This can effectively restore the edge and contour features of defects, while avoiding the loss of details caused by over-processing. It significantly improves the integrity of key discrimination information in the image and provides a high-quality image foundation for subsequent accurate detection.

[0016] 2. By quantifying the artifact index generated during the deblurring process, a scientific artifact evaluation system was established. Based on this index, the defect judgment threshold was dynamically adjusted, which can effectively distinguish between real defects and artifact features introduced by the algorithm. While maintaining the sensitivity to detect minor defects, the risk of misjudgment was greatly reduced. This effectively overcame the limitations of the traditional fixed threshold method, significantly improved the reliability and accuracy of the detection results, and fully met the dual requirements of industrial inspection for stability and accuracy. Attached Figure Description

[0017] Figure 1 This is a flowchart of a visual inspection method for mold defects according to the present invention.

[0018] Figure 2 This is a flowchart for generating a preliminary restored image for this invention. Detailed Implementation

[0019] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0020] like Figure 1 As shown, the present invention provides a visual inspection method for mold defects, comprising: S1. Obtain the image of the mold surface to be inspected through the image acquisition device mounted on the mobile platform; S2. Analyze the gradient magnitude of each region in the image to be detected, and determine the blur characteristics of different regions in the image to be detected based on the differences in gradient magnitude. S3. Evaluate the expected confidence level of each region based on its blur characteristics to perform deblurring operation, and perform deblurring operation on each region based on the expected confidence level to obtain a preliminary restored image; S4. Calculate the information entropy values ​​of multiple local windows in different directions in the uniform background region of the initially restored image, and calculate the anisotropy ratio of local entropy based on the information entropy values. Quantify the anisotropy ratio into an artifact index. S5. Delineate multiple local feature regions in the preliminary restored image and analyze the degree of concentration of image components in the frequency domain within each local feature region. S6. Compare the degree of distribution concentration with the preset defect judgment threshold adjusted according to the artifact index to determine whether the corresponding local feature region is a defect region.

[0021] S1. Acquire the image of the mold surface to be inspected using the image acquisition device mounted on the mobile platform. Specific implementation includes: First, based on the 3D model of the mold to be inspected and the pre-set inspection plan, a preset scanning path for the mobile platform is generated. This preset scanning path contains a series of sequentially arranged spatial coordinates of inspection points, ensuring complete coverage of all surface areas of the mold to be inspected. The mobile platform is driven by a high-precision servo motor and moves precisely along the preset scanning path according to the position commands issued by the control system. When the spatial 3D deviation between the optical center point of the image acquisition device on the mobile platform and the coordinates of the target inspection point is less than the system's allowable positioning tolerance, such as less than 10 micrometers, it is determined that the mobile platform has accurately moved to the inspection point.

[0022] After the mobile platform stabilizes at the detection site, it does not immediately trigger image acquisition, but enters a short stabilization waiting period, for example, the waiting time is set to 100 milliseconds. During this period, the system continuously monitors the residual vibration amplitude of the platform through the high-sensitivity vibration sensor on the platform. When the monitored vibration amplitude is continuously lower than the preset stabilization threshold, for example, continuously lower than 0.5 micrometers per second for 50 milliseconds, it is determined that the mobile platform has reached a stable state, and then the control system sends a trigger acquisition signal to the image acquisition device.

[0023] Upon receiving a trigger signal, the image acquisition device calls a pre-stored set of predetermined exposure parameters for image acquisition. This set of predetermined exposure parameters is determined in advance through systematic calibration experiments. The specific setting process includes: under strictly identical standard light source illumination conditions, using a standard test block of typical material on the mold surface as the object, conducting multiple sets of shooting experiments with different exposure times, aperture sizes, and gain values; by analyzing the statistical characteristics of the grayscale histogram of the acquired images, selecting the set of parameters that makes the overall grayscale mean of the image fall within the middle range of the camera's dynamic range, such as 40% to 60%, and has the largest grayscale standard deviation, as the final predetermined exposure parameters. For example, the specific settings are an exposure time of 20 milliseconds, an aperture value of F8, and a gain value of 1.0. The acquisition device controls the optical lens and sensor based on this set of parameters to complete the acquisition and digital conversion of a single image to be detected.

[0024] Throughout the image acquisition process, the illumination conditions of the light source are strictly controlled. A high color rendering ring-shaped LED white light source is used, powered by a high-precision constant current source to ensure high stability of the luminous intensity. The illuminance value of the light source is measured at typical locations on the mold surface using a calibrated illuminance meter and fed back to the light source controller in real time. A closed-loop control algorithm stabilizes the illuminance at a preset value, such as 1000 lux, with fluctuations controlled within ±3%. Simultaneously, the light source is firmly fixed by a high-rigidity mechanical bracket, ensuring that its light-emitting plane forms a fixed angle with the normal direction of the mold surface, such as 45 degrees. This angle is calibrated using a high-precision digital angle meter and mechanically locked during system installation and debugging, ensuring that the illumination angle and illuminance received by each detection point remain constant throughout the scanning and acquisition process, thus providing consistent and reliable input for subsequent image processing and analysis.

[0025] S2. Analyze the gradient magnitude of each region in the image to be detected, and determine the blur characteristics of different regions in the image to be detected based on the differences in gradient magnitude. Specific implementation includes: After obtaining the image to be detected, the image blur characteristics are analyzed. First, the Sobel operator is used to calculate the gradient component of each pixel in the image. Specifically, a 3-pixel × 3-pixel horizontal convolution kernel is used to convolve the image. The kernel values ​​are configured such that the left column is -1, the middle column is 0, and the right column is 1. This convolution operation yields the gradient value of each pixel in the horizontal direction. Simultaneously, a 3-pixel × 3-pixel vertical convolution kernel is used to convolve the image. The kernel values ​​are configured such that the top row is -1, the middle row is 0, and the bottom row is 1. This convolution operation yields the gradient value of each pixel in the vertical direction. The gradient values ​​in both directions are signed scalars, and their magnitude reflects the degree of grayscale change of the pixel in that direction.

[0026] After obtaining the horizontal and vertical gradient values ​​of each pixel, the gradient magnitude of that pixel is obtained by calculating the square root of the sum of the squares of these two gradient values. The specific calculation process is as follows: multiply the horizontal gradient value by itself, multiply the vertical gradient value by itself, add the two products together, and then take the square root of the sum. This calculation process is performed on each pixel in the image one by one, and finally a gradient magnitude map with the same size as the original image to be detected is obtained. Each pixel value in this map represents the gradient magnitude at the corresponding position in the original image. Its value is a non-negative scalar. The larger the value, the more obvious the image edge or texture features at that point.

[0027] After calculating the gradient magnitude of the entire image, the entire image to be detected is divided into multiple rectangular regions of the same size. The determination of the size of the rectangular regions requires a trade-off between analysis accuracy and computational efficiency. For example, 32 pixels × 32 pixels can be chosen as the size of a rectangular region. When dividing, start from the first pixel in the upper left corner of the image and move to the right and down with a fixed step size to ensure that each rectangular region does not overlap and can completely cover the entire image. For the parts of the right and lower edges of the image that are not covered by the complete rectangular regions, the pixels are supplemented by mirror filling, that is, by copying the pixel values ​​of the image edges to form complete rectangular regions.

[0028] For each rectangular region obtained by division, calculate the arithmetic mean of the gradient magnitudes of all pixels contained within it; this average value represents the average edge strength or texture richness of the image content within the rectangular region; during the calculation, the gradient magnitudes of each pixel within the region are added together and then divided by the total number of pixels in the region to obtain the average gradient magnitude; this calculation process is performed on all rectangular regions to obtain a list containing the average gradient magnitudes of all rectangular regions.

[0029] After obtaining the average gradient magnitude of all rectangular regions, a first preset threshold and a second preset threshold are set based on the statistical distribution characteristics of these values ​​to distinguish the degree of blur. The specific setting method is as follows: collect the average gradient magnitude of all rectangular regions, arrange these values ​​in ascending order, calculate the cumulative percentage of each value in the sorted sequence, and use the average gradient magnitude at a cumulative percentage of 25% as the first preset threshold and the average gradient magnitude at a cumulative percentage of 75% as the second preset threshold. This threshold determination method based on statistical quantiles can adapt to the contrast characteristics of different images and ensure that the threshold setting matches the image content.

[0030] Finally, based on the relationship between the average gradient magnitude of each rectangular region and the two thresholds, its blurring characteristics are classified. Rectangular regions with an average gradient magnitude lower than the first preset threshold are marked as highly blurred regions, which typically correspond to flat surfaces lacking texture features in the image. Rectangular regions with an average gradient magnitude greater than or equal to the first preset threshold and less than or equal to the second preset threshold are marked as moderately blurred regions, which typically correspond to transitional regions in the image with some texture but unclear details. Rectangular regions with an average gradient magnitude higher than the second preset threshold are marked as low-blurred regions, which typically correspond to feature regions in the image with clear edges and obvious textures. Through this classification method, different regions in the image to be detected are quantitatively divided according to their blurring characteristics, providing a basis for subsequent targeted deblurring processing. The entire analysis process is based entirely on the gradient features of the image itself and can automatically determine the blurring characteristics of all regions without manual intervention.

[0031] Figure 2 The flowchart of the present invention for generating a preliminary restored image is given. In step S3, the expected confidence level of each region for performing deblurring operation based on its blurring characteristics is evaluated. Based on the expected confidence level, deblurring operation is performed on each region to obtain a preliminary restored image. The specific implementation includes: After determining the blur characteristics of each region in the image to be detected, the expected confidence level of the deblurring operation is evaluated, followed by a differential processing procedure based on the evaluation results. For each region with determined blur characteristics, its structure tensor at multiple different integration scales needs to be calculated first. The choice of integration scale depends on the specific region size and degree of blur. For example, for a 32-pixel × 32-pixel region, five different integration scales can be selected: 3-pixel × 3-pixel, 5-pixel × 5-pixel, 7-pixel × 7-pixel, 9-pixel × 9-pixel, and 11-pixel × 11-pixel. The structure tensor is calculated as follows: First, the horizontal and vertical gradient values ​​of each pixel within the region are calculated using Sobel... The operator calculates the gradient value, then multiplies the horizontal gradient value of each pixel by itself to obtain the squared horizontal gradient value of that pixel. The horizontal gradient value of each pixel is multiplied by the vertical gradient value to obtain the mixed gradient product value. The vertical gradient value of each pixel is multiplied by itself to obtain the squared vertical gradient value of that pixel. Finally, within the selected integration scale window, Gaussian weighted summation is performed on these three calculated values. The standard deviation of the Gaussian weighting is set to one-sixth of the integration scale size. In this way, the structure tensor matrix at each scale is obtained. This matrix is ​​a 2×2 symmetric matrix.

[0032] Eigenvalue decomposition is performed on the structure tensor matrix calculated at each integral scale. Eigenvalue decomposition is achieved by solving the characteristic equation, that is, calculating the eigenvalues ​​when the determinant of the matrix is ​​zero. The specific calculation process is as follows: For the four elements of the structure tensor matrix, denoted as a, b, c, and d, where a is the Gaussian weighted sum of the squared gradients in the horizontal direction, b and c are the Gaussian weighted sum of the mixed gradient products, and d is the Gaussian weighted sum of the squared gradients in the vertical direction, the eigenvalues ​​of the characteristic equation are solved, and the larger of the two eigenvalues ​​is taken as the principal eigenvalue at that scale. The principal eigenvalue reflects the main intensity information of the image structure at that scale, and its value is positively correlated with the image texture sharpness at that scale.

[0033] Arrange all principal eigenvalues ​​at all integral scales in ascending order of scale to form a numerical sequence, called the eigenvalue trajectory. This trajectory describes the regularity of image structure intensity changes with the observation scale. The standard deviation of this eigenvalue trajectory is calculated as a quantitative indicator of trajectory stability. The calculation process is as follows: first, calculate the arithmetic mean of all principal eigenvalues; then, square the difference between each principal eigenvalue and the arithmetic mean, calculate the arithmetic mean of these squared values, and finally take the square root of the arithmetic mean. The smaller the value of this indicator, the more stable the eigenvalue trajectory.

[0034] The stability threshold is set based on statistical analysis of a large number of sample images. For example, 1000 images of mold surfaces with different degrees of blur can be collected, and the standard deviation of the feature value trajectory of each region can be calculated. These standard deviations are arranged in ascending order, and the value at the 85th percentile of the arrangement is taken as the stability threshold. The stability threshold obtained by this method is usually between 0.15 and 0.25, and the specific value depends on the image acquisition conditions and the characteristics of the mold surface. The quantitative index of trajectory stability for each region is compared with this stability threshold. Regions with a quantitative index of trajectory stability less than or equal to the stability threshold are given a high confidence rating, indicating that the structural features of the region are stable at different scales and are suitable for strong deblurring processing. Regions with a quantitative index of trajectory stability greater than the stability threshold are given a low confidence rating, indicating that the structural features of the region change significantly with scale and require a more conservative deblurring strategy.

[0035] For regions receiving high confidence ratings, the Lucy-Richardson deconvolution algorithm was used to perform standard deblurring. This standard operation involved 50 iterations, with the point spread function (PSF) size set to 7 pixels × 7 pixels, the PSF being Gaussian, and the standard deviation of the Gaussian function set to 2.0. For regions receiving low confidence ratings, a weakened deblurring operation was performed using the Lucy-Richardson deconvolution algorithm with reduced iterations (10 iterations). The PSF size remained unchanged at 7 pixels × 7 pixels, but the standard deviation of the Gaussian function was increased to 3.0 to reduce the intensity of the deblurring. After processing all regions, the results were reassembled according to their original positional relationships to obtain a complete preliminary restored image. This image retains the detailed features of clear regions while avoiding over-processing of blurred regions, providing a higher-quality input image for subsequent defect detection analysis. The entire processing is based entirely on adaptive parameter adjustments according to the image content characteristics, achieving differentiated processing for different regions without manual intervention.

[0036] Step S3 assesses the deblurring confidence by analyzing the stability of the eigenvalue trajectories of the multi-scale structural tensor. It recognizes that regions where structural features remain stable at different observation scales have reliable image structures and are suitable for strong deblurring; while regions with large fluctuations in eigenvalues ​​may contain noise or inherent blur, and blindly strengthening deblurring will amplify distortion. This approach abandons the conventional method of applying a uniform deblurring strategy to all regions, and instead makes adaptive decisions based on the structural stability of the image content itself, thereby achieving a better balance between enhancing texture details and suppressing artifact noise, effectively solving the common problem of secondary damage introduced by excessive deblurring in existing technologies.

[0037] S4. Calculate the information entropy values ​​of multiple local windows in different directions within the uniform background region of the initially restored image, and calculate the anisotropy ratio of the local entropy based on the information entropy values. Quantify the anisotropy ratio into an artifact index. Specific implementation includes: After obtaining the preliminary restored image, the artifact index quantification process is performed. First, regions with gray-level variance below the variance threshold in the preliminary restored image are selected as uniform background regions. The variance threshold is determined as follows: calculate the gray-level variance values ​​of all possible regions in the preliminary restored image, arrange these variance values ​​in ascending order, and take the value at the 10th percentile of the arrangement as the variance threshold. The variance threshold obtained in this way can ensure that the selected region has sufficient uniformity. For example, for an 8-bit grayscale image, this threshold is usually between 15 and 25 gray-level squares, and the specific value depends on the actual content characteristics of the image.

[0038] After determining the uniform background region, multiple local windows are placed in these regions using a sliding method. The size of the local windows needs to be chosen by balancing computational accuracy and feature representation capability. For example, 16 pixels × 16 pixels can be chosen as the size of the local window. The sliding step size is set based on the window size, usually set to half of the window size. For example, when the window size is 16 pixels × 16 pixels, the sliding step size is set to 8 pixels. When placing the windows, start from the first pixel at the top left corner of the uniform background region and move to the right and down with a fixed sliding step size to ensure that the entire uniform background region is covered. For positions where the edge of the region cannot accommodate a complete window, a mirror filling method is used to supplement the pixels.

[0039] For each local window, calculate its gray-level co-occurrence matrix in four directions: 0 degrees, 45 degrees, 90 degrees, and 135 degrees. During the calculation, first determine the distance parameter between pixel pairs, which is typically set to 1 pixel. For the 0-degree direction, count the frequency of gray values ​​of all horizontally adjacent pixel pairs in the window, i.e., the gray-level combination of each pixel with its right-hand neighbor. For the 45-degree direction, count the frequency of gray values ​​of all adjacent pixel pairs from the upper right to the lower left in the window, i.e., the gray-level combination of each pixel with its upper right-hand neighbor. For the 90-degree direction... In the 135-degree direction, the gray-level co-occurrence matrix is ​​the frequency of gray-level values ​​of all vertically adjacent pixel pairs in the statistical window, i.e., the gray-level combination of each pixel with its lower adjacent pixel. In the 135-degree direction, the gray-level co-occurrence matrix is ​​the frequency of gray-level values ​​of all adjacent pixel pairs from the upper left to the lower right in the statistical window, i.e., the gray-level combination of each pixel with its lower left adjacent pixel. The gray-level co-occurrence matrix in each direction is a 256×256 two-dimensional matrix, where the value of each element represents the frequency of the corresponding gray-level value combination in the specified direction and distance. The row index and column index of the matrix correspond to the gray-level values ​​of two pixels, respectively.

[0040] The information entropy value for each direction is calculated based on the gray-level co-occurrence matrix in each direction. The calculation process is as follows: First, divide each element value in the gray-level co-occurrence matrix by the sum of all element values ​​in the matrix to obtain a normalized probability distribution matrix. Then, for each probability value in the matrix, multiply the probability value by the negative value of the base-2 logarithmic probability value. Finally, sum all the calculation results. This calculation process is performed on the gray-level co-occurrence matrices in the four directions respectively to obtain the information entropy values ​​in the four directions. These entropy values ​​reflect the complexity and randomness of the image texture in different directions. The larger the entropy value, the more complex the texture.

[0041] For each local window, calculate the standard deviation of its four-directional entropy values. The standard deviation is calculated as follows: first, calculate the arithmetic mean of the four entropy values; then, square the difference between each entropy value and the arithmetic mean, calculate the arithmetic mean of these squared values, and finally take the square root of the arithmetic mean. The obtained standard deviation value reflects the degree of anisotropy of the texture direction distribution within the local window. The larger the value, the stronger the anisotropy; the smaller the value, the better the isotropy.

[0042] The arithmetic mean of the standard deviations of all local windows is calculated, and this mean is quantified as an artifact index. To calculate the arithmetic mean, the standard deviations of all local windows are summed and then divided by the total number of local windows. The resulting artifact index is a dimensionless value that reflects the severity of artificial artifacts introduced by the deblurring operation in the initially restored image. A higher value indicates more severe artifacts, while a lower value indicates better image quality. This artifact index will be used to adjust the defect detection threshold in subsequent steps to ensure that the accuracy of defect detection is not affected by deblurring artifacts. The entire calculation process is based entirely on the statistical characteristics of the image itself, requiring no external parameter input, thus achieving adaptive quantization evaluation.

[0043] Step S4 proposes an artifact quantification index based on the anisotropic ratio of texture in a uniform background region. Existing evaluation methods often focus on global sharpness improvement, neglecting the side effect that deblurring algorithms may introduce directional artificial textures (artifacts) into an originally uniform background. This method quantifies this unwanted directional bias by calculating the dispersion of texture entropy values ​​in multiple directions, transforming the subjective perception of artifacts into an objective metric. This allows subsequent defect assessment to proactively avoid "false features" introduced by the algorithm itself, significantly improving the accuracy and reliability of defect identification and resolving the technical bias of misclassifying artifacts as real defects.

[0044] S5. Delineate multiple local feature regions in the preliminary restored image and analyze the degree of concentration of image components in the frequency domain within each local feature region. Specific implementation includes: After obtaining the preliminary restored image, an analysis of the concentration of frequency domain distribution is performed. First, the preliminary restored image is divided into multiple non-overlapping rectangular regions as local feature regions. The size of the rectangular regions is selected based on the size range of typical defects on the mold surface and the image resolution characteristics. For example, 32 pixels × 32 pixels can be selected as the size of a local feature region. This size is determined by analyzing the size of the smallest detectable defect in historical defect data and taking 2 to 3 times it as the size of the local feature region. When dividing, start from the first pixel in the upper left corner of the image and divide to the right and down with the selected size as a fixed step size to ensure that each local feature region is completely independent and covers the entire image. For the remaining parts of the right and lower edges of the image that cannot form a complete rectangular region, a mirror expansion method is used to supplement pixels to form a complete local feature region. The specific method of mirror expansion is to copy the pixel values ​​at symmetrical positions with the image edge as the axis of symmetry.

[0045] A two-dimensional fast Fourier transform is performed on the image grayscale values ​​of each local feature region obtained by segmentation. Before the transform, the grayscale values ​​in the region are preprocessed to have their mean zeroed out, that is, the arithmetic mean of the grayscale values ​​of all pixels in the region is calculated, and then the grayscale value of each pixel is subtracted from the arithmetic mean. This preprocessing step can eliminate the influence of DC component on frequency domain analysis. The two-dimensional fast Fourier transform is implemented by row and column separation. First, a one-dimensional fast Fourier transform is performed on each row, and then a one-dimensional fast Fourier transform is performed on each column of the transform result to obtain the corresponding complex form frequency domain spectrum. The size of the frequency domain spectrum is the same as that of the local feature region and contains two components: real part and imaginary part.

[0046] The energy distribution of each frequency spectrum is calculated by calculating the square of the modulus of each frequency component in the frequency spectrum. The specific calculation process is as follows: for each complex element in the frequency spectrum, the real part value is multiplied by the real part value and the imaginary part value is multiplied by the imaginary part value to obtain the energy value of that frequency component. The energy values ​​of all frequency components are combined into a real number matrix of the same size as the frequency spectrum. This matrix is ​​the frequency energy distribution map of the local feature region. The magnitude of the energy value reflects the proportion of that frequency component in the image.

[0047] The energy distribution entropy value of the corresponding frequency domain spectrum is calculated based on the energy distribution of each frequency domain spectrum. Before calculation, each element value in the energy distribution matrix is ​​divided by the sum of all element values ​​in the matrix to obtain a normalized probability distribution matrix, ensuring that the sum of all probability values ​​is 1. The calculation process of the energy distribution entropy value is as follows: for each probability value in the normalized matrix, when the probability value is greater than zero, the probability value is multiplied by the negative value of the logarithm of the probability value with base 2, and when the probability value is equal to zero, the value of the term is zero. Then, all calculation results are summed. The magnitude of the energy distribution entropy value reflects the degree of concentration of energy in the frequency domain. The smaller the entropy value, the more concentrated the energy is in a few frequency components, and the larger the entropy value, the more dispersed the energy distribution.

[0048] The calculated energy distribution entropy value is used as a quantitative indicator of the concentration of image components in the frequency domain within the corresponding local feature region. This quantitative indicator can effectively characterize the texture characteristics of image content. For background regions with uniform texture, their frequency domain energy is usually more dispersed, and the energy distribution entropy value is larger. For regions containing defects, since defects usually exhibit local abnormal features, their frequency domain energy is often concentrated on specific frequency components, and the energy distribution entropy value is smaller. This quantitative indicator can distinguish between normal regions and potential defect regions, providing an important basis for subsequent defect judgment. The entire calculation process is based on mature digital image processing algorithms, which can ensure the accuracy and reliability of the analysis results.

[0049] S6. Compare the distribution concentration with the preset defect judgment threshold adjusted according to the artifact index to determine whether the corresponding local feature region is a defect region. Specific implementation includes: After quantifying the frequency domain distribution concentration, the defect region determination process is executed. First, the energy distribution entropy value corresponding to each local feature region is obtained as a quantitative indicator of the distribution concentration. This energy distribution entropy value is a numerical representation obtained by performing a two-dimensional fast Fourier transform on each 32-pixel × 32-pixel local feature region and calculating the frequency domain energy distribution entropy. At the same time, the artifact index is obtained by analyzing the texture anisotropy of the uniform background region. This artifact index is a dimensionless value obtained by calculating the average of the standard deviations of the information entropy values ​​of multiple 16-pixel × 16-pixel local windows in four directions, reflecting the severity of artificial artifacts introduced into the image by the deblurring operation.

[0050] The normalization weighting coefficient is set based on statistical analysis of a large amount of experimental data. The specific determination method is as follows: 200 mold surface image samples of different quality levels are collected, including 50 clear images, 50 images with mild artifacts, 50 images with moderate artifacts, and 50 images with severe artifacts. The artifact index value is calculated for each image, and the misjudged areas caused by artifacts are manually marked. The mathematical relationship between the artifact index value and the proportion of misjudged area is established through least squares regression analysis. 0.5 times the inverse of the slope of the regression curve is taken as the normalization weighting coefficient. This coefficient is usually between 0.1 and 0.3, for example, 0.2 can be taken. The role of the normalization weighting coefficient is to adjust the influence of the artifact index on the judgment threshold, ensuring that the threshold adjustment can effectively suppress artifact interference without excessively reducing the detection sensitivity.

[0051] The artifact index is multiplied by a normalized weighting coefficient to obtain the normalized artifact impact factor. This calculation process converts the absolute value of the artifact index into a relative degree of influence, so that artifact interference of different levels can affect the final judgment threshold in an appropriate proportion. The artifact impact factor is a dimensionless value, and its magnitude is proportional to the severity of the artifact. For example, when the artifact index is 1.5 and the normalized weighting coefficient is 0.2, the artifact impact factor is calculated as 1.5 × 0.2 = 0.3.

[0052] The determination of the preset defect judgment threshold is based on the statistical characteristics of normal mold surface images. The specific method is as follows: collect 500 known defect-free mold surface images, divide each image into a 32-pixel × 32-pixel local feature region, calculate the energy distribution entropy value of each region after two-dimensional fast Fourier transform, statistically analyze the distribution of these entropy values, and take the value at the 5th percentile after sorting all entropy values ​​by size as the initial preset defect judgment threshold. This threshold represents the lower limit of the energy distribution entropy value of the normal region. Regions below this value are likely to contain defects. For example, this threshold is usually between 2.5 and 3.5.

[0053] The preset defect judgment threshold is added to the normalized artifact influence factor to obtain the adjusted judgment threshold. The significance of this addition operation is that when there are severe artifacts in the image, appropriately increasing the judgment threshold can avoid misjudging the texture generated by artifacts as real defects. The adjusted judgment threshold is a dynamically changing value that can automatically adapt to the image quality. For example, when the preset defect judgment threshold is 3.0 and the artifact influence factor is 0.3, the adjusted judgment threshold is 3.0 + 0.3 = 3.3.

[0054] The energy distribution entropy value of each local feature region is compared with the adjusted judgment threshold. The comparison is made by directly comparing the numerical values. The smaller the energy distribution entropy value, the more concentrated the frequency domain energy is, and the more likely it is to contain defect features. A one-to-one correspondence is established during the comparison process, and each local feature region is compared with only one adjusted judgment threshold.

[0055] When the energy distribution entropy value of a certain local feature region is lower than the adjusted judgment threshold, the local feature region is judged as a defect region. This judgment logic is based on the following principle: the normal mold surface usually has a uniform texture distribution, its frequency domain energy is relatively dispersed, and the energy distribution entropy value is high; while the defect region has abnormal structure, its frequency domain energy is often concentrated on specific frequency components, and the energy distribution entropy value is low. Through this dynamic threshold adjustment mechanism, the risk of misjudgment caused by deblurring artifacts can be effectively reduced while ensuring detection sensitivity, thereby improving the accuracy and reliability of defect detection. All judgment results are output in the form of binary images, where defect regions are marked as 255 and non-defect regions are marked as 0.

[0056] Step S6 dynamically adjusts the defect judgment threshold by introducing an artifact index. While deblurring improves image clarity, it introduces directional artifacts. These artifacts have frequency domain characteristics similar to real defects, making false positives highly likely if a fixed threshold is used. By quantifying the severity of artifacts and adaptively adjusting the judgment threshold accordingly, an optimal balance is achieved between detection sensitivity and specificity. Compared to existing technologies that use static thresholds, this method effectively solves the false positive problem caused by algorithm side effects, significantly improving the accuracy and reliability of defect identification.

[0057] All calculations involved in the embodiments are dimensionless numerical calculations, and the preset parameters and thresholds in the calculations are set by those skilled in the art according to the actual situation.

[0058] It should be noted that this invention can be deployed on the device itself to realize embedded applications, or it can run on a PC or other terminal with a user interface, thereby meeting various hardware environments and usage requirements.

[0059] The above embodiments can be implemented, in whole or in part, by software, hardware, firmware, or any other combination thereof. When implemented using software, the above embodiments can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wireless or wired transmission; wired transmission methods include optical fiber, twisted pair, coaxial cable, etc.; wireless transmission includes infrared, microwave, etc. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center containing one or more sets of available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium. A semiconductor medium can be a solid-state drive.

[0060] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and modules described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0061] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or modules may be electrical, mechanical, or other forms.

[0062] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical modules; they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0063] In addition, the functional modules in the various embodiments of this application can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module.

[0064] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0065] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

[0066] In conclusion, the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A method for visual inspection of mold defects, characterized in that, include: S1. Obtain the image of the mold surface to be inspected through the image acquisition device mounted on the mobile platform; S2. Analyze the gradient magnitude of each region in the image to be detected, and determine the blur characteristics of different regions in the image to be detected based on the differences in gradient magnitude. S3. Evaluate the expected confidence level of each region based on its blur characteristics to perform deblurring operation, and perform deblurring operation on each region based on the expected confidence level to obtain a preliminary restored image; S4. Calculate the information entropy values ​​of multiple local windows in different directions in the uniform background region of the initially restored image, and calculate the anisotropy ratio of local entropy based on the information entropy values. Quantify the anisotropy ratio into an artifact index. S5. Delineate multiple local feature regions in the preliminary restored image and analyze the degree of concentration of image components in the frequency domain within each local feature region. S6. Compare the degree of distribution concentration with the preset defect judgment threshold adjusted according to the artifact index to determine whether the corresponding local feature region is a defect region.

2. The method for visual inspection of mold defects according to claim 1, characterized in that, The image to be inspected on the surface of the mold is acquired through an image acquisition device mounted on a mobile platform, including: Control the mobile platform to move along the preset scanning path to the detection point on the mold surface; When the mobile platform is stably stationed at the detection site, the image acquisition device is triggered to acquire the image of the mold surface to be inspected with predetermined exposure parameters.

3. The method for visual inspection of mold defects according to claim 2, characterized in that, The process of acquiring the image to be inspected includes controlling the light source to illuminate the mold surface at a constant illuminance and angle.

4. The method for visual inspection of mold defects according to claim 1, characterized in that, Analyze the gradient magnitude of each region in the image to be detected, and determine the blur characteristics of different regions in the image to be detected based on the differences in gradient magnitude, including: The Sobel operator is used to calculate the horizontal and vertical gradient values ​​of each pixel in the image to be detected. Calculate the gradient magnitude of the corresponding pixel based on the horizontal and vertical gradient values ​​of each pixel; The image to be detected is divided into multiple rectangular regions of the same size, and the average gradient magnitude of all pixels in each rectangular region is calculated. The blur characteristics of different regions in the image to be detected are determined based on the difference in the average gradient magnitude of multiple rectangular regions.

5. The method for visual inspection of mold defects according to claim 4, characterized in that, Based on the differences in the average gradient magnitudes of multiple rectangular regions, the blurring characteristics of different regions in the image to be detected are determined, including: Regions with average gradient magnitude below a first preset threshold are defined as highly blurred regions, regions with average gradient magnitude between the first preset threshold and the second preset threshold are defined as moderately blurred regions, and regions with average gradient magnitude above the second preset threshold are defined as lowly blurred regions.

6. The method for visual inspection of mold defects according to claim 1, characterized in that, Evaluate the expected confidence level of deblurring operations performed on each region based on its blur characteristics. Based on the expected confidence level, perform deblurring operations on each region to obtain a preliminary restored image, including: For each region with determined fuzzy characteristics, calculate its structure tensor at multiple different integral scales; Eigenvalue decomposition is performed on the structural tensor at each integral scale to extract the principal eigenvalues ​​of each structural tensor. Arrange all principal eigenvalues ​​under the integral scale in scale order to form the eigenvalue trajectory; The standard deviation of the eigenvalue trajectory is calculated as a quantitative indicator of trajectory stability; The quantitative index of trajectory stability is compared with the stability threshold. Regions where the quantitative index of trajectory stability is less than or equal to the stability threshold are given a high confidence rating, while regions where the quantitative index of trajectory stability is higher than the stability threshold are given a low confidence rating. Standard deblurring is performed on high-confidence-rating regions, while weakened deblurring is performed on low-confidence-rating regions, ultimately yielding a preliminary restored image.

7. The method for visual inspection of mold defects according to claim 6, characterized in that, For high-confidence rating regions, the Lucy-Richardson deconvolution algorithm is used to perform standard deblurring, while for low-confidence rating regions, the Lucy-Richardson deconvolution algorithm with reduced iterations is used to perform weakened deblurring.

8. The method for visual inspection of mold defects according to claim 1, characterized in that, In the uniform background region of the initially restored image, the information entropy values ​​of multiple local windows in different directions are calculated, and the anisotropy ratio of the local entropy is calculated based on the information entropy values. The anisotropy ratio is quantified into an artifact index, including: In the preliminary restored image, regions with gray-level variance lower than the variance threshold are selected as uniform background regions. Multiple local windows are arranged in a sliding manner within a uniform background area; For each local window, calculate its gray-level co-occurrence matrix in the four directions of 0 degrees, 45 degrees, 90 degrees and 135 degrees; Calculate the information entropy value for each direction based on the gray-level co-occurrence matrix in each direction; For each local window, calculate the standard deviation of its information entropy values ​​in four directions; The average standard deviation of all local windows is quantified as an artifact index.

9. The method for visual inspection of mold defects according to claim 1, characterized in that, In the preliminary restored image, multiple local feature regions are delineated, and the degree of concentration of image components in the frequency domain within each local feature region is analyzed, including: The initially restored image is divided into multiple non-overlapping rectangular regions as local feature regions; A two-dimensional fast Fourier transform is performed on the image grayscale values ​​within each local feature region to obtain the corresponding frequency domain spectrum; Calculate the energy distribution of each frequency domain spectrum; Calculate the entropy value of the energy distribution of the corresponding frequency domain spectrum based on the energy distribution of each frequency domain spectrum; The calculated energy distribution entropy value is used as a quantitative indicator of the degree of concentration of image components in the frequency domain within the corresponding local feature region.

10. A method for visual inspection of mold defects according to claim 1, characterized in that, The distribution concentration is compared with a preset defect judgment threshold adjusted according to the artifact index to determine whether the corresponding local feature region is a defect region, including: The energy distribution entropy value corresponding to each local feature region is obtained as a quantitative indicator of the degree of distribution concentration. Obtain artifact metrics; Multiply the artifact index by the normalized weighting coefficient to obtain the normalized artifact impact factor; The preset defect judgment threshold is added to the normalized artifact influence factor to obtain the adjusted judgment threshold. Compare the energy distribution entropy value of each local feature region with the adjusted judgment threshold. When the energy distribution entropy value of a local feature region is lower than the adjusted judgment threshold, the corresponding local feature region is judged as a defect region.

Citation Information

Patent Citations

  • Image deblurring method based on adaptive amplitude filtering and gradient enhancement

    CN120235783A

  • OLED mobile phone screen linear defect detection method and system

    CN120263891A

  • Outer wall visual inspection method and system based on deep learning

    CN120495942A

  • Battery pack injection mold production defect detection and identification method

    CN120765653A

  • System and method for defect detection using visible light cameras with synchronized lighting

    US20240354930A1

Cited By

  • Three-dimensional defect online detection device and method for high-temperature mold for disc casting machine

    CN121186066A

  • Box-type substation spraying quality detection method based on image processing

    CN121190474A

  • Aluminum alloy profile surface defect online identification system based on machine vision

    CN121599949A