Defect segmentation positioning method and system for inorganic mineral cast image

By analyzing the pixel brightness and brightness gradient of the casting surface, combined with local roughness weight and structural tensor analysis, and dynamically adjusting the exposure parameters, the problem of high reflectivity areas affecting the images of inorganic mineral castings was solved. This enabled accurate defect region segmentation and classification, improving the accuracy and reliability of defect location.

CN121073980BActive Publication Date: 2026-02-24SHANDONG CLAREMONT NEW MATERIAL TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511224984.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-08-29
Publication Date
2026-02-24
Estimated Expiration
2045-08-29

AI Technical Summary

Technical Problem

Existing technologies struggle to adapt to the influence of local high-reflectivity areas when processing images of inorganic mineral castings, leading to loss of image details and noise diffusion. This results in low accuracy, particularly in detecting small defects such as cracks and pores. Morphological operations in traditional methods cannot effectively preserve key features, affecting the accuracy of defect area identification.

Method used

By analyzing the pixel brightness matrix of the casting surface, a brightness gradient matrix and a high-reflectivity area identification matrix are constructed. Exposure time parameters are matched, and images are stitched together. Defect areas are identified by combining brightness gradient analysis and edge pixel connectivity. Local roughness weights and structural tensor matrices are calculated to identify the type of defect area and locate its actual spatial position.

Benefits of technology

Dynamically adjusting the exposure range reduces the loss of details in overexposed areas, improves the accuracy of defect area identification, enhances sensitivity to minor surface defects, and improves the accuracy and reliability of defect location.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121073980B_ABST
    Figure CN121073980B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of computer vision, in particular to a defect segmentation and positioning method and system for inorganic mineral castings, comprising the following steps: calling a light image to analyze brightness, matching exposure parameters and splicing images, analyzing a gradient to identify defects and screen effective areas, calculating a gray variance to construct a roughness weight to identify texture features, calculating a structure tensor and analyzing a direction to output defect type information, and combining target point actual coordinates to correct identified positions to generate positioning information, in the present application, by combining high reflection area identification, brightness gradient analysis, pixel-level roughness weight and structure tensor analysis, the exposure interval can be dynamically adjusted when processing casting images, the loss of details in overexposed areas is reduced, the identification accuracy of defect areas is improved, accurate area segmentation and classification processing is realized, the roughness weight calculation combining gray variance and pixel density enhances the sensitivity to surface micro-defects and improves the accuracy and reliability of defect positioning.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer vision technology, and in particular to a method and system for defect segmentation and localization of images of inorganic mineral castings. Background Technology

[0002] The field of computer vision technology encompasses various techniques for automatically analyzing and understanding targets in images or videos using computers. These techniques include image acquisition, image preprocessing, feature extraction, target recognition, and segmentation. The aim is to extract and classify information such as object shape, texture, color, and spatial location by performing structured analysis of pixel data in images. Applications include industrial inspection, medical image analysis, and autonomous driving. The development of computer vision technology involves the comprehensive design and implementation of aspects such as image imaging hardware configuration, light source layout optimization, image enhancement and denoising, region feature extraction, pixel-level annotation, and rule-based segmentation methods. Among them, the defect segmentation and localization method for inorganic mineral casting images refers to the detection method for defects such as cracks, pores, inclusions, and corner chips that occur on the surface of inorganic mineral castings after production or molding. This method involves acquiring images of the casting surface and segmenting and locating the defect area. The process includes first acquiring images of the casting surface using an industrial camera under fixed lighting conditions, then processing the images such as grayscale conversion, contrast enhancement, and filtering to remove noise. To highlight the defect features, a threshold segmentation combined with edge detection method is used to extract the contour of the defect area. Irrelevant noise is removed through morphological operations. Finally, the pixel coordinates of the defect area are mapped to the actual casting surface position to complete the accurate localization and labeling of the defect.

[0003] Existing technologies for processing images of inorganic mineral castings rely on overall exposure parameters, making it difficult to adapt to the influence of local high-reflectivity areas. This leads to the loss of details in highlight areas and the spread of noise. It is also difficult to accurately extract surface defect contours from complex textured backgrounds, especially in the detection of small defects such as cracks and pores, where the accuracy is low. Morphological operations in traditional methods have limited effect on noise suppression and cannot effectively preserve all key features, resulting in significant errors in defect area identification. This leads to insufficient detail in the processed image, affecting the accuracy of subsequent defect localization and causing distortion or omission of detection results in complex environments. Summary of the Invention

[0004] To address the technical problems existing in the prior art, embodiments of the present invention provide a defect segmentation and localization method for images of inorganic mineral castings, comprising the following steps:

[0005] To achieve the above objectives, the present invention adopts the following technical solution: a defect segmentation and localization method for images of inorganic mineral castings, comprising the following steps:

[0006] S1: Call the presampled illumination image, analyze the pixel brightness matrix of the casting surface, compare the brightness difference between adjacent pixels to construct the brightness gradient matrix, analyze the spatial aggregation mode to generate a high reflectivity region identification matrix, analyze the connected regions and match the exposure time parameters, and perform image stitching after imaging to generate a partitioned stitched image.

[0007] S2: Using the partitioned and stitched image, perform brightness gradient analysis, identify candidate defect regions by combining edge pixel connectivity, construct an energy distribution sequence based on the boundary gray-level gradient, analyze the change amplitude and peak concentration, screen effective defect regions, and obtain surface defect identification results.

[0008] S3: Based on the surface defect identification results, calculate the gray-level variance of the pixel neighborhood in the effective defect area, combine it with the pixel density, construct the local roughness weight and analyze the spatial distribution to form a roughness index and generate regional texture feature information.

[0009] S4: Based on the surface defect identification results and regional texture feature information, calculate the structure tensor matrix of the effective defect region in images at multiple scales, extract peak and valley feature values ​​and calculate the proportions, identify the defect region type by calculating the trend of principal axis direction changes at multiple scales, and generate crack direction analysis results.

[0010] S5: Using the surface defect identification results and crack direction analysis results, calculate the pixel coordinates of the target point in the image, calculate the difference between the pixel coordinates of the target point and the corresponding physical coordinates, and combine the radial and tangential distortion parameter fitting calculations to identify the actual spatial location of the defect and generate defect location information.

[0011] As a further aspect of the present invention, the partitioned stitched image includes pixel distribution information of high reflectivity areas, partitioned exposure parameter mapping information, and pixel matrix of the stitched image. The surface defect identification result specifically includes the effective defect region contour, defect boundary energy characteristics, and defect region connectivity data. The regional texture feature information includes a roughness spatial distribution map, a local roughness weight set, and texture directionality features. The crack direction analysis result specifically refers to the crack principal axis direction parameters, crack type labels, and crack direction change curves. The defect location information includes a defect physical coordinate set, target point position difference data, and a distortion correction parameter mapping table.

