A method for automatically detecting surface defects of a casting
By using multi-source data processing and self-supervised retraining, the problem of poor consistency of segmentation results at multiple time points in casting surface defect detection is solved, achieving high-precision defect area tracking and environmental adaptability, and supporting intelligent source tracing and production optimization of casting surface defects.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- MEIZHOU HUAHE PRECISION IND CO LTD
- Filing Date
- 2025-09-09
- Publication Date
- 2026-04-17
AI Technical Summary
Existing surface defect detection technologies for castings suffer from poor consistency in segmentation results across multiple time points, making it difficult to continuously track the evolution of the same defect region. Segmentation boundaries fluctuate significantly over time, exhibiting poor adaptability to environmental changes and lacking a self-supervised mechanism. Consequently, they cannot achieve high-precision cross-temporal spatial alignment and feature fusion of defect regions, limiting intelligent tracing of defect growth processes and process optimization.
By acquiring multi-source imaging data and morphology data, denoising and brightness normalization are performed. The RANSAC algorithm is used for cross-temporal spatial feature matching to generate defect evolution pseudo-labels. The segmentation model is then retrained under self-supervision to achieve high-confidence consistency tracking and fine-grained segmentation of defect regions, generating a defect evolution trend report.
It achieves high consistency and robustness of multi-time segmentation results, improves the spatial alignment accuracy and feature fusion capability of defect areas, enhances adaptability to complex environments, and supports intelligent traceability of casting surface defects and optimization of production processes.
Smart Images