[0012] As a further aspect of the present invention, the structure tensor matrix in the multi-scale image is a matrix form constructed for image data of multiple resolutions and neighborhood ranges, used to express the gradient change relationship of pixels in multiple directions, and to reflect the directional features and texture distribution of local regions at multiple scales.

[0013] As a further aspect of the present invention, the step of obtaining the partitioned and stitched image is as follows:

[0014] S101: Call the presampled illumination image, analyze the pixel brightness matrix of the casting surface, compare the brightness difference between adjacent pixels in the horizontal and vertical directions, construct the brightness gradient matrix and analyze the gradient distribution, determine the aggregation mode of gradient changes in spatial location, and generate brightness aggregation distribution coefficients.

[0015] S102: Based on the brightness aggregation distribution coefficient, construct a high reflectivity area identification matrix, analyze the connected regions in the identification matrix, compare the correspondence between each connected region and the exposure time parameters in the exposure parameter table, match the exposure time parameters for each connected region, and generate partitioned exposure parameter mapping coefficients.

[0016] S103: Based on the partition exposure parameter mapping coefficient, after imaging is completed, perform a stitching process on multiple partition images, merge the image data of each partition in pixel coordinate order, and generate a partition stitched image.

[0017] As a further aspect of the present invention, the step of obtaining the surface defect identification result is as follows:

[0018] S201: Using the partitioned and stitched image, analyze the pixel brightness gradient distribution of the entire image area, identify candidate defect regions by combining edge pixel connectivity, record the pixel range and position of the candidate defect regions, and generate candidate defect region distribution parameters.

[0019] S202: Based on the candidate defect region distribution parameters, extract the pixel grayscale gradient of the boundary of each candidate defect region, arrange them in a clockwise direction to form an energy distribution sequence, calculate the change amplitude of adjacent data and record the peak occurrence position to generate boundary energy change parameters;

[0020] S203: Based on the boundary energy change parameters, by judging the stability of the energy change and analyzing the concentration of the peak values, identify and screen effective defect areas, and generate surface defect identification results.

[0021] As a further aspect of the present invention, the step of obtaining the regional texture feature information is as follows:

[0022] S301: Based on the surface defect identification results, calculate the gray-level variance in the neighborhood of each pixel in the effective defect area, record the neighborhood gray-level variance according to the pixel position and form a distribution matrix to generate a pixel gray-level variance matrix.

[0023] S302: Based on the pixel grayscale variance matrix and the pixel density of the target area, obtain the local roughness weight of each pixel, and establish local roughness weight distribution information according to the position coordinate information of the corresponding pixel.

[0024] S303: Based on the local roughness weight distribution information, analyze the spatial distribution pattern of the weights in the target area, analyze the distribution characteristics of the local roughness weights and form the roughness index of the target effective defect area, and generate regional texture feature information.

[0025] As a further aspect of the present invention, the step of obtaining the crack direction analysis result is as follows:

[0026] S401: Based on the surface defect identification results and regional texture feature information, calculate the structure tensor matrix of the effective defect region in images at multiple scales, extract peak and valley feature values ​​under images at multiple scales and calculate the ratio, and generate multi-scale feature ratio data.

[0027] S402: Based on the multi-scale feature ratio data, calculate the changing trend of the principal axis direction at multiple scales, perform correlation analysis between the changing trend and the ratio data at corresponding positions, establish a trend change sequence, and generate a principal axis direction change sequence.

[0028] S403: Based on the sequence of changes in the main axis direction, compare the stability of the proportional change with the smoothness of the direction change trend, identify and classify the effective defect areas, output defect area type labels, and generate crack direction analysis results.

[0029] As a further aspect of the present invention, the step of obtaining the defect location information is as follows:

[0030] S501: Using the surface defect identification results and crack direction analysis results, locate the defect area, mark the target point on the actual workpiece, and obtain the pixel coordinates of the target point in the image to generate the pixel coordinate data of the marker point.

[0031] S502: Based on the pixel coordinate data of the marked points, calculate the difference between the pixel coordinates of each target point and its corresponding physical coordinates, establish a difference vector matrix, and perform fitting calculations by combining radial distortion parameters and tangential distortion parameters to generate distortion correction coordinate data.

[0032] S503: Based on the distortion correction coordinate data, match the spatial mapping relationship of the defect area on the surface of the inorganic mineral casting entity, identify the actual spatial location of the defect, and generate defect location information.

[0033] A defect segmentation and localization system for images of inorganic mineral castings includes:

[0034] The image reflection processing module calls the presampled illumination image, analyzes the pixel brightness matrix of the casting surface, compares the brightness difference between adjacent pixels to construct a brightness gradient matrix, analyzes the spatial aggregation mode to generate a high reflectivity area identification matrix, analyzes the connected regions and matches the exposure time parameters, and performs image stitching after imaging to generate a partitioned stitched image.

[0035] The gradient energy recognition module uses the partitioned stitched image to perform brightness gradient analysis, combines edge pixel connectivity to identify candidate defect regions, constructs an energy distribution sequence based on the boundary gray-level gradient, analyzes the change amplitude and peak concentration, filters effective defect regions, and obtains surface defect recognition results.

[0036] The surface roughness recognition module calculates the gray-level variance of the pixel neighborhood in the effective defect area based on the surface defect recognition results, combines the pixel density to construct local roughness weights and analyze the spatial distribution, forms a roughness index, and generates regional texture feature information.

[0037] Based on the surface defect identification results and regional texture feature information, the structural trend analysis module calculates the structural tensor matrix of the effective defect region in images at multiple scales, extracts peak and valley feature values ​​and calculates the proportion, identifies the defect region type by calculating the change trend of the principal axis direction at multiple scales, and generates crack direction analysis results.

[0038] The spatial location calibration module uses the surface defect identification results and crack direction analysis results to calculate the pixel coordinates of the target point in the image, calculate the difference between the pixel coordinates of the target point and the corresponding physical coordinates, and combine radial and tangential distortion parameter fitting calculations to identify the actual spatial location of the defect and generate defect location information.

[0039] Compared with the prior art, the advantages and positive effects of the present invention are as follows:

[0040] In this invention, by combining high-reflectivity area identification, brightness gradient analysis, pixel-level roughness weight, and structural tensor analysis, the exposure range can be dynamically adjusted when processing casting images, reducing the loss of details in overexposed areas, improving the recognition accuracy of defect areas, and achieving accurate region segmentation and classification. The roughness weight calculation, which combines grayscale variance and pixel density, enhances the sensitivity to minor surface defects and improves the accuracy and reliability of defect location. Attached Figure Description

[0041] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0042] Figure 1 This is a schematic diagram of the steps of the present invention;

[0043] Figure 2 This is a detailed schematic diagram of S1 of the present invention;

[0044] Figure 3 This is a detailed schematic diagram of S2 of the present invention;

[0045] Figure 4 This is a detailed schematic diagram of S3 of the present invention;

[0046] Figure 5 This is a detailed schematic diagram of S4 of the present invention;

[0047] Figure 6 This is a detailed schematic diagram of S5 of the present invention;

[0048] Figure 7 This is a system module diagram of the present invention. Detailed Implementation

[0049] The technical solution of the present invention will now be described with reference to the accompanying drawings.

[0050] In embodiments of the present invention, words such as "exemplarily," "for example," etc., are used to indicate that something is an example, illustration, or description. Any embodiment or design described as "exemplary" in the present invention should not be construed as being more preferred or advantageous than other embodiments or designs. Specifically, the use of the word "exemplary" is intended to present the concept in a concrete manner. Furthermore, in embodiments of the present invention, the meaning expressed by "and / or" can be both, or either one.

[0051] In the embodiments of this invention, the terms "image" and "picture" may sometimes be used interchangeably. It should be noted that, without emphasizing the distinction between them, they convey the same meaning. Similarly, the terms "of," "corresponding (relevant)," and "corresponding" may sometimes be used interchangeably. It should be noted that, without emphasizing the distinction between them, they convey the same meaning.

[0052] In this embodiment of the invention, sometimes a subscript such as W1 may be written in a non-subscript form such as W1. When the difference is not emphasized, the meaning they express is the same.

[0053] To make the technical problems, technical solutions and advantages of the present invention clearer, a detailed description will be given below in conjunction with the accompanying drawings and specific embodiments.

[0054] Please see Figure 1 This invention provides a method for defect segmentation and localization of images of inorganic mineral castings, comprising the following steps:

[0055] S1: Call the presampled illumination image, analyze the pixel brightness matrix of the casting surface, compare the brightness difference between adjacent pixels to construct the brightness gradient matrix, analyze the spatial aggregation mode to generate a high reflectivity region identification matrix, analyze the connected regions and match the exposure time parameters, and perform image stitching after imaging to generate a partitioned stitched image.

[0056] S2: Utilize partitioned and stitched images to perform brightness gradient analysis, combine edge pixel connectivity to identify candidate defect regions, construct an energy distribution sequence based on boundary gray-level gradients, analyze the variation amplitude and peak concentration, screen effective defect regions, and obtain surface defect identification results;

[0057] S3: Based on the surface defect identification results, calculate the gray-level variance of the pixel neighborhood in the effective defect area, combine it with the pixel density to construct local roughness weights and analyze their spatial distribution, form a roughness index, and generate regional texture feature information.

[0058] S4: Based on the surface defect identification results and regional texture feature information, calculate the structure tensor matrix of the effective defect area in images at multiple scales, extract peak and valley feature values ​​and calculate the proportion, identify the defect area type by calculating the trend of principal axis direction change at multiple scales, and generate crack direction analysis results.

[0059] S5: Using the surface defect identification results and crack direction analysis results, calculate the pixel coordinates of the target point in the image, calculate the difference between the pixel coordinates of the target point and the corresponding physical coordinates, and combine the radial and tangential distortion parameter fitting calculations to identify the actual spatial location of the defect and generate defect location information.

[0060] The partitioned image includes pixel distribution information of high reflectivity areas, partitioned exposure parameter mapping information, and pixel matrix of the merged image. The surface defect identification results specifically include the effective defect area contour, defect boundary energy characteristics, and defect area connectivity data. The regional texture feature information includes roughness spatial distribution map, local roughness weight set, and texture directionality features. The crack direction analysis results specifically refer to crack principal axis direction parameters, crack type labels, and crack direction variation curves. The defect location information includes defect physical coordinate set, target point position difference data, and distortion correction parameter mapping table.

[0061] The structure tensor matrix in images of multiple scales is a matrix form constructed for image data of multiple resolutions and neighborhood ranges. It is used to express the gradient change relationship of pixels in multiple directions and reflect the directional features and texture distribution of local regions at multiple scales.

[0062] Please see Figure 2 The steps for obtaining the partitioned and stitched image are as follows:

[0063] S101: Call the presampled illumination image, analyze the pixel brightness matrix of the casting surface, compare the brightness difference between adjacent pixels in the horizontal and vertical directions, construct the brightness gradient matrix and analyze the gradient distribution, determine the aggregation mode of gradient changes in spatial location, and generate brightness aggregation distribution coefficients.

[0064] After calling the presampled illumination image, a two-dimensional brightness matrix is ​​constructed based on the brightness value of each pixel in the grayscale space in the image matrix. For any two horizontally adjacent pixels in this matrix... and and adjacent pixels in the vertical direction and Perform interpolation operations separately to obtain the brightness difference matrix. and The brightness difference formula is used for numerical calculation of brightness difference. ,in and For the brightness of two adjacent pixels, assume there are in a certain column , ,but After calculating the brightness difference in the horizontal and vertical directions, the two matrices are weighted and averaged according to their corresponding pixel positions to form a brightness gradient matrix. This matrix records the combined intensity value of brightness jumps at each point in the entire image. In actual casting surface images, there are gradient anomaly areas caused by metal textures or high reflectivity, for example, in a certain sample image. Significantly higher than the average of its neighboring points At this point, it is determined to be a local high gradient point. Next, a model is constructed centered on each pixel. or The neighborhood window is used to iterate through the gradient values ​​of each pixel, and the standard deviation and mean of the brightness gradient within the window are calculated. Based on the local standard deviation... With respect to the overall image gradient standard deviation Compare, if satisfied If a point is identified as a local mutation point, the spatial density of mutation points across the entire image is calculated, and the aggregation level is determined based on the degree of clustering of mutation points. For example, the image is divided into... Each small grid cell is used to count the number of mutation points within each grid cell. Then calculate the global average mutation density. If a certain mesh cell satisfies If the brightness aggregation region exists within the cell, then all grids that meet the aggregation conditions are marked by position encoding to generate a brightness aggregation distribution coefficient matrix. This matrix reflects the spatial aggregation characteristics of different regions in the casting image caused by brightness differences.

[0065] S102: Based on the brightness aggregation distribution coefficient, construct a high reflectivity area identification matrix, analyze the connected regions in the identification matrix, compare the correspondence between each connected region and the exposure time parameters in the exposure parameter table, match the exposure time parameters for each connected region, and generate the partitioned exposure parameter mapping coefficient;