Figure CN121169855B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent inspection technology for casting, and in particular to an automatic method for detecting surface defects in castings. Background Technology
[0002] Currently, the detection and traceability of surface defects in castings in the foundry industry is gradually moving towards automation and intelligence. The mainstream technical approaches mainly focus on surface defect segmentation and recognition methods based on machine vision and deep learning, such as deep segmentation models like Convolutional Neural Networks (CNNs) and U-Net, as well as multi-source imaging techniques like 3D scanning and structured light detection for surface morphology. Some cutting-edge solutions attempt to combine multi-source data (such as optical images and 3D contours), region segmentation strategies, and sample augmentation to achieve defect detection and preliminary region segmentation under complex working conditions. Furthermore, with the advancement of process digitalization, many companies have begun to build phased traceable databases for the casting production process, promoting the transformation from static defect identification to dynamic tracking and trend analysis.
[0003] In practical engineering applications, existing surface defect detection systems for castings generally rely on single-frame segmentation strategies. This involves using the surface image at the current time point as a basis and directly outputting a defect mask through traditional pattern recognition or depth segmentation models. These methods perform well under static imaging conditions and when defect features are clear, and can handle general batch inspection and quality grading requirements. However, for surface defects undergoing dynamic evolution, especially in the casting process where factors such as temperature, fluid disturbance, surface oxidation, and secondary processing cause deformation, migration, or boundary fluctuations in the defect area, existing methods struggle to guarantee the consistency of segmentation results across multiple time points.
[0004] Some studies have attempted to improve multi-time defect tracking capabilities through multi-frame image registration and temporal feature statistics. However, their core technologies mostly remain at the level of coarse regional registration and simple temporal averaging, lacking accurate modeling of the continuous evolution of defects. This makes it difficult to cope with real-world interferences such as complex surface textures, large environmental variations, and dynamic morphological changes in castings. For example, typical segmentation models are prone to abrupt changes in defect region boundaries under environmental influences such as illumination variations, surface wetting, local contamination, and batch-to-batch differences in imaging equipment, resulting in insufficient reproducibility and trend reliability of multi-time segmentation results.
[0005] Existing representative technical solutions mostly focus on instantaneous and accurate segmentation and single-point statistics of defects, lacking effective mechanisms for cross-temporal and spatial alignment of defect regions, high-precision continuous tracking, and improved segmentation consistency. When discerning the evolutionary behavior of the same defect under different imaging conditions at multiple time points, historical comparison misjudgments and distorted trend analysis often occur due to segmentation boundary drift, temporal registration errors, or model sensitivity to abnormal noise, limiting the accurate tracing of the defect growth process. Furthermore, these methods typically rely on large amounts of manually labeled data for model training, resulting in weak data expansion and model adaptability, thus limiting their generalization ability to different batches and process variations.
[0006] In summary, current technologies for detecting and tracking surface defects in castings have the following prominent shortcomings:
[0007] (1) The results of defect segmentation at multiple times are inconsistent, making it difficult to continuously and accurately track the evolution of the same defect region. The segmentation boundary fluctuates significantly over time, making it difficult to use as a data basis for process traceability.
[0008] (2) The spatial alignment and feature fusion of the defect area across time are insufficient, the spatiotemporal continuity of the defect area is relatively rough, and the movement and morphological changes of the host workpiece can easily cause registration failure.
[0009] (3) Current annotation-based supervised segmentation models are poorly adaptable to environmental changes such as morphology, lighting, and texture, and their stability is limited under actual process noise and complex field conditions.
[0010] (4) It lacks self-supervision and consistency enhancement mechanisms, making it difficult to use historical multi-time segmentation information to optimize the current model, and the reproducibility and robustness of tracking segmentation are insufficient.
[0011] (5) The intelligent extraction and data-driven process optimization functions for defect growth and migration trends are weak, and cannot provide strong support for production decision-making and anomaly prediction. Summary of the Invention
[0012] In order to solve the above-mentioned technical problems, the present invention provides an automatic detection method for surface defects in castings.
[0013] The technical solution of this invention is implemented as follows: an automatic detection method for surface defects in castings, comprising:
[0014] S1: Acquire multi-source imaging data and morphology data of the casting surface at multiple time points during continuous production. Mark the acquisition time and area coordinate labels according to the differences in texture and illumination in different areas of the casting surface.
[0015] S2: Denoise and brightness normalization are performed on the acquired multi-source imaging data and morphology data to eliminate environmental interference and illumination changes caused by different batches and sampling locations, thereby improving the consistency of the basic data for subsequent defect area identification.
[0016] S3: Based on the normalized multi-source imaging data, a defect segmentation algorithm is used to perform preliminary segmentation of the casting surface image at each time step, and the defect region feature descriptor is extracted to generate the defect segmentation results and corresponding feature parameters for each region.
[0017] S4: For suspected same defect region, cross-temporal spatial feature matching is performed in the defect segmentation results of adjacent multiple time steps using the extracted feature descriptors and morphological change information. By estimating the spatial affine transformation based on the RANSAC algorithm, the defect position is normalized and mapped to a unified temporal anchor point space.
[0018] S5: In the temporal anchor space, the intersection and union of high-confidence regions of the segmentation results of multiple frames before and after are calculated to automatically generate defect evolution pseudo-labels, and a "soft label" confidence interval is set for regions with fluctuating segmentation boundaries to describe the dynamic change trend of the diachronic segmentation results.
[0019] S6: Input the generated defect evolution pseudo-labels into the current segmentation model as a self-supervised regularization signal to perform consistent retraining or online fine-tuning of the model, so as to improve the detection robustness and segmentation consistency of the segmentation model in the process of defect region boundary evolution.
[0020] S7: Perform a confidence consistency assessment on the current frame segmentation result and the defect evolution pseudo-label. If a significant inconsistency is detected between the segmentation boundary and the pseudo-label, the local region fine segmentation process is automatically triggered to optimize the segmentation boundary stability of the region.
[0021] S8: Combines the fine-grained defect segmentation results after multi-time defect tracking and segmentation consistency optimization with the segmentation history to automatically generate a defect region evolution trend report and store it in the full-process traceability database, realizing intelligent traceability of defect time-series evolution and data support for production process improvement.
[0022] Beneficial effects
[0023] The present invention provides an automatic detection method for surface defects in castings, which has the following beneficial effects:
[0024] Cross-temporal spatial normalization promotes the comparability of multi-time segmentation. By acquiring structured, multi-time, multi-source high-resolution imaging and 3D topographic data, combined with regional segmentation and spatial block indexing, the acquisition time, spatial coordinates, texture, and illumination characteristics of each region on the casting surface are accurately calibrated. This enables high spatiotemporal resolution tracking of defect evolution and provides a solid data foundation for segmentation consistency modeling. This normalization process effectively eliminates recording biases caused by production batches, sampling locations, and environmental perception, laying a standardized information foundation for historical evolution analysis and traceability applications.
[0025] (1) High-precision alignment of the same defect region across multiple time steps is achieved based on robust feature fusion and RANSAC spatial transformation. Through joint extraction of regional statistical features, multi-level texture features (such as LBP, HOG, Gabor, etc.), and 3D morphological changes, combined with high-confidence registration of SIFT / ORB spatial feature points, and using RANSAC robust affine transformation parameter estimation, the segmentation results are mapped to a unified temporal anchor point space. Comparison shows that the spatial overlap (IOU) of the temporally aligned regions is improved by 8%–15%, the coordinate alignment error is reduced to within 1–2 pixels, and the consistency of multi-frame segmented regions is greatly improved.
[0026] (2) This method pioneers a temporal pseudo-label and soft-label mechanism, significantly improving boundary reproducibility and trend sensitivity. By using the intersection / union of high-confidence region sets from multiple consecutive frames and the coverage probability matrix, it automatically generates solid core regions and dynamic suspicious boundary regions, and automatically assigns weights to low-consistency regions using soft-label confidence intervals. Compared to existing models that rely solely on static annotations or manual rules, this method can effectively handle complex dynamic interference scenarios on casting surfaces.
[0027] (3) By using pseudo-labels as adaptive regularization, the segmentation model is retrained and fine-tuned online to automatically suppress error propagation caused by single-frame noise and interference, thus maintaining high robustness of the segmentation model under the dynamic evolution of defect boundaries. In practical applications, after self-supervised optimization, the level of intelligence far exceeds that of static or single-frame trained fixed models.
[0028] (4) For local regions where the segmentation and pseudo-labels are significantly inconsistent, a multi-scale convolutional-boundary refinement network is automatically activated, and combined with morphological change compensation, high-resolution re-segmentation and adaptive confidence interval fusion are completed, thereby compensating for boundary abrupt changes caused by extreme process disturbances and surface state fluctuations. The local consistency improvement effect is obvious, and the fault tracing capability is significantly enhanced.
[0029] (5) Vertically integrating historical defect trends with source tracing applications to achieve a data closed loop for process optimization. This invention automatically archives fine-grained defect segmentation and tracking results with temporal evolution trends, integrates them into a full-process source tracing database, and outputs trend curves, dynamic change parameters, and visualized dynamic chart reports, providing intelligent data support for enterprise production process adjustments, anomaly warnings, and quality control. Compared with traditional isolated detection or manual trend analysis, data availability, continuity, and consistency are fundamentally improved, making business decisions more scientific and efficient. Attached Figure Description
[0030] Appendix Figure 1 This is the main flowchart of an automatic detection method for surface defects in castings;
[0031] Appendix Figure 2 This is a sub-flowchart of an automatic detection method for surface defects in castings;
[0032] Appendix Figure 3 This is another sub-flowchart of an automatic detection method for surface defects in castings. Detailed Implementation
[0033] To make the objectives and advantages of the present invention clearer, the present invention will be further described below with reference to embodiments; it should be understood that the specific embodiments described herein are merely for explaining the present invention and are not intended to limit the present invention.
[0034] Preferred embodiments of the present invention will now be described with reference to the accompanying drawings. Those skilled in the art should understand that these embodiments are merely illustrative of the technical principles of the present invention and are not intended to limit the scope of protection of the present invention.
[0035] When used herein, the singular forms of “a,” “an,” and “the” may also include the plural forms unless the context clearly indicates otherwise. It should also be understood that the terms “comprising / including” or “having,” etc., specify the presence of the stated features, wholes, steps, operations, components, parts, or combinations thereof, but do not preclude the possibility of the presence or addition of one or more other features, wholes, steps, operations, components, parts, or combinations thereof. Meanwhile, the term “and / or” as used in this specification includes any and all combinations of the associated listed items.
[0036] Please see Figure 1 As shown, an automatic detection method for surface defects in castings includes:
[0037] S1: Acquire multi-source imaging data and morphology data of the casting surface at multiple time points during continuous production. Mark the acquisition time and area coordinate labels according to the differences in texture and illumination in different areas of the casting surface.
[0038] S2: Denoise and brightness normalization are performed on the acquired multi-source imaging data and morphology data to eliminate environmental interference and illumination changes caused by different batches and sampling locations, thereby improving the consistency of the basic data for subsequent defect area identification.
[0039] S3: Based on the normalized multi-source imaging data, a defect segmentation algorithm is used to perform preliminary segmentation of the casting surface image at each time step, and the defect region feature descriptor is extracted to generate the defect segmentation results and corresponding feature parameters for each region.
[0040] S4: For suspected same defect region, cross-temporal spatial feature matching is performed in the defect segmentation results of adjacent multiple time steps using the extracted feature descriptors and morphological change information. By estimating the spatial affine transformation based on the RANSAC algorithm, the defect position is normalized and mapped to a unified temporal anchor point space.
[0041] S5: In the temporal anchor space, the intersection and union of high-confidence regions of the segmentation results of multiple frames before and after are calculated to automatically generate defect evolution pseudo-labels, and a "soft label" confidence interval is set for regions with fluctuating segmentation boundaries to describe the dynamic change trend of the diachronic segmentation results.
[0042] S6: Input the generated defect evolution pseudo-labels into the current segmentation model as a self-supervised regularization signal to perform consistent retraining or online fine-tuning of the model, so as to improve the detection robustness and segmentation consistency of the segmentation model in the process of defect region boundary evolution.
[0043] S7: Perform a confidence consistency assessment on the current frame segmentation result and the defect evolution pseudo-label. If a significant inconsistency is detected between the segmentation boundary and the pseudo-label, the local region fine segmentation process is automatically triggered to optimize the segmentation boundary stability of the region.
[0044] S8: Combines the fine-grained defect segmentation results after multi-time defect tracking and segmentation consistency optimization with the segmentation history to automatically generate a defect region evolution trend report and store it in the full-process traceability database, realizing intelligent traceability of defect time-series evolution and data support for production process improvement.
[0045] Step S1: Acquire multi-source imaging data and morphology data of the casting surface at multiple time points during continuous production. Mark the acquisition time and region coordinates for different areas of the casting surface based on differences in texture and illumination. Specifically, this includes:
[0046] S1.1: Multi-source imaging data acquisition is performed on the target area of the casting on the continuous production line. The system includes a structured light vision imaging system and a surface three-dimensional morphology scanning device. The workpiece number and batch information are used as input conditions. Through a multi-channel synchronous triggering mechanism, high-resolution surface image data and corresponding morphology data at multiple time points are obtained, and the original casting surface multi-source imaging dataset is output.
[0047] Using the casting part number and batch information on the continuous production line as input parameters, the area range that needs to be collected on the surface of the target casting is determined.
[0048] A structured light vision imaging system and a surface three-dimensional topography scanning device are used to perform multi-source synchronous imaging and topography scanning acquisition on a designated casting target area. Based on this, a multi-channel synchronous triggering mechanism (parameters: trigger delay < 5ms, channel error < 1 pixel) is used to coordinate the acquisition of multi-type, high-resolution data on the casting surface at the same time node.
[0049] Furthermore, based on the aforementioned equipment, a raw dataset is generated containing multi-band high-resolution surface reflection images and three-dimensional topographic measurement data such as spatial height, slope, and roughness. The multi-channel data is then automatically matched to a unified coordinate reference system using on-site preset equipment calibration parameters.
[0050] For data acquisition scenarios involving multiple batches and continuous time intervals, the unique acquisition timestamps and workpiece batch association codes for each group of multi-source imaging and morphology data are recorded in time intervals according to the production cycle sampling interval and workpiece flow sequence, thereby achieving structured time-series storage.
[0051] Through the above processing flow, using numerical ID, spatial region, and acquisition time as indexes, the original multi-source surface image data and morphology data are classified and organized to form an original multi-source imaging dataset of casting surface that meets the requirements of casting defect evolution tracking and segmentation consistency optimization, thereby achieving high-precision, multi-dimensional, and high spatiotemporal resolution output of the acquired data.
[0052] For example, on an automotive engine block casting production line, for each workpiece number and batch, multi-source data is synchronously acquired every 30 seconds. The specified imaging area size is 100mm × 100mm. A structured light camera with a resolution of 4096 × 3072 pixels and a laser 3D scanner with an accuracy of 10μm are used to synchronously acquire surface data of the casting. The trigger delay of the structured light imaging system is controlled within 2ms, and the spatial registration error of the multi-channel images is better than 0.5 pixels. The system automatically generates original multi-source high-resolution images and a 3D topography dataset containing timestamps, workpiece numbers, batches, and area coordinates. For 100 samples in continuous batch production, the system generates a total of 2000 sets of high-resolution multi-channel data. Verification results show that the spatiotemporal annotation accuracy of the original data reaches 99.8%, and the positioning error of file management and subsequent traceability matching does not exceed 1 pixel, fully meeting the input data quality requirements for subsequent defect area segmentation consistency modeling and evolution trend traceability analysis.
[0053] S1.2: Based on the obtained original multi-source imaging dataset of casting surface, an adaptive region segmentation algorithm is used to automatically partition the casting surface, dividing the same workpiece surface into several predefined region blocks, generating image position parameters with spatial block identifiers, realizing the systematic classification of casting surface regions, and outputting region block structure index.
[0054] The input is the original multi-source imaging dataset of the casting surface, including high-resolution surface images and three-dimensional topography data acquired at multiple times and through multiple channels, with accurate spatial registration, timestamp and workpiece number association information.
[0055] An adaptive region segmentation algorithm (parameters: target region coverage ≥ 99%, minimum segment size adjustable, region uniformity referenced by local image gradient changes) is adopted. For each casting surface image, the number of partitions and the initial position of each partition are automatically determined based on local pixel intensity changes, morphological undulation features and acquisition area boundaries.
[0056] Furthermore, by using local variable-scale segmentation methods (such as SLIC based on superpixel segmentation or K-means morphology partitioning based on clustering criteria), high-gradient change regions are densified into smaller blocks, and low-texture change regions are appropriately expanded into larger blocks. This improves the sensitivity of discrimination against regions prone to major defects and dynamically corrects the partition boundaries to ensure that the region segmentation results adapt to the complexity of the casting surface.
[0057] Furthermore, a partition boundary adjustment algorithm based on spatial continuity (such as the watershed algorithm with minimum boundary energy) is applied to reconstruct the boundaries of regions with abrupt changes in abnormal morphology, occlusion, or partition breaks, correcting the block errors caused by acquisition noise or surface disturbances.
[0058] Furthermore, through a unique spatial block encoding generation mechanism, each partition is assigned an independent spatial block identifier (such as BLOCK_ID). Combined with global regional location matrix parameters, including multi-dimensional indicators such as partition center coordinates, bounding box, area ratio, and average shape, accurate and traceable partition metadata is formed.
[0059] Through structured data output processing, the spatial block identifiers and regional location parameters mentioned above are summarized into a regional block structure index, realizing the systematic classification of the surface regions of the same workpiece, laying a unified data foundation for subsequent extraction of texture and lighting attribute parameters and multi-time partition mapping.
[0060] By employing adaptive region segmentation and spatial block coding algorithms, the original multi-source imaging data is automatically subdivided into several predefined region blocks with searchable spatial indexes, realizing the systematic classification and standardized output of spatial information of casting surface, and significantly improving the spatial accuracy and data consistency of subsequent spatiotemporal tracking and comparison of defect areas.
[0061] For example, in a casting production line, an adaptive SLIC superpixel segmentation algorithm is applied to the surface area of an engine block (100mm×100mm, 4096×3072 pixels). The initial number of region blocks is set to 64, and the final number of partitions is adaptively adjusted to 78 based on the local grayscale variance and surface gradient. The minimum block size for high-variable areas reaches 16×16 pixels, and the maximum size for low-variable areas is 96×96 pixels. Local abnormal areas are automatically corrected using a watershed algorithm to achieve a high fit between the partition boundaries and the actual defect contours. The generated region block structure index includes fields such as BLOCK_ID, partition center (unit: pixels), boundary coordinates, area percentage (mean: 1.28%), and mean region morphology. After outputting the region block structure index, 50 groups of random partitions are manually checked. The block spatial classification accuracy is 98.6%, and the partition overlap error is <3 pixels. This effectively supports subsequent operations such as texture attribute extraction, spatiotemporal label composite, and segmentation consistency comparison, and has high reusability and traceability comparability between batches. The number of blocks can be dynamically adjusted according to changes in production line processes and the needs of defect distribution areas, and is compatible with future multi-source, multi-scale analysis and cascade optimization.
[0062] S1.3: For the output region block structure index and the original casting surface multi-source imaging dataset, a texture and illumination attribute extraction method based on reflectivity distribution and illumination uniformity analysis is adopted. For each region block, surface texture feature parameters and regional illumination distribution parameters are calculated to form a texture and illumination multidimensional attribute matrix. The texture and illumination attribute parameter set used for regional difference identification is output.
[0063] S1.4: Utilizing the texture and illumination attribute parameter set and the region block structure index, combined with the acquisition timestamp information of each multi-source imaging data, and based on the time-series label generation rules, composite annotation of acquisition timestamp and spatial region coordinate labels is performed on each set of imaging data of the same casting at different time points and in different regions, and an imaging data label set with complete spatiotemporal index information is output.
[0064] S1.5: The imaging data label set with spatiotemporal index information is structurally fused with the original multi-source imaging dataset of the casting surface to construct a spatiotemporal mapping database of multi-time, multi-region, multi-channel multi-source imaging and morphology data, providing a standardized input data set for subsequent defect tracking algorithms based on cross-temporal spatial transformation and consistent segmentation models.
[0065] Step S2 involves denoising and brightness normalizing the acquired multi-source imaging and topography data to eliminate environmental interference and illumination variations caused by different batches and sampling locations, thereby improving the consistency of the basic data for subsequent defect area identification. Specifically, this includes:
[0066] S2.1: Source label normalization is performed on the acquired multi-source imaging data and morphology data to integrate the original data formats under different acquisition channels (such as visible light, structured light, etc.), unify the imaging data structure, and provide consistent input for subsequent multi-channel collaborative denoising operations.
[0067] The input consists of multi-source imaging data and morphology datasets collected and structured in step S1. These datasets contain raw data from multiple imaging channels, including visible light, structured light, infrared, and laser 3D imaging. The data file formats and annotation standards may vary, and each set of data includes timestamps, spatial coordinate labels, and batch / workpiece number metadata.
[0068] A multi-channel data scheduling and parsing program (configuration parameters: channel type enumeration table, file naming rules and path mapping table) is adopted to realize the automatic interpretation and classification of multi-source imaging data and topography data, and to achieve efficient extraction and format pre-matching of raw data from different channels.
[0069] Furthermore, through source tag parsing and standardized mapping methods (configuring channel ID mapping table and tag dictionary), based on the embedded tags or external tag files in each channel data file, the data under different acquisition channels is mapped to a unified tag domain and parsed into metadata objects containing standardized attributes such as acquisition type, spatial resolution, spatiotemporal coordinates, area block number, and batch identifier.
[0070] Furthermore, a unified data structure conversion engine (structure templates: ImageCube, HeightMap, MetaLabelSet) is adopted to achieve organization-level normalization of cross-channel raw data, and to uniformly encapsulate all types of imaging data (such as two-dimensional surface reflection images, three-dimensional topographic point clouds, etc.) into multi-dimensional tensors or structured data blocks, and inject common fields into labels, annotations and spatial coordinates to achieve structural consistency.
[0071] Furthermore, based on the normalized data structure and tag set, integrity and consistency checks are performed (rules: one-to-one correspondence between the number of files and the number of tags, tag conflict detection, and spatial pixel index alignment) to screen for omissions, ambiguities, or format conflicts that may occur during the collection, transmission, or tag generation stages. Standardized warning logs and repair suggestions are generated for abnormal records to ensure that all input data is available and that tags and data are tightly coupled.
[0072] By using the above source label normalization and data structure integration processing methods, the acquired multi-channel imaging data and morphology data are uniformly organized and aligned at the file level, label level, and structure level, providing a unique and consistent input baseline for subsequent multi-channel collaborative denoising operations, and achieving high-standard normalization between batches of complex cross-channel data at multiple time points.
[0073] For example, during the batch inspection of automotive engine blocks, the original acquisition system outputs a set of multi-channel data files every 30 seconds, generated by a structured light camera (filename format: VIS-YYMMDD-HHMMSS-ID.bmp), a laser 3D scanner (filename format: LAS-YYMMDD-HHMMSS-ID.xyz), and an infrared camera (filename format: IR-YYMMDD-HHMMSS-ID.tif). Each set contains one main image, one 3D point cloud, and one infrared image, and each has an embedded label and an external label table. The acquisition batch is 100 batches, with 20 sets of data per batch. This step first schedules all data in all directories at once according to the configuration file. Referring to the naming and label mapping table, data from different channels is automatically merged and parsed based on batch, workpiece number, and timestamp. The data is then uniformly transcoded into ImageCube (4096×3072 pixels, 16-bit), HeightMap (4096×3072 sampling points, 10μm precision), and MetaLabelSet (containing workpiece number, timestamp, BLOCK_ID, and acquisition device ID). A set of structurally strictly corresponding, labeled, and spatially aligned joint data blocks is then output after normalization. Automatic label matching and integrity checks are performed on all batches. Results show that the accuracy of one-to-one data-label correspondence is 100%, with no spatial coordinate conflicts, and label annotations are consistent with the actual data acquisition. This ultimately forms a standard input set that can be directly used for multi-channel continuous denoising and brightness normalization processing, significantly improving the automation and data consistency of multi-channel collaborative preprocessing, and laying a unified, high-quality data foundation for subsequent defect identification and segmentation models.
[0074] S2.2: Based on multi-source imaging data in a unified format, a time-domain adaptive filtering algorithm is used to remove high-frequency random noise in the image, thereby reducing interference introduced by multi-batch process disturbances and sensor background noise, and building a clean signal baseline for the stable operation of the subsequent brightness normalization algorithm.
[0075] S2.3: Apply local adaptive brightness normalization technology (such as Retinex algorithm or CLAHE algorithm) to the denoised multi-source imaging data. Dynamically adjust the gray-level histogram distribution of the imaging data according to the changes in light intensity or shadow in different sampling areas to achieve standardized transformation of global and local brightness characteristics.
[0076] S2.4: For multi-source imaging data with normalized brightness, perform cross-source topography feature alignment: using topography data (such as height field or gradient map) as a spatial reference, use affine or nonlinear mapping algorithms to accurately register the imaging data with the spatial pixel grid of the topography data, and obtain highly consistent multi-source collaborative preprocessing results.
[0077] S2.5: For multi-source imaging data and topography data that have been aligned, calculate the normalized statistics (such as mean, standard deviation, etc.) of intensity characteristics between regions, and use these statistical properties to set the normalization threshold of subsequent defect segmentation feature parameters to ensure that defect region identification parameters are comparable and robust throughout the entire life cycle and under multiple working conditions.
[0078] Step S3: Based on the normalized multi-source imaging data, a defect segmentation algorithm is used to initially segment the surface image of the casting at each time step, and defect region feature descriptors are extracted to generate defect segmentation results and corresponding feature parameters for each region. For example... Figure 2 As shown, it specifically includes:
[0079] S3.1: Perform time-series preprocessing on the multi-source imaging data after denoising and brightness normalization to align the spatial resolution, scale, and pixel arrangement of the images at each time point, providing standardized input for the subsequent defect segmentation algorithm and obtaining a spatiotemporally aligned normalized image dataset.
[0080] S3.2: Based on the spatiotemporally aligned normalized image dataset, a specific defect segmentation algorithm (such as the deep learning U-Net network structure or traditional segmentation algorithm) is used to perform preliminary defect pixel-level segmentation on the surface image of the casting at each time step to obtain the original defect mask data.
[0081] For the spatiotemporally aligned normalized image dataset, a deep learning U-Net network structure (parameters: encoder layer number = 5, convolution kernel size = 3×3, pooling stride = 2, dropout rate = 0.2) or traditional segmentation methods such as Otsu thresholding and region growing are used to perform pixel-level segmentation, which corresponds one-to-one with the normalized input data of each frame of the casting surface image to generate the original defect segmentation probability map.
[0082] Furthermore, through the forward inference module of the U-Net network, each frame of normalized image after S3.1 time-series processing is input, and multi-level spatial-texture features are automatically extracted to complete the feature encoding and upsampling decoding process, resulting in a segmentation probability mask P(x, y), where (x, y) is the spatial index of the pixel.
[0083] Furthermore, the segmentation probability mask P(x, y) is binarized using the maximum probability discrimination criterion, and the following threshold segmentation formula is adopted:
[0084]
[0085] Where T is an adaptive threshold, set based on the statistical mean and distribution characteristics of the batch samples, and M(x,y) is a binary defect mask.
[0086] Furthermore, a morphological filling and edge compensation algorithm (parameters: structuring element type = cross shape, size = 5×5) is used to process the segmented binary mask, eliminate isolated noise points and small holes, and obtain a coherent defect area mask.
[0087] Furthermore, the binding relationship between each frame segmentation mask and spatiotemporal metadata is recorded to generate the original defect mask dataset, providing input basis for processes such as defect region extraction and feature numbering in S3.3.
[0088] Through the pixel-level segmentation and probabilistic discrimination processing described above, the normalized input image is effectively transformed into a high-confidence original defect mask, realizing automatic separation of defect regions and laying a technical foundation for subsequent structured analysis of defect regions and modeling of historical evolution trends.
[0089] For example, in the inspection scenario of high-pressure cast aluminum engine cylinder blocks, the resolution of each batch of workpiece images after normalization preprocessing is 4096×3072 pixels. The U-Net network structure adopts the ResNet-34 backbone, with 64 batches of normalized images input, and the inference time per frame is 0.12 seconds. Using a normalized segmentation threshold T=0.65, and performing three iterative closing operations based on a 5×5 cross-shaped structure element, an average of 2-5 independent defect masks can be obtained per frame. The actual output mask defect area detection error is less than 2.5%, and the average IOU of the segmentation boundary reaches 0.91. For areas with blurred boundaries or drastic lighting changes, probabilistic filtering + binary thinning processing can effectively eliminate missed detections and artifacts, ensuring accurate segmentation of defect areas under complex batch / multi-source conditions, and outputting a standardized original mask set for subsequent batch processing in the numbering and feature description steps.
[0090] S3.3: Based on the defect mask data of each frame, morphological analysis methods (such as connected component analysis and erosion dilation operation) are applied to extract independent defect regions, and each defect region is numbered and spatially labeled to obtain a set of defect regions containing spatial indexes.
[0091] The input is the original defect mask data of each frame of the casting surface after time-series alignment and normalization. The data structure includes a pixel-level binary mask matrix and the corresponding spatiotemporal metadata.
[0092] The connected component analysis method (parameter: pixel connectivity is set to 8-connected) is used to segment the regions of each independent pixel block in the binary defect mask, extract all connected defect region components that meet the minimum region area threshold, and establish a pixel coordinate index for each connected region.
[0093] Furthermore, through morphological erosion and dilation operations (parameters: structuring element uses 3×3 square kernel, erosion iterates once, dilation iterates once), the boundaries of the initially divided connected regions are refined and small noise filling is corrected, isolated pixels and tiny artifacts are removed, and the continuity and integrity of the regions are optimized.
[0094] Furthermore, a region size filtering algorithm (parameters: minimum effective defect area A_min, maximum compensation area A_max, A_min = 20 pixels, A_max = 100000 pixels) is used to filter regions that meet the defect judgment criteria, so as to exclude background connectivity misjudgments and occasional interference blocks.
[0095] Furthermore, through the area number assignment module, the above-mentioned valid defect areas are automatically assigned incremental numbers from the top left to the bottom right, and an area label mapping table is generated to achieve unique identification of the area.
[0096] Furthermore, using the spatial centroid and circumscribed rectangle calculation method, the geometric center point ((x) of each numbered region is extracted. c ,y c The minimum bounding rectangle parameters (width, height, and position coordinates) are obtained and stored in association with the numbering information to construct a set of defect areas containing spatial indexes.
[0097] Through the aforementioned algorithms such as connected component analysis, morphological optimization, and spatial geometry extraction, the initial segmentation defect mask is effectively transformed into a structured set of independent defect regions. Each region is assigned a spatial number and location label, enabling precise spatial separation of defects within the same frame and efficient management of multi-region information.
[0098] For example, in the scenario of batch non-destructive testing of high-pressure cast aluminum engine cylinder blocks, an 8-connected component analysis algorithm was used for a single-frame defect mask with a resolution of 4096×3072 pixels. The minimum defect area threshold A_min was set to 50 pixels. Erosion / dilation were performed using a 3×3 square kernel, each iterating once. The regions were numbered from top left to bottom right. In typical batch samples, each frame was segmented into an average of 3–12 effective connected defect regions, with the largest single area being approximately 3×10⁴ pixels and the smallest effective area being approximately 52 pixels. Fine-dot artifacts at the boundaries were automatically filtered out through erosion, and no misclassification or omissions were observed. All independent regions were labeled with numbers and centroid coordinates, and the region label information corresponded one-to-one with the segmentation results. In practical applications, the defect region set processed in the above way can be directly used for subsequent feature description (sweep region grayscale, texture analysis) and temporal tracking, laying the spatial organization foundation for subsequent multi-time-time dynamic comparison and evolution trend analysis of defects.
[0099] S3.4: For each defect region after numbering, use statistical feature extraction algorithms (such as region gray mean, area, perimeter, shape factor, etc.) combined with texture feature extraction algorithms (such as LBP, HOG, Gabor filtering, etc.) to jointly generate a multi-dimensional feature descriptor for the defect region to characterize its texture, shape and spatial attributes.
[0100] The input is a set of independent defect regions after step numbering and spatial location marking in S3.3. Each region contains pixel coordinate index, number information and spatial metadata.
[0101] A statistical feature extraction algorithm (parameter settings: grayscale channel is selected as the main acquisition channel, and the statistical area is limited to the connected component mask) is used to calculate the basic geometry and grayscale parameters of each defect area.
[0102] Furthermore, the mean gray level μ of the region is calculated using the following formula:
[0103]
[0104] Where N is the number of pixels in the region, R is a subset of pixel coordinates in the defect region, and I(x, y) is the grayscale value at (x, y). This achieves the representation of the overall brightness characteristics of the defect region.
[0105] Furthermore, the following indicators are calculated using area and perimeter extraction algorithms: the area is defined as the total number of pixels A = N within the connected region, the perimeter is obtained by the length P of the region boundary pixels, and the foreground-background boundary discrimination adopts the eight-neighbor boundary tracking method.
[0106] Furthermore, a shape factor calculation algorithm is used to extract features such as compactness and roundness. The commonly used compactness formula is as follows:
[0107]
[0108] Where A is the area and P is the perimeter, used to reflect the regularity of the region's shape.
[0109] Furthermore, based on the texture feature extraction algorithm, the Local Binary Pattern (LBP) algorithm (parameter settings: sampling neighborhood radius r = 1, number of sampling points p = 8) is used to encode the local structural pattern of the defect area and extract the LBP histogram as the distribution feature.
[0110] Furthermore, the Histogram of Oriented Gradients (HOG) algorithm (parameter settings: patch size 16×16 pixels, gradient direction bins set to 9) is applied to aggregate directional information such as edges and ridges within the region to generate feature vectors that reflect the directionality of local texture.
[0111] Furthermore, a Gabor filter bank (parameters: scale = 3, direction = 6, spatial frequency coverage 0.05-0.25 cycles / pixel) is used to extract the multi-scale and multi-directional response of the pixel distribution within the region, and Gabor energy is obtained as a multi-dimensional texture response index.
[0112] Through the collaborative processing of the above-mentioned multi-algorithm, the statistical features and texture features of each numbered defect region are fused into a multi-dimensional feature descriptor, thereby achieving a refined quantitative representation of the defect region in terms of brightness, geometry, morphology, and multi-level texture space.
[0113] By structurally binding feature descriptors with regional index data, a highly robust and high-resolution input feature vector is provided for subsequent cross-time series multi-region matching and defect evolution history analysis.
[0114] For example, in the defect detection process of high-pressure cast aluminum engine cylinder blocks, the area of a typical single-frame defect region ranges from 52 to 3 × 10^4 pixels, the grayscale mean μ ranges from 70 to 190 (depending on the acquisition channel and defect type), and the compactness C is mostly in the range of 0.3 to 0.85. Texture feature extraction uses an LBP radius of 1 and 8 sampling points to generate a 256-dimensional histogram, HOG features are 576-dimensional, and Gabor filter responses form an 18-dimensional feature vector. After feature fusion, an 850-dimensional feature combination vector is generated for each region. In practical applications, through the above-mentioned fused feature descriptors, highly reliable spatial-texture comparison of the same defect region at multiple time points can be achieved, with a defect history evolution matching accuracy of over 97.5%. This effectively supports downstream segmentation consistency analysis and trend prediction, demonstrating strong adaptability and discriminative power in batch detection, complex morphology, and high variability backgrounds.
[0115] S3.5: Map the defect mask data corresponding to each frame to the extracted defect region feature descriptors one by one, and output a standardized defect segmentation result set and associated feature parameter set, providing structured input for subsequent cross-temporal spatial feature matching and segmentation consistency analysis.
[0116] Step S4: For suspected same defect region, cross-temporal spatial feature matching is performed using the extracted feature descriptors and morphological change information in the defect segmentation results at adjacent time steps. By estimating the spatial affine transformation based on the RANSAC algorithm, the defect location is normalized and mapped to a unified temporal anchor point space. Figure 3 As shown, it specifically includes:
[0117] S4.1: Based on the defect segmentation results obtained in the previous process, extract the feature descriptors and morphological change parameters of each suspected same defect region as input conditions for subsequent temporal spatial matching. By locating the spatial performance of the defect region at adjacent time points, establish a descriptive basis for cross-temporal spatial feature fusion.
[0118] The input data consists of the defect segmentation results at each time step output from the previous process, the set of independent defect regions with corresponding numbers, and the multi-dimensional feature descriptors of the regions, including spatial location, geometric parameters, grayscale and multi-level texture information, as well as the associated topography data (such as three-dimensional height field and gradient field).
[0119] A spatial region filtering algorithm (parameters: maximum displacement d_max between temporal frames, threshold Δc for changes in the centroid of the region) is adopted to automatically filter out a set of suspected defective regions that are close in spatial location, have the same number, or have a feature vector Euclidean distance less than the set threshold between each pair of adjacent time segmentation results, thereby achieving preliminary cross-temporal region pairing.
[0120] Furthermore, using a region feature descriptor alignment method (parameters: Euclidean distance threshold ε_1, texture correlation coefficient threshold ρ_1), the multi-dimensional feature descriptor of each suspected defect region in the previous time step is compared pairwise with the feature descriptors of each candidate region in the current time step, and the matching score S is calculated:
[0121] S = w1·D stat +w2·D lbp +w3·D hog +w4·D gabor
[0122] Where D stat To normalize the differences in the statistics (gray level / area / perimeter), D lbp For LBP histogram similarity, D hog D is the HOG characteristic cosine distance. gabor The Gabor energy difference is represented by w1 to w4, which are weighting coefficients.
[0123] Furthermore, using the morphological change analysis method, the change amplitude ΔH of the morphological parameters of the suspected area between the previous time and the current time is calculated, as shown in the following formula:
[0124]
[0125] Where H t (x, y) represents the height value within region R of the current frame, H t-1 (x,y) represents the height value of the corresponding region in the previous frame, and N represents the number of pixels in the region.
[0126] Furthermore, by combining the feature descriptor similarity score S with the morphological change ΔH, a weighted aggregation criterion is used to select region pairs that meet the joint threshold of similarity and morphological magnitude, thus obtaining cross-temporal spatial feature pairing results:
[0127] Q = α·S + β·ΔH
[0128] Where α and β are empirical weighting parameters.
[0129] Through the above processing method, the input multi-time suspected defect regions are converted into highly reliable feature descriptions and morphological change pairing data, providing the location and similarity quantitative indicators of each pair of regions in the temporal space, laying the data foundation for subsequent accurate spatial feature matching and spatial affine transformation parameter estimation, and realizing the initial technical support for the entire cross-temporal spatial feature fusion processing chain.
[0130] For example, in a continuous production scenario for monitoring surface defects in high-pressure cast aluminum engine cylinder blocks, the typical image resolution per batch is 4096×3072, and each frame is segmented to obtain an average of 4–10 defect regions, with region numbers automatically generated. Parameter setting: Maximum spatial displacement d max =40 pixels, region centroid change Δc < 25 pixels, feature vector Euclidean distance threshold ε_1 = 0.2, LBP / HOG histogram cosine similarity threshold ρ_1 = 0.85, and morphological change ΔH upper limit is 5μm. Feature descriptor weighting coefficients w_1:w_2:w_3:w_4 = 0.25:0.25:0.25:0.25, pairing criterion weighting α = 0.7, β = 0.3. When pairing region features, the relevant indicators of suspected regions are calculated in batches in parallel. Through the above chain-like feature alignment and morphological change analysis, the numbering pairing table and feature similarity matrix of each pair of spatially corresponding regions are output. The verification results show that the accuracy of this step in cross-temporal identification of the same defect region in complex environments is better than 98.2%, providing a highly robust input foundation for subsequent cross-temporal spatial transformation and region alignment processing in S4.2~S4.4.
[0131] S4.2: For the extracted feature descriptors and morphological change parameters, a spatial feature matching algorithm, such as local feature point matching based on SIFT or ORB, is used to calculate the spatial correspondence of suspected same defect areas in multi-time segmentation maps and obtain a preliminary cross-temporal spatial correlation matrix.
[0132] The input data includes the cross-temporal suspected defect region pairing results output from the previous step, the multi-dimensional feature descriptors of each defect region, and the temporal corresponding morphological change parameters.
[0133] Local feature point detection and description algorithms (such as SIFT or ORB, with parameters: detection threshold set to 0.04 and maximum number of feature points set to 2500) are used to extract feature points and generate descriptors in the segmented block images at their respective time points for each pair of suspected defective regions that have been preliminarily screened, thereby achieving a high-dimensional expression of the feature structure inside the region.
[0134] Furthermore, using a feature point matching algorithm (parameters: KNN matching, k=2, distance ratio threshold 0.75), for the defect region descriptors of the previous and current time steps, all feature point pairs are traversed and Euclidean distances are calculated. Nearest neighbor matching and second nearest neighbor matching are selected, and high-confidence feature point pairs are screened out under the control of the distance ratio threshold.
[0135] Furthermore, using a spatial pose consistency discrimination method (parameter: number of extreme matching pairs n_min = 15), spatial constraint checks are performed on all acquired feature point pairs. Only point pairs whose distribution satisfies local neighborhood constraints, whose main morphological direction is consistent, or whose height variation is within ΔH_max are retained, while abnormal pairs that deviate significantly from the regional structure are removed.
[0136] Furthermore, a shape-induced spatial constraint algorithm (parameter: maximum allowable spatial deformation error ε_m = 5 pixels) is adopted, combined with the principal direction or gradient distribution of the three-dimensional height field, to perform secondary screening on the point set selected by feature point pairing, retaining only point pairs with fully overlapping spatial distributions and corresponding height differences less than ε_m, thereby improving the physical rationality of the matching.
[0137] Furthermore, by constructing a spatial feature matching relation matrix M ij M ij =1 indicates that the feature point at time i and the feature point at time j are a valid high-confidence matching pair, M ij =0 indicates invalidity. By summarizing all valid matching pairs, a preliminary correlation matrix across time and space is formed.
[0138] Through the above spatial feature matching algorithm chain processing, the internal local features and morphological data of suspected same defect regions in multi-time segmentation maps are paired with high confidence, which significantly enhances the robustness and accuracy of cross-temporal spatial region registration, realizes the consistent association of the spatial location and structural expression of the same defect region between segmentation maps, and provides high-resolution, structured input for subsequent spatial affine transformation parameter estimation, region alignment and anchor point spatial normalization processing.
[0139] For example, in the automatic inspection scenario of the high-pressure die-cast aluminum engine cylinder block production process, for single-region segmentation output with a resolution of 4096×3072 pixels, the SIFT algorithm (threshold 0.04, maximum detection of 2500 feature points) achieves a feature point distribution coverage of over 95%. The feature point descriptor dimension is 128-dimensional, outputting approximately 1800–2200 feature points per pair of regions. KNN matching with k=2 and a distance ratio threshold set to 0.75 significantly improves the mismatch point removal rate. The extreme value matching quantitative assessment threshold n_min=15 results in an average of 24–73 high-confidence matching pairs per pair of regions. Through spatial constraints and morphological principal direction compensation, the final feature matching average spatial error is <3.2 pixels, and the outlier point removal pairing ratio is greater than 99.2%. The density of the output spatial feature matching relation matrix is better than 0.86. In practical verification, even under scenarios with drastic changes in regional structure or significant morphological disturbances in the temporal imaging results of different batches of castings, an effective cross-temporal registration accuracy of over 95.8% can still be maintained. Finally, the preliminary cross-temporal spatial correlation matrix output is used as the confidence matching input to support subsequent RANSAC robust affine transformation modeling, achieving high-precision mapping of temporal anchor points in defect regions.
[0140] S4.3: Using the above-mentioned cross-temporal spatial correlation matrix, the spatial affine transformation parameters are robustly estimated through the RANSAC algorithm. For each pair of adjacent time-series segmented images, the spatial mapping relationship between defective regions is automatically calculated, unreliable outlier matching pairs are eliminated, and a reliable spatial affine transformation model is formed.
[0141] The input is the preliminary cross-temporal spatial correlation matrix output by step S4.2, which includes the high-confidence matching pairs of feature points of suspected same defect regions at adjacent time points on the segmented image and their spatial coordinate attributes.
[0142] The RANSAC (Random Sample Consensus) robust spatial transformation parameter estimation algorithm (parameters: maximum number of iterations N_iter, inlier distance threshold ε_r, minimum number of model sample points n_min = 3) is adopted. For each pair of adjacent time-separated segmented images, the minimum model set is randomly sampled and fitted to a two-dimensional affine transformation model.
[0143] Furthermore, spatial parameters are fitted to the matching feature points of each pair of regions using the following affine transformation model:
[0144]
[0145] Where (x, y) are the coordinates of the feature point at the previous time step, (x'y') are the coordinates of the feature point at the current time step, {a ij} represents the linear transformation coefficients, and t1 and t2 are the translation parameters.
[0146] Furthermore, using the RANSAC interior-exterior discrimination mechanism, the reprojection error e under the current affine model is calculated sequentially for all matching feature points:
[0147]
[0148] Where (x' est y' est (x') represents the predicted coordinates after affine model transformation. obs ,y' obs () represents the actual coordinates of the paired feature points. For errors less than the distance threshold ε r Points that are not internal are marked as internal points; otherwise, they are marked as external points.
[0149] Furthermore, in all RANSAC iterations, the affine parameter set that yields the largest number of interior points is selected as the optimal spatial transformation parameter to establish a confidence spatial affine transformation model. Outlier outlier matching pairs are removed, and only the interior point matching dataset from the high-confidence affine model is retained as the basis for subsequent mapping.
[0150] Furthermore, for cases with a small number of large displacements or noise matching, an iterative weighted least squares optimization algorithm is applied to correct the interior point set weights of the affine parameters, thereby improving the adaptability to complex working conditions and actual deformation scenarios.
[0151] By using the RANSAC robust spatial affine transformation parameter estimation and interior point screening mechanism described above, the cross-temporal spatial matching relationship output in the previous step is transformed into a high-confidence spatial mapping model, which greatly improves the robustness and anti-interference ability of coordinate alignment between segmented regions.
[0152] For example, in the scenario of segmenting and tracking defects on the surface of a high-pressure cast aluminum engine cylinder block, the input is a segmented image with a resolution of 4096×3072. For each pair of suspected defect regions, SIFT feature extraction yields 1800–2200 feature point pairs, with an average of 65 initially effective matching pairs. RANSAC parameters are configured with a maximum of 1000 iterations and an inlier distance threshold ε. r =3.0 pixels, minimum model sample 3 pairs. RANSAC fits the affine model in each round, with an average of over 58 inlier pairs, accounting for more than 89%. The final output spatial transformation matrix of the optimal affine parameter set matches the inlier set with high confidence, and the average reprojection error of the largest inlier set is less than 1.9 pixels. For batch data with perturbations and random noise, after weighted least squares optimization iterations, the model reprojection error is reduced to 1.2 pixels, and the region alignment accuracy and temporal consistency are significantly improved, providing a spatially consistent affine transformation model input for subsequent defect anchor point spatial normalization and evolution trend analysis.
[0153] S4.4: Based on the confidence space affine transformation model, the coordinates of the defect regions on the segmented images at adjacent time steps are normalized, and each defect region is uniformly mapped to the set temporal anchor point space to realize the coordinate alignment of the defect regions across the temporal space and output the set of normalized temporal anchor point coordinates of the defect regions.
[0154] S4.5: For the normalized set of temporal anchor point coordinates of the defect region, the spatial coverage criterion is further used to automatically determine whether they are the same defect evolution body, and local morphological adjustment compensation is performed on the region boundary to output the defect region features after consistency calibration, providing a reliable spatial alignment basis for the next step of pseudo-label generation and segmentation consistency assessment.
[0155] Step S5: In the temporal anchor point space, intersection and union calculations are performed based on the high-confidence regions of the segmentation results from multiple consecutive frames to automatically generate defect evolution pseudo-labels. A "soft label" confidence interval is set for regions with fluctuating segmentation boundaries to describe the dynamic trend of the diachronic segmentation results. Specifically, this includes:
[0156] S5.1: High-confidence region extraction is performed on the multi-frame defect segmentation results in the input temporal anchor point space. A confidence threshold algorithm is used to filter the high-confidence regions in the segmentation mask of each frame to obtain the set of high-confidence defect segmentation regions at each time point, so as to eliminate the interference of low-confidence pixels on the region evolution analysis.
[0157] Within the temporal anchor point space, the normalized defect region, number, block index, and aligned topography data output from the previous processing step (S4.5) are used as input. A pixel-level confidence threshold algorithm (parameter: threshold T_conf, typically set to 0.85–0.95) is employed to analyze the confidence distribution of each pixel output by the model for each frame of the segmentation mask, thereby automatically extracting high-confidence segmentation regions.
[0158] Furthermore, using a confidence mask construction method (parameters: minimum connected region area A_min, spatial continuity threshold Δc), discrete high-confidence points caused by random noise or tiny false positive pixels are removed, and only high-confidence connected region regions with a connected area greater than A_min are retained. The remaining high-confidence pixels are then aggregated to form a high-confidence candidate region mask.
[0159] Furthermore, a spatial consistency discrimination method is used to determine the spatial overlap rate of high-confidence candidate region masks across frames. The intersection-union ratio (IOU) metric is used to determine the degree of spatial overlap between adjacent time points of high-confidence candidate regions, and to screen a set of high-confidence regions that are stable in position and consistent in shape between temporal frames.
[0160] Furthermore, a region numbering mapping and confidence sequence extraction method is adopted to establish cross-temporal numbering tracking for each candidate defect region. High-confidence pixels of the same numbered region in multiple frames are extracted into a confidence temporal sequence, and the spatial coordinate set and corresponding confidence score of the high-confidence segmentation results at each time point are output.
[0161] Through the above high-confidence region screening and number tracking process, low-confidence pixels in the multi-time segmentation results are removed or ignored, thereby achieving high-reliability input data preparation for defect region evolution analysis and reducing the impact of interference points on subsequent pseudo-label generation and segmentation boundary evolution analysis.
[0162] For example, in the scenario of detecting surface defects in high-pressure cast aluminum engine cylinder blocks, a confidence mask output by a deep convolutional segmentation model (such as a variant of U-Net) is used. With a confidence threshold T_conf = 0.90, high-confidence pixels with a confidence score greater than 0.90 are extracted from each frame of 4096×3072 pixel segmentation results. The minimum connected component area A_min is set to 200 pixels, and the spatial continuity criterion Δc is set to 30 pixels, automatically removing breakpoints and isolated points. Using an IOU greater than 0.7 as the cross-frame spatial consistency screening standard, 3–8 high-confidence region numbers and their temporal variation sequences can be effectively extracted from 5 frames of temporal segmentation data. The processing results show that the average spatial overlap between the improved confidence regions and the manually reviewed segmentation results exceeds 97.3%, significantly improving the data quality and robustness of subsequent pseudo-label evolution analysis, and providing a stable basic dataset for intersection and union calculations and dynamic soft label assignment.
[0163] S5.2: Based on the set of high-confidence regions, perform intersection and union calculations of defect segmentation results at multiple time points. Use set operation methods to obtain the spatial overlap area (intersection) and maximum expansion area (union) of high-confidence defect regions at each time point, and generate the basic data structure that characterizes the historical stable range and possible evolution trajectory of defect regions.
[0164] The input is a set of high-confidence defect segmentation regions at different time points within the temporal anchor point space output from the previous processing step. Each set is a mask of the high-confidence defect region for the corresponding time frame, and all have undergone spatial affine normalization and numbering consistency calibration.
[0165] Employing a multi-frame spatial set operation method (parameter: time window length T) w (Set types include intersection and union). For high-confidence regions with the same ID, parallel set operations are performed on the corresponding pixel sets of all time frames within the temporal anchor point space to obtain the following spatial mask set: the set M of high-confidence defect regions for all time frames k. k The spatial intersection M is calculated according to the formula. core Union of spaces M unionCalculation:
[0166]
[0167] Among them, M core The intersection of high-confidence defect region pixels at all times represents the spatially stable core region of the defect region in the multi-frame history.
[0168]
[0169] Among them, M union The set of pixels representing high-confidence defect regions at all times represents the maximum possible historical evolution range of the defect region.
[0170] Furthermore, through the spatial coverage matrix calculation method (parameter IOU threshold θ) iou For each pixel in the intersection and union results, the temporal coverage probability is statistically analyzed to form the coverage distribution matrix P(x, y) of each pixel on the time axis:
[0171]
[0172] in, As an indicator function, P(x, y) reflects the frequency with which the point belongs to the high-confidence region across all time frames, and is used to quantify the spatiotemporal stability and evolutionary activity of the region.
[0173] Furthermore, an adaptive optimization algorithm for the regional boundary is adopted (the parameter is the regional area change threshold A). thr Boundary fluctuation threshold E bd ), for M union With M core By comparing the boundary morphology, spatial segments that significantly deviate from the intersection are automatically identified and grouped, laying the foundation for subsequent soft label assignment and evolutionary partitioning.
[0174] Through the above chain processing method, the spatial intersection and union operations of defect regions with the same number at multiple time points are completed. The output includes a basic data structure containing a high-confidence historical spatial overlap area (intersection), a maximum expansion area (union), and a spatiotemporal coverage probability distribution. This provides structured input for modeling the evolution trend of defect regions and assigning dynamic soft labels, enabling accurate characterization of defect spatial evolution and extraction of historical variation trends.
[0175] For example, in the scenario of tracking surface defects in a high-pressure die-cast aluminum engine block, T is selected. w =5-frame time window, single frame resolution 4096×3072 pixels, the operation object is a high-confidence segmented mask after being filtered by a confidence threshold and spatially aligned (threshold set to 0.9). Spatial set operations are accelerated using bitwise operations, theoretically calculating M core With M unionThe average area A per frame is in the range of [500, 12000] pixels. Statistical analysis using the coverage distribution matrix P(x, y) shows that over 95% of the intersection of most actual defect areas (P(x, y) ≥ 0.8) is consistent with manually labeled areas, and the maximum expansion of the boundary (P(x, y) ≤ 0.2) roughly indicates the dynamic evolution potential area. The entire process outputs spatial masks of the core and maximum regions, as well as a coverage probability distribution matrix, providing a foundation for subsequent defect trend pseudo-label generation and attribute analysis. The high robustness and high spatiotemporal consistency of this integrated effect are crucial for improving the interpretability and trend identification capabilities of defect tracing between production batches.
[0176] S5.3: Based on the intersection and union results, generate defect evolution pseudo-labels: the segmented intersection region is defined as the "solid core region" of defect evolution, and the segmented union region but not the intersection region is defined as the "suspicious boundary region". The defect evolution pseudo-label mask is constructed with multi-frame superposition analysis logic to achieve unified identification of the same defect region across time and space.
[0177] S5.4: For the boundary fluctuation areas where defects are segmented and concentrated, the degree of fluctuation of the historical segmentation boundary in the same area is statistically evaluated based on the temporal consistency analysis algorithm. Confidence intervals are used to assign soft labels and mark the confidence gradient interval for unstable boundary areas in order to scientifically quantify the dynamic change trend of defect areas.
[0178] S5.5: Integrates the defect evolution pseudo-label mask and the confidence interval of the soft label to output a composite defect evolution pseudo-label set, providing accurate information input containing temporal confidence weights for subsequent consistent self-supervised training and segmentation model fine-tuning, thereby realizing the automation of defect tracking and segmentation and improving its historical robustness.
[0179] Step S6: Input the generated defect evolution pseudo-labels into the current segmentation model as self-supervised regularization signals to perform consistent retraining or online fine-tuning of the model, thereby improving the detection robustness and segmentation consistency of the segmentation model during the defect region boundary evolution process. Specifically, this includes:
[0180] S6.1: Based on the segmentation history, obtain the defect evolution pseudo-labels in the temporal anchor space and the corresponding defect region segmentation results. Associate the defect evolution pseudo-labels with the defect region segmentation results at each time step to construct a defect segmentation consistency training set based on historical temporal information.
[0181] S6.2: For the defect region segmentation results in the defect segmentation consistency training set, a pseudo-label supervised adaptive regularization algorithm is adopted. The defect evolution pseudo-label is used as a self-supervised regularization signal to automatically adjust the loss function structure of the current segmentation model, so that the segmentation model can enhance its response to the evolution of the defect region boundary over time during the training phase.
[0182] For the defect region segmentation results in the defect segmentation consistency training set, a pseudo-label supervised adaptive regularization algorithm (parameters: confidence threshold T_conf, regularization weight α, soft label interval β) is adopted to realize the processing flow of automatically guiding the segmentation model optimization with defect evolution pseudo-labels as self-supervised regularization signals.
[0183] An adaptive pseudo-label supervision loss term is constructed based on the predicted mask output by the current segmentation model and the corresponding defect evolution pseudo-label mask, using a loss function structure adjustment method. The loss structure includes the main segmentation loss L... seg Pseudo-label consistency regularization loss L consis And soft label boundary weighted loss L soft .
[0184] Furthermore, the principal segmentation loss (such as Dice loss or cross-entropy loss) is defined by the following formula: L seg :
[0185]
[0186] Among them, Y i P represents either a real label or a pseudo label (e.g., 1 for the intersection, 0 otherwise). i The pixel-level probabilities output by the model.
[0187] Furthermore, a pseudo-label region consistency loss is adopted, defined as follows:
[0188]
[0189] Among them, Ω core The set of pixels in the solid core region generated by the intersection. This is a high-confidence pseudo-label for the pixels in this area.
[0190] Furthermore, for regions that are unions but not intersections, the soft-label boundary loss is defined as follows:
[0191]
[0192] Among them, Ω border w represents the set of pixels in the suspected boundary region. j S is the weighting factor distributed according to the confidence level frequency. j This represents the soft label probability score (e.g., the value of the coverage distribution matrix P(x,y)).
[0193] Through the total loss function:
[0194] L total =L seg +αL consis +βL soft
[0195] Wherein, α and β are adaptive regularization weight parameters, which are dynamically adjusted according to the boundary consistency evaluation results.
[0196] The adaptive regularization parameter adjustment relies on the historical segmentation and pseudo-label space overlap statistics obtained in the previous steps. According to the preset dynamic adjustment strategy (such as appropriately increasing β when the proportion of inconsistent boundary regions increases, and prioritizing the increase of α when the proportion of consistent core regions is high), the sensitivity of the loss structure to the evolution of defect boundaries is self-driven and enhanced.
[0197] Through the chained processing based on pseudo-label-supervised adaptive regularization, the segmentation model's ability to respond to the temporal evolution of defect region boundaries is continuously improved, effectively suppressing segmentation jumps caused by single-frame interference, and enhancing the temporal consistency and boundary stability of defect segmentation results under complex working conditions.
[0198] For example, in the scenario of detecting surface defects in a high-pressure cast aluminum engine cylinder block, a consistent training set of defect segmentation within five frames of temporal anchor points has been obtained. The main segmentation loss uses pixel-level cross-entropy, the consistency regularization weight α of the pseudo-label core region is 0.8, and the soft label boundary regularization weight β is initially set to 0.3, which can be dynamically adjusted to a maximum of 0.6. The soft label weight w... j The historical coverage distribution matrix P(x, y) is used for direct mapping, with a distribution range of [0.2, 0.8]. During training, it was observed that without initial pseudo-label self-supervision, the temporal boundary consistency F1 score was only 0.82, and the maximum boundary jump variable could reach as high as 12 pixels. After introducing the adaptive regularization structure above, the temporal boundary consistency F1 score improved to 0.93 after convergence on the training set, and the average boundary jump variable decreased to within 3 pixels, indicating that the pseudo-label self-supervised regularization algorithm significantly improved the responsiveness and consistency of the defect segmentation model to boundary evolution. Finally, the output is the parameter set and optimization log of the segmentation model after self-supervised online regularization optimization, laying a highly stable model foundation for subsequent multi-time-step defect tracking and trend analysis.
[0199] S6.3: By utilizing the boundary consistency measure between historical defect region segmentation results and defect evolution pseudo-labels, representative samples are dynamically sampled, and the target segmentation model is gradually adjusted based on an online fine-tuning strategy to improve the detection robustness of the segmentation model in the defect region boundary evolution process in a self-supervised manner.
[0200] S6.4: Introducing a built-in reliability evaluation mechanism to perform a subjective and objective fusion evaluation of the fitting degree between the segmentation model output and the defect evolution pseudo-label in the main boundary region. Based on the evaluation results, the self-supervised regularization weights are adjusted in a timely manner to achieve an adaptive consistency retraining process.
[0201] S6.5: Generates a parameter set for the defect segmentation model after consistent retraining or online fine-tuning, and performs phased verification of the model performance. It outputs a defect region segmentation model with enhanced temporal consistency, providing robust support for subsequent defect tracking and multi-time segmentation comparison results.
[0202] Step S7: A confidence consistency assessment is performed on the current frame segmentation result and the defect evolution pseudo-label. If a significant inconsistency is detected between the segmentation boundary and the pseudo-label, a local region fine-tuning process is automatically triggered to optimize the segmentation boundary stability of that region. Specifically, this includes:
[0203] S7.1: Calculate the boundary coordinate overlap between the defect region boundary obtained from the current frame segmentation result and the high confidence region of the defect evolution pseudo-label. Use spatial overlap indicators such as boundary IOU (Intersection over Union) to quantify the segmentation consistency and obtain confidence consistency evaluation parameters between the segmentation result and the pseudo-label.
[0204] S7.2: Based on the confidence consistency evaluation parameters, the threshold discrimination algorithm is used to screen out local defect areas with fluctuating segmentation boundaries or insufficient consistency, and output the corresponding local segmentation anomaly candidate area coordinate set as the target object for subsequent fine segmentation processing.
[0205] S7.3: For the coordinate set of segmentation anomaly candidate regions, the segmentation results at multiple time points, defect evolution pseudo-labels, and temporal morphological change parameters are integrated. A multi-scale convolution and boundary refinement network model is used to perform high-resolution resegmentation of local regions and continuously iteratively optimize the local segmentation boundary.
[0206] The input consists of the coordinate set of local segmentation anomaly candidate regions obtained by filtering according to step S7.2, the defect segmentation results at multiple time points before and after, the defect evolution pseudo-labels, and the temporal morphological change parameters.
[0207] A multi-scale convolutional feature enhancement method (parameters: kernel size {3×3, 5×5, 7×7}, number of layers 3 to 5, stride 1, and zero padding strategy) is adopted to extract feature information and model fine-grained structure of local segmentation anomaly candidate regions at different spatial scales.
[0208] Furthermore, a boundary refinement network (parameters: boundary guidance loss coefficient λ = 0.5, number of upsampling levels N = 2, boundary guidance label sampling radius r = 2 pixels) is used to combine the solid core area generated by the pseudo-label with the suspicious boundary area as a supervision signal to perform high-resolution refinement of the pixel-level boundary information of the local abnormal area.
[0209] Based on the superposition of feature maps of multi-time segmentation results and defect evolution pseudo-labels, temporal topographic change parameters (such as regional elevation difference Δh and surface gradient change Δg) are fused, and a topographic-aware weight adjustment algorithm is adopted to dynamically adjust the mixed weights of multi-scale features and boundary features according to the following formula:
[0210] w mix =η1·f conv +η2·f bnd +η3·Δh+η4·Δg
[0211] Among them, f conv For the convolutional feature output, f bnd The boundary refinement characteristic response, Δh is the local elevation difference, Δg is the surface gradient change, and η is the boundary refinement characteristic response. i These are the normalized weighted coefficients, i = 1, 2, 3, 4.
[0212] Furthermore, through an iterative refinement and optimization mechanism, the above multi-scale convolution-boundary refinement-feature mixing operation is continuously iterated for each candidate anomaly region until the rate of change of the IOU (Intersection over Union) of the segmentation output and the pseudo-label boundary region, |ΔIOU|, is less than a preset threshold τ (e.g., 0.01), or the maximum number of iterations (e.g., T) is reached. max =5), automatically terminate the optimization iteration.
[0213] Through a high-resolution re-segmentation process, the segmentation boundary of the local abnormal region is gradually optimized to be highly consistent with the evolution trend and morphological information at multiple time points, compensating for local segmentation jumps caused by single-frame interference or extreme working conditions, and achieving spatial fine-grained stability of the defect segmentation boundary.
[0214] For example, in the batch inspection scenario of high-pressure cast aluminum cylinder blocks, for the segmentation anomaly candidate regions screened by S7.2, a 3-layer multi-scale convolutional network (kernel sizes of 3×3, 5×5, and 7×7 respectively) is selected, combined with a 2-level boundary refinement upsampling network (boundary guiding label sampling radius r = 2 pixels, loss weight λ = 0.4). The five-frame temporal segmentation results are superimposed with the solid core region and suspicious boundary region of the defect evolution pseudo-label as joint feature input, and morphological parameters such as temporal elevation difference statistics Δh = 0.03 mm and surface gradient change Δg = 2.1° are fused. The feature mixing weights are set to η1 = 0.55, η2 = 0.25, η3 = 0.1, and η4 = 0.1 respectively. Each anomaly region is iterated for a maximum of 5 rounds, and the IOU convergence threshold τ is set to 0.02. Test results show that this process can improve the temporal IOU index of candidate region fine segmentation boundaries by an average of 0.07–0.13, reduce boundary jump pixels by 10–25% under extreme conditions, and improve multi-time segmentation consistency to over 94%. The final output is a fine-grained local defect segmentation mask optimized by high-resolution multi-scale re-segmentation, providing highly reliable segmentation basis data for subsequent confidence fusion and global trend analysis.
[0215] S7.4: The consistency evaluation of the local segmentation boundary results after fine segmentation optimization and the original pseudo-label boundary is carried out again. The final local segmentation confidence interval is generated by the adaptive confidence fusion algorithm as the new subdivision label to ensure that the updated defect region segmentation boundary is compatible with the multi-time evolution trend.
[0216] S7.5: The final fine-grained defect region boundary, after confidence consistency fusion and fine segmentation optimization, is fed back to the overall segmentation result and the time-series defect evolution pseudo-label database to form a closed-loop feedback, providing highly consistent segmentation basis data for subsequent defect tracking and evolution trend analysis.
[0217] Step S8: The fine-grained defect segmentation results, optimized for consistency between multi-time defect tracking and segmentation, are combined with the segmentation history to automatically generate a defect region evolution trend report and store it in the full-process traceability database. This enables intelligent traceability of defect temporal evolution and data support for production process improvement. Specifically, this includes:
[0218] S8.1: Perform multi-time aggregation processing on the fine-grained defect segmentation results after consistency optimization. Based on the segmentation boundary change sequence, integrate historical segmentation data to generate a time-by-time evolution trajectory dataset of the defect region, so as to realize the full merging of the dynamic evolution information of defects.
[0219] S8.2: Based on the evolution trajectory dataset, a trend analysis algorithm is used to quantitatively calculate the changes in segmentation parameters (such as area, perimeter, centroid, and boundary roughness) of defect areas, obtain the changing trends of the main features over time, and provide data support for the generation of trend reports.
[0220] S8.3: Apply visualization processing methods to transform the extracted defect evolution trend data into chart-like results (such as trend curves, waveform information, and dynamic maps of regional evolution) to generate a defect region evolution trend report for process analysis.
[0221] The dynamic parameter set and time-by-time boundary change index set output by the defect region evolution trend analysis are processed by a trend visualization modeling method (parameters: target feature sequence {area, perimeter, center coordinates, boundary roughness}, time series coverage window W, sampling interval Δt) to realize the curve modeling of key defect segmentation parameters in the entire time series.
[0222] By applying a trend curve extraction algorithm and smoothing the time series (method: SG filter or moving average, window length K such as K=3~5), noise suppression and trend line construction are performed on the parameter sequences such as area, perimeter, and boundary roughness of the defect region, and a one-dimensional trend curve dataset reflecting the "steady state", "abrupt change" and "growth trend" of the defect region is generated.
[0223] Furthermore, through waveform analysis and segmentation detection algorithms (such as CWT continuous wavelet transform, parameters: mother wavelet type Morlet, scale range [1,10]), the mutation points, inflection points and growth rate change intervals in the segmentation parameter sequence are identified, key waveform features representing dynamic behaviors such as defect expansion and migration are extracted, and a time coordinate-feature intensity comparison matrix is output.
[0224] Furthermore, by using a multi-frame sequence image synthesis algorithm and a region mask dynamic overlay method, the segmentation mask or boundary curve of the defect region evolving over time is stacked in time. Pseudo-color encoding (parameters: different color marks are mapped at different time points, transparency α = 0.5~0.8) is used to display the defect evolution process in the form of dynamic map, heat map or pseudo-color stacked map, realizing the visualization output of three-dimensional linkage of space-time-morphology.
[0225] The chart generation engine automatically aggregates the aforementioned trend curves, waveform features, and dynamic chart objects into a unified defect evolution trend analysis report template (parameters: report layout, column configuration, interactive index, etc.), achieving standardized data encapsulation of trend quantification data and visualization results.
[0226] By using multi-dimensional visualization processing methods, the segmentation history and key evolution parameters obtained in the previous step are transformed into trend curves, waveform information, and time-series dynamic diagrams in a process analysis-friendly display format, enabling intuitive analysis of defect evolution trends and data-driven process improvement support.
[0227] For example, in the scenario of tracking defects in automotive cylinder block casting, the time-series indices of area, perimeter, and boundary roughness of the fine-grained segmentation results are processed using a 5-frame time window (Δt = 40s, W = 200s). A 3rd-order Savitzky-Golay filter is used to smooth the segmentation parameter sequence, extracting abrupt change points in defect area. Morlet wavelets are set as the mother wavelet, with a CWT scale range of 2–8, automatically detecting 2–3 points each of area growth and contour abrupt change. Through dynamic stacking of multi-frame defect masks, blue-red gradient pseudo-color encoding is used, with a transparency set to 0.75, generating a dynamic graph of defect region evolution. Simultaneously, based on a Python report generator, all trend curves, abrupt change waveforms, and dynamic graphs are embedded into an interactive PDF report. Practical application shows that the above method can support timely identification and parameterized quantification of dynamic defect expansion within a batch. The trend report provides a reliable decision-making basis for on-site process adjustments and anomaly warnings. The data encapsulation results can be directly connected to the MES traceability module, achieving traceable management of the entire defect lifecycle.
[0228] S8.4: Standardize the metadata encapsulation of the defect evolution trend report and the corresponding fine-grained segmentation results, and store them in a structured manner in the full-process traceability database based on the traceability data interface protocol, so as to establish a data index for production process backtracking and defect cause analysis.
[0229] S8.5: Regularly perform data integrity scans and consistency audits on the defect area evolution trend reports stored in the traceability database, and use historical multi-time defect data to verify the continuity and accuracy of data in real time, ensuring the high availability of traceability information and the stability of the intelligent traceability process.
[0230] The technical solution of the present invention has been described above with reference to the preferred embodiments shown in the accompanying drawings. However, it will be readily understood by those skilled in the art that the scope of protection of the present invention is obviously not limited to these specific embodiments. Without departing from the principles of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after these changes or substitutions will all fall within the scope of protection of the present invention.
[0231] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and rules of the present invention should be included within the scope of protection of the present invention.
Claims
1. An automatic detection method for surface defects in castings, characterized in that, Includes the following steps: S1: Acquire multi-source imaging data and morphology data of the casting surface at multiple time points during continuous production, and mark the acquisition time and area coordinate labels according to the differences in texture and illumination in different areas of the casting surface. S2: Perform noise reduction and brightness normalization processing on the multi-source imaging data and morphology data; S3: Based on normalized multi-source imaging data, a defect segmentation algorithm is used to perform preliminary segmentation of the casting surface image at each time step, and defect region feature descriptors are extracted to generate defect segmentation results and corresponding feature parameters for each region. S4: For suspected same defect area, cross-temporal spatial feature matching is performed in the defect segmentation results of adjacent multiple time steps using the extracted feature descriptors and morphological change information. By estimating spatial affine transformation, the defect position is normalized and mapped to a unified temporal anchor point space. S5: In the time-series anchor point space, the intersection and union of the high-confidence regions of the segmentation results of multiple frames before and after are calculated to generate defect evolution pseudo-labels, and soft label confidence intervals are set for regions where the segmentation boundary fluctuates. S6: Input the defect evolution pseudo-label into the current segmentation model as a self-supervised regularization signal, and perform consistent retraining or online fine-tuning of the model; S7: Perform a confidence consistency assessment on the current frame segmentation result and the defect evolution pseudo-label. If a significant inconsistency is detected between the segmentation boundary and the pseudo-label, trigger the local region fine segmentation process. S8: Combine the fine-grained defect segmentation results after multi-time defect tracking and segmentation consistency optimization with the segmentation history to generate a defect region evolution trend report and store it in the full-process traceability database.
2. The automatic detection method for surface defects of castings according to claim 1, characterized in that, Step S1 specifically includes: Multi-source imaging data acquisition is carried out on the target area of castings on a continuous production line. The system includes a structured light vision imaging system and a surface three-dimensional morphology scanning device. The workpiece number and batch information are used as input conditions. Through a multi-channel synchronous triggering mechanism, high-resolution surface image data and corresponding morphology data at multiple time points are obtained, and the original casting surface multi-source imaging dataset is output. Based on the original multi-source imaging dataset of the casting surface, an adaptive region segmentation algorithm is used to automatically partition the casting surface, dividing the same workpiece surface into several predefined region blocks, generating image position parameters with spatial block identifiers, and outputting the region block structure index. For the region block structure index and the original casting surface multi-source imaging dataset, a texture and illumination attribute extraction method based on reflectivity distribution and illumination uniformity analysis is adopted. For each region block, surface texture feature parameters and regional illumination distribution parameters are calculated to form a texture and illumination multi-dimensional attribute matrix, and a texture and illumination attribute parameter set for regional difference identification is output. Using the texture and illumination attribute parameter set and the region block structure index, combined with the acquisition timestamp information of each multi-source imaging data, and based on the time-series label generation rules, composite annotation of acquisition timestamp and spatial region coordinate labels is performed on each set of imaging data of the same casting at different time points and in different regions, and an imaging data label set with complete spatiotemporal index information is output. The imaging data tag set with spatiotemporal index information is structurally fused with the original multi-source imaging dataset of the casting surface to construct a spatiotemporal mapping database of multi-time, multi-region, multi-channel multi-source imaging and morphology data.
3. The automatic detection method for surface defects of castings according to claim 2, characterized in that, The parameters of the multi-channel synchronous triggering mechanism are trigger delay less than 5ms and channel error less than 1 pixel.
4. The automatic detection method for surface defects of castings according to claim 1, characterized in that, In step S2, the denoising uses a time-domain adaptive filtering algorithm, and the brightness normalization uses the Retinex algorithm or the CLAHE algorithm.
5. The automatic detection method for surface defects of castings according to claim 1, characterized in that, Step S3 specifically includes: Perform time-series preprocessing on the multi-source imaging data after denoising and brightness normalization to align the spatial resolution, scale, and pixel arrangement of the images at each time point, and obtain a spatiotemporally aligned normalized image dataset. Based on the spatiotemporally aligned normalized image dataset, a defect segmentation algorithm is used to perform preliminary defect pixel-level segmentation on the surface image of the casting at each moment frame by frame to obtain the original defect mask data. Based on the defect mask data of each frame, morphological analysis is used to extract independent defect regions, and each defect region is numbered and spatially labeled to obtain a set of defect regions containing spatial indexes. For each defect region after numbering, a multi-dimensional feature descriptor for the defect region is jointly generated by combining a statistical feature extraction algorithm with a texture feature extraction algorithm. The defect mask data corresponding to each frame is mapped one-to-one with the defect region feature descriptor, and a standardized defect segmentation result set and associated feature parameter set are output.
6. The automatic detection method for surface defects of castings according to claim 5, characterized in that, The defect segmentation algorithm is a model based on the deep learning U-Net network structure. The U-Net encoder has 5 layers, a convolution kernel size of 3×3, a pooling stride of 2, and a dropout rate of 0.
2.
7. The automatic detection method for surface defects of castings according to claim 1, characterized in that, Step S4 specifically includes: Based on the defect segmentation results obtained at each time point, feature descriptors and morphological change parameters of each suspected same defect region are extracted. For the feature descriptors and the morphological change parameters, a spatial feature matching algorithm is used to calculate the spatial correspondence between suspected defect regions in multi-time segmentation maps, and a preliminary cross-temporal spatial correlation matrix is obtained. Using the aforementioned cross-temporal spatial correlation matrix, the spatial affine transformation parameters are robustly estimated using the RANSAC algorithm. For each pair of adjacent time-series segmented images, the spatial mapping relationship between defect regions is automatically calculated, and unreliable outlier matching pairs are eliminated to form a reliable spatial affine transformation model. Based on the confidence space affine transformation model, the coordinates of the defect regions on the segmented images at adjacent time points are normalized, and each defect region is uniformly mapped to the set temporal anchor point space, outputting the set of normalized temporal anchor point coordinates of the defect regions. For the normalized set of time-series anchor point coordinates of the defect region, the spatial coverage criterion is further used to automatically determine whether they are the same defect evolution body, and local morphological adjustment compensation is performed on the region boundary to output the defect region features after consistency calibration.
8. The automatic detection method for surface defects of castings according to claim 1, characterized in that, Step S6 specifically includes: Based on the segmentation history, obtain the defect evolution pseudo-labels in the temporal anchor space and the corresponding defect segmentation results. Associate the pseudo-labels with the segmentation results at each time point to construct a consistent defect segmentation training set. For the defect segmentation consistency training set, a pseudo-label supervised adaptive regularization algorithm is used to automatically adjust the loss function structure of the current segmentation model; By utilizing the boundary consistency measure between the historical defect region segmentation results and the defect evolution pseudo-labels, representative samples are dynamically sampled, and the parameters of the target segmentation model are gradually adjusted based on an online fine-tuning strategy. A built-in reliability evaluation mechanism is introduced into the algorithm to evaluate the fit between the model output and the pseudo-label in the boundary region. The self-supervised regularization weights are adjusted in a timely manner based on the evaluation results. Generate a parameter set for the segmentation model after consistent retraining or online fine-tuning, verify the model performance in stages, and output a segmentation model with enhanced temporal consistency.
9. The automatic detection method for surface defects of castings according to claim 1, characterized in that, Step S8 specifically includes: The fine-grained defect segmentation results after consistency optimization are aggregated at multiple time points. Combined with the segmentation boundary change sequence and historical data, a time-by-time evolution trajectory dataset of the defect region is generated. Based on the evolution trajectory dataset, a trend analysis algorithm is used to quantitatively calculate the changes in segmentation parameters of defective regions and obtain the changing trends of key features over time. By applying visualization processing methods, defect evolution trend data is transformed into trend curves, waveform information, and dynamic maps of regional evolution, generating defect region evolution trend reports for process analysis. The evolution trend report and segmentation results are encapsulated in standardized metadata and stored in a structured manner in the full-process traceability database based on the traceability data interface protocol, so as to establish a data index for process backtracking and defect cause analysis. The defect area evolution trend reports stored in the traceability database are periodically subjected to integrity scans and consistency audits, and historical defect data is used to verify the continuity and accuracy of the data.
10. The automatic detection method for surface defects of castings according to claim 9, characterized in that: The defect region evolution trend report includes time series trend curves, waveform analysis results, and dynamic images of defect area, perimeter, center coordinates, and boundary roughness parameters. The visualization uses pseudo-color encoding and is stored in a structured metadata format.
Citation Information
Patent Citations
Method for detecting abnormal state of parts based on images shot by train vehicle intelligent inspection robot
CN116012579A
Pull rivet fluorescent crack detection method based on improved YOLOV5 model
CN116664511A