[0066] Based on the generated brightness aggregation distribution coefficient matrix, all coefficient values ​​in the matrix are first normalized to ensure they fall within a certain range. Within the interval, the normalized matrix is ​​then subjected to connected component labeling. Based on the 4-neighborhood method, all connected regions consisting of non-zero pixels are extracted, and the pixel set and geometric range of each connected region are recorded and numbered sequentially. Calculate the boundary area, total number of pixels inside, and brightness concentration value of each connected region. This value is the ratio of the average brightness of all pixels within the region to the standard deviation of the overall image brightness, defined as follows: ,in Indicates the first The average brightness value within each connected region This represents the standard deviation of brightness for the entire image, for example, in a real image sample. , ,but Then, each connected region is compared with the exposure time parameters in the exposure parameter table, which lists the corresponding exposure time periods under different brightness concentration levels, using brightness concentration. As an index parameter, if If the area is greater than 1000 pixels, the exposure time is matched to 1 / 200s; otherwise, it is matched to 1 / 100s. For example, the area... Matches 1 / 200s, region Match 1 / 100s and build a mapping table. Record the region number and its corresponding exposure parameters. The matching results of each group are integrated into a set of regional exposure parameter mapping coefficients. This set of coefficients will serve as the key parameter basis for the subsequent image acquisition stage, and will be used to guide the setting of the independent exposure time for each region.

[0067] S103: Based on the mapping coefficient of the zone exposure parameters, after imaging, perform the stitching process of multiple zone images, merge the image data of each zone in the order of pixel coordinates, and generate a zone stitched image;

[0068] Based on the established set of zoned exposure parameter mapping coefficients, after image acquisition, the original image is partitioned according to the region number during the image processing stage. The area number recorded in the middle The corresponding pixel coordinate range is used to separate the image data of each region from the original image and label them as follows. Then, all partitioned images are rearranged and stitched according to pixel space coordinates, using a position-first algorithm. This means that the top-left corner coordinates of the pixels are used as a reference to arrange the partitioned image blocks sequentially. If two images have overlapping edge areas, pixel mean fusion is performed. For example, if the pixel values ​​of overlapping edge areas are 145 and 155 respectively, the merged pixel value is 150. Additionally, local contrast shifts caused by exposure differences need to be corrected, and mean alignment is performed. Histogram mean adjustment is applied to each partitioned image to make the gray-level distribution center of each region more consistent. Assuming the region... The mean grayscale value is 180, and the mean target value is 160. Therefore, for... Subtract 20 from all pixels, then perform uniform alignment, and after all partitioned images are stitched together, a complete partitioned stitched image is formed. This image has the characteristics of uniform brightness and adaptive local exposure, and serves as the basic image data source for subsequent defect detection and texture analysis.

[0069] Please see Figure 3 The steps for obtaining surface defect identification results are as follows:

[0070] S201: Utilize partitioned image stitching to analyze the pixel brightness gradient distribution across the entire image domain, identify candidate defect regions by combining edge pixel connectivity, record the pixel range and location of candidate defect regions, and generate candidate defect region distribution parameters.

[0071] After merging the image using partitioning, gradient analysis is first performed on the grayscale values ​​of all pixels within the entire image region. Specifically, each pixel is traversed, and its four adjacent pixels in the four directions (up, down, left, and right) are selected. The horizontal and vertical gradient magnitudes of the pixel are calculated by the difference in grayscale values ​​between each pair of pixels. Then, the sum of the squares of the gradient magnitudes in the two directions is taken as the square root to obtain the brightness gradient value of the pixel, which is used to construct the image brightness gradient distribution map. For example, if the grayscale values ​​of pixel P(50,60) with its upper and lower adjacent pixels are 180 and 120 respectively, and its left and right adjacent pixels are 175 and 130 respectively, then the horizontal gradient of this point is 45, the vertical gradient is 60, and the brightness gradient value is approximately 74.4. This brightness gradient value is written into the corresponding position in the gradient matrix G. After completing the gradient analysis of the entire image, edge detection is then performed on all pixels in the gradient map. The method involves using points with pixel gradient magnitudes greater than a set threshold as the initial set of edge points. The threshold can be set based on the standard deviation of the gradient values ​​across the entire image. If the standard deviation of the gradient is 25, then the threshold is set to twice the standard deviation, i.e., 50. All pixel positions with a gradient magnitude greater than 50 are selected, and 4-neighborhood or 8-neighborhood connectivity is determined for these pixels. All pixels in the connected regions are used as the initial boundaries of the candidate regions. Subsequently, the pixel index range of each connected region is recorded, and its starting coordinates, width, height, and boundary length are obtained. For example, region A has starting pixels (100, 150), a width of 30, a height of 25, and 260 boundary pixels. This data is structured and recorded as a list of candidate region distribution parameters, and numbered sequentially. Finally, the spatial location and boundary range information of all connected edge regions that meet the conditions are compiled to generate candidate defect region distribution parameters.

[0072] S202: Based on the distribution parameters of the candidate defect region, extract the pixel grayscale gradient of the boundary of each candidate defect region, arrange them in a clockwise direction to form an energy distribution sequence, calculate the change amplitude of adjacent data and record the peak occurrence position to generate boundary energy change parameters;

[0073] Based on the aforementioned candidate defect region distribution parameters, for each identified candidate region, its boundary pixels are located and arranged clockwise to form an ordered pixel boundary sequence. The coordinate position and brightness gradient value of each boundary pixel are recorded. During the traversal of this sequence, a numerical difference operation is performed based on the brightness gradient values ​​of every two adjacent boundary pixels, recording the change amplitude between adjacent gradient values. For example, in the boundary sequence of a certain region, if the gradient values ​​of point 1 and point 2 are 80 and 90, the difference is 10; if the gradient values ​​of point 2 and point 3 are 90 and 70, the difference is 20. This process is repeated to calculate the change amplitude of each pair of adjacent points, generating a continuous change sequence. The column marks all locations where extreme changes occur, i.e., peak points. When the gradient difference between two points exceeds the average gradient difference of all points plus a baseline fluctuation threshold, that point is determined to be a local energy jump point. For example, if the average gradient difference in this region is 15 and the baseline fluctuation threshold is set to 10, then a difference exceeding 25 is a peak point. The index position and gradient change direction of these peak points are recorded, and the number of peak concentration regions and their distribution in the sequence are counted. Finally, the boundary gradient change sequence, peak position array, and number of gradient jump segments corresponding to each candidate region are organized into the boundary energy change parameters of that region, which are used for the next step of stability judgment and concentration analysis.

[0074] S203: Based on the boundary energy change parameters, by judging the stability of energy change and analyzing the concentration of peak values, effective defect areas are identified and screened to generate surface defect identification results;

[0075] The specific formula for analyzing the concentration of peak values ​​is as follows:

[0076] ;

[0077] Calculate the peak energy concentration index, and combine it with the stability of energy changes to identify and screen effective defect areas;

[0078] in, As a peak energy concentration index, For the candidate defect region, the first The normalized value of the gray-level gradient change amplitude of each boundary pixel. This represents the normalized average of the grayscale gradient changes of all boundary pixels in the candidate defect region. The normalized grayscale gradient variation amplitude in the candidate defect region standard deviation For the first The normalized variance of the grayscale gradient values ​​of each boundary pixel within a local 5×5 sliding window. This represents the total number of pixels at the boundary of the candidate defect region. The index of the boundary pixel in the candidate defect region is used to identify the first pixel involved in the calculation. Each boundary pixel.

[0079] The specific formula for analyzing the concentration of peaks in the above content is as follows: This is used to calculate the peak energy concentration index, and combined with the stability of energy changes, to identify and screen effective defect areas. The formula uses a logic that comprehensively judges the deviation amplitude and local fluctuations to measure the concentration and stability of the gray-level gradient changes in the candidate boundary region, thus screening effective defect areas. In the embodiment, the parameter sources and numerical examples are as follows: Each boundary pixel was measured through image analysis. The normalized grayscale gradient magnitude is obtained by normalizing the gradient values ​​within a sliding 5×5 neighborhood. Typical value range: . :all The average value of each normalized grayscale gradient amplitude is calculated as follows: Assuming data collection The values ​​obtained for each boundary pixel are shown in Table 1; The standard deviation of the above-mentioned uniformly normalized gray-level gradient amplitude is calculated as follows: ; Each boundary pixel Within its local 5×5 sliding window, the variance of the gradient value is obtained after normalization, and its square root (√) Used for weighted bias; : Total number of boundary pixels, e.g., 4; Specific example data is as follows:

[0080] Table 1 Example of parameter monitoring and calculation

[0081]

[0082] As shown in Table 1, normalized values ​​are obtained through image brightness gradient calculation and local statistics.

[0083] Calculations based on the data in Table 1:

[0084] ;

[0085] ;

[0086] ;

[0087] ;

[0088] The result indicates When substituted into the formula for the final calculation of the steps, an extremely low A value indicates that the gray-level gradient change of the candidate region has high concentration and stability in the local space. This indicator will be used in subsequent comparisons with the stability judgment of energy changes and the concentration threshold to help screen whether it belongs to a valid defect region. The threshold is set as follows: The system first statistically analyzes all defect regions based on the historical sample library of labeled defect data under different material and process conditions. Value distribution. This is achieved by analyzing the positive and negative samples. Distribution analysis used the 95th percentile as the upper limit threshold. For example, in high-texture castings, In low-texture castings When detecting a new workpiece, the candidate region is calculated. Value; if If the gradient change is concentrated and stable, the region is considered a "valid defect candidate"; otherwise, it is excluded. This is achieved by introducing a sample-driven adaptive threshold. Compared to the fixed-value method, the overall false detection rate is reduced by approximately 20%, the detection rate of small defects is increased by approximately 15%, and the robustness to high-texture backgrounds is significantly enhanced. The formula, by introducing a product term of the absolute value of the deviation and the square root of local fluctuations, achieves a comprehensive measure of anomalous gradients and regional instability, which helps to more accurately screen out surface defect regions with concentrated and stable characteristics.

[0089] Please see Figure 4 The steps for obtaining region texture feature information are as follows:

[0090] S301: Based on the surface defect identification results, calculate the gray-level variance in the neighborhood of each pixel in the effective defect area, record the neighborhood gray-level variance according to the pixel position and form a distribution matrix to generate the pixel gray-level variance matrix.

[0091] Based on the surface defect identification results, in each valid defect region, each pixel is selected as the center point to construct a neighborhood window region of fixed size. (The last sentence appears to be a fragment and doesn't translate directly.) or A rectangular neighborhood is defined, and the standard deviation of the gray values ​​of all pixels within this neighborhood is calculated to quantify the degree of gray-level fluctuation in the local area of ​​that point. The calculation process first calculates the average gray value of the nine pixels within the window, then calculates the squared difference between each pixel's gray value and the average value, sums all the squared differences, and divides by the number of pixels to obtain the final gray-level variance value of that pixel. Assuming the gray value of the neighborhood surrounding a pixel is... Then its mean is 121.3, and the differences of squares are respectively The summation yields 44.01, which, when divided by 9, results in a grayscale variance of 4.89. This value represents the grayscale fluctuation index of the pixel. This calculation is performed to cover all pixels within the entire effective defect area, generating a set of grayscale variance values ​​corresponding to their coordinate positions. The results are stored in two-dimensional pixel coordinates to form a grayscale variance matrix. This matrix has the same data dimension as the original image. The grayscale variance of all pixels in non-defect areas is set to 0, and only the grayscale fluctuation characteristics within the defect area are recorded. During the matrix formation process, the grayscale variance value of each pixel can be used to reveal the degree of local disturbance in the surface texture of the defect. After completing the traversal of all defect areas and matrix recording, a complete pixel grayscale variance matrix is ​​output.

[0092] S302: Based on the pixel grayscale variance matrix and combined with the pixel density of the target area, obtain the local roughness weight of each pixel, and establish the local roughness weight distribution information according to the position coordinate information of the corresponding pixel.

[0093] Based on the variance value of each pixel recorded in the pixel grayscale variance matrix, and combined with the pixel density information within the defect region, a local roughness weight value is assigned to each pixel. This weight value is used to quantify the participation of the pixel in spatial texture perturbation. The calculation process first calculates the pixel density of each effective defect region, specifically the number of effective pixels in the region divided by the region area. For example, if region A has 100 effective pixels and its area is 25 square pixels, then the pixel density is 4.0. Subsequently, for each pixel within this region, based on its grayscale variance value... With pixel density Calculate its roughness weight value together The weight value is set in the following way: If the grayscale variance of a pixel is 3.2 and the corresponding pixel density in the region is 4.0, then its roughness weight is 12.8. After assigning the roughness weight to each pixel, the pixel's position coordinate information in the region is further considered. The spatial distribution relationship of roughness weights is established, and all roughness weight values ​​are mapped one-to-one with their two-dimensional positions to form a roughness spatial distribution table. This table organizes records by region number, and each entry contains region number, pixel position, pixel gray-level variance, region pixel density, and the calculated roughness weight value. For example: region B, pixel (40, 55), gray-level variance 5.6, pixel density 2.3, roughness weight 12.88. After this process is completed in all effective defect areas, a complete local roughness weight distribution information dataset is formed.

[0094] S303: Based on the local roughness weight distribution information, analyze the spatial distribution pattern of the weight in the target area, analyze the distribution characteristics of the local roughness weight and form the roughness index of the target effective defect area, and generate regional texture feature information.

[0095] Based on the roughness weight distribution information, a roughness distribution map is constructed for each effective defect region, and all recorded roughness weight values ​​are processed. Spatial traversal is performed, and a sliding window is used to statistically analyze the local roughness maximum, minimum, mean, and standard deviation within a region. The spatial variation range of each statistical index is calculated to determine whether there is structural clustering of roughness within the region. A defect region is divided into several sub-grid regions, and the roughness mean is statistically analyzed for each grid. The range and standard deviation of the mean values ​​between grids are calculated. If the range is greater than the set distribution baseline value of 50, and the standard deviation is greater than 1.2 times the standard deviation of the overall mean, it is determined that there is a spatial concentration of roughness in that region. Further, a roughness heatmap is plotted to observe the spatial diffusion trend of each weight, and the diffusion... By comparing the trend vector with the coordinate axis direction, we can analyze whether the roughness extends along the principal axis direction. In practice, for example, the roughness value in region C is highest on the vertical stripe, corresponding to multiple consecutive pixel weight values ​​between 20 and 25, while the horizontal distribution is only between 5 and 10, indicating that the texture of this region is vertical stripes. Finally, the above spatial analysis results are converted into regional roughness indices, and the index value range, principal axis direction and distribution density level are recorded. The roughness index of each defect region is stored as a standardized texture parameter vector for subsequent structural tensor analysis and defect type identification processes, ultimately generating regional texture feature information.

[0096] Please see Figure 5 The steps for obtaining the crack direction analysis results are as follows:

[0097] S401: Based on the surface defect identification results and regional texture feature information, calculate the structure tensor matrix of the effective defect region in images at multiple scales, extract peak and valley feature values ​​under images at multiple scales and calculate the proportion, and generate multi-scale feature proportion data.

[0098] Based on the surface defect identification results and regional texture feature information, within each effective defect region, an image pyramid with multiple scale versions is constructed sequentially, using the original resolution image as a baseline. The selected scaling scale can be four levels: 1.0, 0.75, 0.5, and 0.25, representing the original image, 3 / 4 scaled-down, 1 / 2 scaled-down, and 1 / 4 scaled-down images, respectively. A defect region block is extracted from the corresponding location in each scale image. Two-dimensional directional statistics are performed on the pixel gradient information within this region block, calculating the gradient value changes along the horizontal, vertical, and diagonal directions to obtain the corresponding scale for that region. The principal axis features of the domain's structure tensor are analyzed, and two feature values ​​of this tensor are extracted, representing the response degree of image texture intensity in the principal and secondary directions, respectively. For example, at scale 1.0, the feature values ​​of the structure tensor of a certain region are λ1=15.2 and λ2=4.8, so the ratio is 3.17. At scale 0.5, the feature values ​​of the same region are λ1=7.5 and λ2=2.5, so the ratio is still 3.0. The feature values ​​and calculated ratio data at all scales are recorded in sequence and included in the multi-scale feature ratio dataset of the current defect region as the basic data source for analyzing the consistency of texture response at various scales in the region.

[0099] S402: Based on multi-scale feature scale data, calculate the changing trend of the principal axis direction at multiple scales, perform correlation analysis between the changing trend and the scale data at corresponding positions, establish a trend change sequence, and generate a principal axis direction change sequence;

[0100] Based on multi-scale feature ratio data, the principal axis direction data extracted from each defect region at scales 1.0, 0.75, 0.5, and 0.25 were processed. By comparing the changes in the principal axis direction angles at each scale, the trend data of principal axis direction changes were obtained. The angle θ between the principal axis direction and the horizontal direction was recorded at each scale. For example, if the principal axis angles of a certain region at the four scales are 12°, 14°, 17°, and 16° respectively, then the principal axis direction of this region shows a stable and slightly upward trend. After processing the principal axis direction angles, the trend of this direction change was correlated with the changes in the structural tensor ratio to analyze whether the two changed synchronously. If the larger the angle change, the larger the ratio change, it indicates that the region has scale response instability. The data points of each scale combination were recorded as a trend sequence to construct the principal axis direction change sequence. For example, the sequence for a certain region was: [Scale 1.0, Ratio 3.2, Angle 12°], [Scale 0.75, Ratio 3.1, Angle 14°], [Scale 0.5, [Scale 3.0, Angle 17°], [Scale 0.25, Scale 2.9, Angle 16°], then calculate the change in scale and angle between each group, determine whether their change trends are consistent or stable, and finally generate the sequence of changes in the main axis direction of the defect area.

[0101] S403: Based on the sequence of changes in the principal axis direction, compare the stability of the proportional change with the smoothness of the directional change trend, identify and classify the effective defect areas, output defect area type labels, and generate crack direction analysis results.

[0102] Based on the sequence of changes in the main axis direction, in each effective defect region, the difference between the maximum and minimum values ​​of the proportional change rate is calculated, and its standard deviation is also calculated to reflect the stability of the proportional change. Next, the range and fluctuation range of the main axis direction change angle are statistically analyzed as a basis for judging the stability of the direction change. If the maximum proportional change in a certain region is 3.3, the minimum is 2.7, and the standard deviation is 0.21, and the direction angle range is 11° to 18° with a standard deviation of 2.4°, then according to the set stability thresholds, such as a proportional standard deviation less than 0.3 and an angle fluctuation standard deviation less than 3°, it is judged as "unstable". The system identifies areas that meet the stability criteria as regular defects, while areas with significant fluctuations in both proportion and direction are classified as irregular defects. Furthermore, the crack direction is categorized based on whether the principal axis angle is concentrated around 0° or 90°. Angles concentrated between 85° and 95° are classified as "vertical cracks," those between 5° and 15° as "horizontal cracks," and those with discrete angle distributions as "intersecting cracks" or "undirected cracks." Finally, the system outputs crack direction analysis results and type labels for each defect area for subsequent analysis and classification.

[0103] Please see Figure 6 The steps for obtaining defect location information are as follows:

[0104] S501: Using the surface defect identification results and crack direction analysis results, locate the defect area, mark the target point on the actual workpiece, and obtain the pixel coordinates of the target point in the image to generate the pixel coordinate data of the marker point.

[0105] Using surface defect identification results and crack direction analysis results, the two-dimensional pixel position boundary in the image coordinate system is determined for each identified effective defect area. The center point or geometric edge feature points of the area are extracted as the basis for setting target points. Target points are attached or marked on the actual workpiece surface using a physical positioning system, ensuring that the target point can be clearly identified in the image. Pixel coordinate extraction is performed on each physical target point in image space, and the pixel row and column index of the point in the image matrix is ​​read. For example, target point A on a workpiece is located at the center of the defect area, and its corresponding coordinates in the image are (x=512, y=346). Then, the image coordinates of multiple other target points are read sequentially, and each marked point is numbered. A table record structure is established, including the label number, image x-coordinate, image y-coordinate, corresponding defect number, and crack principal axis direction information of the target point's region. For example, point B is located in region 3, with coordinates (x=678, y=346). (y=289), with a principal axis angle of 14°. The pixel coordinate data of this marker point serves as the input data source for subsequent geometric mapping fitting processing, used to establish the correspondence between image space and physical space.

[0106] S502: Based on the pixel coordinate data of the marker points, calculate the difference between the pixel coordinates of each target point and its corresponding physical coordinates, establish a difference vector matrix, and perform fitting calculations by combining radial distortion parameters and tangential distortion parameters to generate distortion correction coordinate data.

[0107] Based on the pixel coordinate data of the marker points, a robustness analysis is first performed on the target point data. Using a 3D measuring instrument or a high-precision positioning platform, the physical spatial coordinates (X, Y, Z) of each target point on the actual workpiece surface are obtained, forming a dataset with a one-to-one correspondence to the image pixel coordinates. For example, image point (512, 346) corresponds to workpiece coordinates (125.3 mm, 84.2 mm, 0 mm). After collecting the image and physical coordinate data of all target points, abnormal target point detection is performed. The reprojection error of each target point is calculated through preliminary fitting, and the residual distribution is statistically analyzed. Target points exceeding a threshold (e.g., μ + 3σ) or identified as outliers by cluster analysis are removed, resulting in a set of valid target points. On this set of valid target points, the distance vector difference between the image coordinates and physical coordinates is calculated, forming a difference vector matrix. This matrix records the image position, actual position, and difference of each target point. Subsequently, by combining the pre-calibrated radial distortion coefficients (e.g., k1=0.015, k2=-0.003) and tangential distortion coefficients (p1=0.001, p2=0.002) of the camera system, a robust fitting method (such as RANSAC-based weighted least squares) is used to perform distortion back-calculation correction on the coordinates of all target points in the image space, avoiding the influence of outliers on the fitting results. Finally, the corrected image coordinate values ​​are fitted and re-correlated with the actual physical coordinates to generate highly reliable distortion-corrected coordinate data for subsequent accurate spatial location mapping.

[0108] S503: Based on distortion correction coordinate data, match the spatial mapping relationship of the defect area on the surface of the inorganic mineral casting, identify the actual spatial location of the defect, and generate defect location information.

[0109] Based on distortion-corrected coordinate data, the image positions of key feature points within the identified defect area are spatially mapped into the distortion-corrected image coordinate system. This involves inputting the coordinates of key pixels such as the center point, the start and end points of the main axis, and the feature points on the contour edges of the defect area into a spatial transformation function. This function is constructed based on the mapping relationship between the image space and physical space fitted by the target points. For example, using a two-dimensional projective transformation model to convert pixels to actual physical coordinates, a pixel (x=512, y=346) is converted into physical space coordinates (X=125.1 mm, Y=84.4 mm). After performing mapping processing on all key points for each defect area, the specific spatial range of the defect area on the actual inorganic mineral casting surface is determined. The corresponding physical coordinate range, center position, and the extension angle and length of the crack main axis in space are recorded. Finally, all processing results are summarized to generate defect location information, which is output in structured data form. Each data entry includes the defect number, physical coordinate boundary, and crack spatial direction, for subsequent workpiece repair or quality traceability.

[0110] Please see Figure 7 A defect segmentation and localization system for images of inorganic mineral castings, comprising:

[0111] The image reflection processing module calls the presampled illumination image, analyzes the pixel brightness matrix of the casting surface, compares the brightness difference between adjacent pixels to construct a brightness gradient matrix, analyzes the spatial aggregation mode to generate a high reflectivity area identification matrix, analyzes the connected regions and matches the exposure time parameters, and performs image stitching after imaging to generate a partitioned stitched image.

[0112] The gradient energy recognition module uses partitioned and stitched images to perform brightness gradient analysis, combines edge pixel connectivity to identify candidate defect regions, constructs an energy distribution sequence based on boundary gray-scale gradients, analyzes the magnitude of change and the degree of peak concentration, filters effective defect regions, and obtains surface defect recognition results.

[0113] The surface roughness recognition module calculates the gray-level variance of the pixel neighborhood in the effective defect area based on the surface defect recognition results, combines the pixel density to construct local roughness weights and analyze their spatial distribution, forming a roughness index and generating regional texture feature information.

[0114] Based on the surface defect identification results and regional texture feature information, the structural trend analysis module calculates the structural tensor matrix of the effective defect area in images at multiple scales, extracts peak and valley feature values ​​and calculates the proportion, identifies the defect area type by calculating the change trend of the principal axis direction at multiple scales, and generates crack direction analysis results.

[0115] The spatial location calibration module uses the surface defect identification results and crack direction analysis results to calculate the pixel coordinates of the target point in the image, calculate the difference between the pixel coordinates of the target point and the corresponding physical coordinates, and combine radial and tangential distortion parameter fitting calculations to identify the actual spatial location of the defect and generate defect location information.

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

Claims

1. A method for defect segmentation and localization of images of inorganic mineral castings, characterized in that, Includes the following steps: S1: Call the presampled illumination image, analyze the pixel brightness matrix of the casting surface, compare the brightness difference between adjacent pixels to construct the brightness gradient matrix, analyze the spatial aggregation mode to generate a high reflectivity region identification matrix, analyze the connected regions and match the exposure time parameters, and perform image stitching after imaging to generate a partitioned stitched image. The steps for obtaining the partitioned and stitched image are as follows: S101: Call the presampled illumination image, analyze the pixel brightness matrix of the casting surface, compare the brightness difference between adjacent pixels in the horizontal and vertical directions, construct the brightness gradient matrix and analyze the gradient distribution, determine the aggregation mode of gradient changes in spatial location, and generate brightness aggregation distribution coefficients. S102: Based on the brightness aggregation distribution coefficient, construct a high reflectivity area identification matrix, analyze the connected regions in the identification matrix, compare the correspondence between each connected region and the exposure time parameters in the exposure parameter table, match the exposure time parameters for each connected region, and generate partitioned exposure parameter mapping coefficients. S103: Based on the partition exposure parameter mapping coefficient, after imaging is completed, perform a stitching process on multiple partition images, merge the image data of each partition in pixel coordinate order, and generate a partition stitched image; S2: Using the partitioned and stitched image, perform brightness gradient analysis, identify candidate defect regions by combining edge pixel connectivity, construct an energy distribution sequence based on the boundary gray-level gradient, analyze the change amplitude and peak concentration, screen effective defect regions, and obtain surface defect identification results. S3: Based on the surface defect identification results, calculate the gray-level variance of the pixel neighborhood in the effective defect area, combine it with the pixel density, construct the local roughness weight and analyze the spatial distribution to form a roughness index and generate regional texture feature information. S4: Based on the surface defect identification results and regional texture feature information, calculate the structure tensor matrix of the effective defect region in images at multiple scales, extract peak and valley feature values ​​and calculate the proportions, identify the defect region type by calculating the trend of principal axis direction changes at multiple scales, and generate crack direction analysis results. S5: Using the surface defect identification results and crack direction analysis results, calculate the pixel coordinates of the target point in the image, calculate the difference between the pixel coordinates of the target point and the corresponding physical coordinates, and combine the radial and tangential distortion parameter fitting calculations to identify the actual spatial location of the defect and generate defect location information.

2. The defect segmentation and localization method for inorganic mineral casting images according to claim 1, characterized in that, The partitioned image includes pixel distribution information of high reflectivity areas, partitioned exposure parameter mapping information, and pixel matrix of the merged image. The surface defect identification results specifically include the effective defect region contour, defect boundary energy characteristics, and defect region connectivity data. The regional texture feature information includes a roughness spatial distribution map, a local roughness weight set, and texture directionality features. The crack direction analysis results specifically refer to crack principal axis direction parameters, crack type labels, and crack direction variation curves. The defect location information includes a defect physical coordinate set, target point position difference data, and a distortion correction parameter mapping table.

3. The defect segmentation and localization method for inorganic mineral casting images according to claim 1, characterized in that, The structure tensor matrix in the multi-scale image is a matrix form constructed for image data of various resolutions and neighborhood ranges. It is used to express the gradient change relationship of pixels in multiple directions and reflect the directional features and texture distribution of local regions at multiple scales.

4. The defect segmentation and localization method for inorganic mineral casting images according to claim 1, characterized in that, The steps for obtaining the surface defect identification results are as follows: S201: Using the partitioned image, analyze the pixel brightness gradient distribution of the entire image area, identify candidate defect regions by combining edge pixel connectivity, record the pixel range and position of the candidate defect regions, and generate candidate defect region distribution parameters. S202: Based on the candidate defect region distribution parameters, extract the pixel grayscale gradient of the boundary of each candidate defect region, arrange them in a clockwise direction to form an energy distribution sequence, calculate the change amplitude of adjacent data and record the peak occurrence position to generate boundary energy change parameters; S203: Based on the boundary energy change parameters, by judging the stability of the energy change and analyzing the concentration of the peak values, identify and screen effective defect areas, and generate surface defect identification results.

5. The defect segmentation and localization method for inorganic mineral casting images according to claim 1, characterized in that, The steps for obtaining the region texture feature information are as follows: S301: Based on the surface defect identification results, calculate the gray-level variance in the neighborhood of each pixel in the effective defect area, record the neighborhood gray-level variance according to the pixel position and form a distribution matrix to generate a pixel gray-level variance matrix. S302: Based on the pixel grayscale variance matrix and the pixel density of the target area, obtain the local roughness weight of each pixel, and establish local roughness weight distribution information according to the position coordinate information of the corresponding pixel. S303: Based on the local roughness weight distribution information, analyze the spatial distribution pattern of the weights in the target area, analyze the distribution characteristics of the local roughness weights and form the roughness index of the target effective defect area, and generate regional texture feature information.

6. The defect segmentation and localization method for inorganic mineral casting images according to claim 1, characterized in that, The steps for obtaining the crack direction analysis results are as follows: S401: Based on the surface defect identification results and regional texture feature information, calculate the structure tensor matrix of the effective defect region in images at multiple scales, extract peak and valley feature values ​​under images at multiple scales and calculate the ratio, and generate multi-scale feature ratio data. S402: Based on the multi-scale feature ratio data, calculate the change trend of the principal axis direction under multiple scales, perform correlation analysis between the change trend and the ratio data at corresponding positions, establish a trend change sequence, and generate a principal axis direction change sequence; S403: Based on the sequence of changes in the main axis direction, compare the stability of the proportional change with the smoothness of the direction change trend, identify the type of the effective defect area and classify it, output the defect area type label, and generate the crack direction analysis result.

7. The defect segmentation and localization method for inorganic mineral casting images according to claim 1, characterized in that, The steps for obtaining the defect location information are as follows: S501: Using the surface defect identification results and crack direction analysis results, locate the defect area, mark the target point on the actual workpiece, and obtain the pixel coordinates of the target point in the image to generate the pixel coordinate data of the marker point. S502: Based on the pixel coordinate data of the marked points, abnormal target points are identified and eliminated by calculating and analyzing the target point coordinate residuals. Based on the difference between the pixel coordinates of each valid target point and the corresponding physical coordinates, a difference vector matrix is ​​established. The radial distortion parameter and the tangential distortion parameter are combined to perform fitting calculations to generate distortion correction coordinate data. S503: Based on the distortion correction coordinate data, match the spatial mapping relationship of the defect area on the surface of the inorganic mineral casting entity, identify the actual spatial location of the defect, and generate defect location information.

8. A defect segmentation and localization system for images of inorganic mineral castings, characterized in that, The system is used to implement the defect segmentation and localization method for inorganic mineral casting images according to any one of claims 1-7, the system comprising: The image reflection processing module calls the presampled illumination image, analyzes the pixel brightness matrix of the casting surface, compares the brightness difference between adjacent pixels to construct a brightness gradient matrix, analyzes the spatial aggregation mode to generate a high reflectivity area identification matrix, analyzes the connected regions and matches the exposure time parameters, and performs image stitching after imaging to generate a partitioned stitched image. The gradient energy recognition module uses the partitioned stitched image to perform brightness gradient analysis, combines edge pixel connectivity to identify candidate defect regions, constructs an energy distribution sequence based on the boundary gray-level gradient, analyzes the change amplitude and peak concentration, filters effective defect regions, and obtains surface defect recognition results. The surface roughness recognition module calculates the gray-level variance of the pixel neighborhood in the effective defect area based on the surface defect recognition results, combines the pixel density to construct local roughness weights and analyze the spatial distribution, forms a roughness index, and generates regional texture feature information. Based on the surface defect identification results and regional texture feature information, the structural trend analysis module calculates the structural tensor matrix of the effective defect region in images at multiple scales, extracts peak and valley feature values ​​and calculates the proportion, identifies the defect region type by calculating the change trend of the principal axis direction at multiple scales, and generates crack direction analysis results. The spatial location calibration module uses the surface defect identification results and crack direction analysis results to calculate the pixel coordinates of the target point in the image, calculate the difference between the pixel coordinates of the target point and the corresponding physical coordinates, and combine radial and tangential distortion parameter fitting calculations to identify the actual spatial location of the defect and generate defect location information.

Citation Information

Patent Citations

  • Mineral casting defect detection method based on artificial intelligence

    CN117152180A

  • Glass bottle label defect detection method and system based on image processing

    CN120318477A