Method for detecting surface defects of aircraft power distribution equipment based on standard sample library

CN122289849BActive Publication Date: 2026-09-11CHENGDU AIRCRAFT INDUSTRY GROUP
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202610739637.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-05-27
Publication Date
2026-09-11
Estimated Expiration
2046-05-27

AI Technical Summary

Technical Problem

[0005]本发明公开了基于标准样本库的飞机配电设备表面缺陷检测方法,基于融合图像制作标准样本数据集,训练无监督模型进行检测,解决飞机配电设备缺陷样本稀缺、标注成本极高、微小缺陷漏检、高风险区域检测灵敏度不足、缺陷边界模糊以及无法量化缺陷等问题,实现对飞机配电设备表面缺陷的准确检测和定位,大幅提升检测的可靠性、安全性与效率

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122289849B_ABST
    Figure CN122289849B_ABST
Patent Text Reader

Abstract

This invention discloses a method for detecting surface defects in aircraft electrical equipment based on a standard sample library. By establishing a structural functional region segmentation model, differentiated weights, sampling rules, and judgment thresholds are configured for regions with different risk levels, achieving accurate detection with high sensitivity in high-risk areas and low false detection rate in normal areas, thus meeting the safety requirements of aviation products. Compared with the basic PatchCore model, the method utilizes HRNet combined with CBAM to maintain high-resolution features while taking into account both local and global features, enabling better detection of minute defects. The method employs weighted K-medoids clustering to construct a memory library, which compresses the memory library size, improves detection efficiency, and avoids uneven feature distribution, thereby ensuring detection accuracy. Based on the anomaly heatmap obtained from PatchCore, the SAM model is used for defect segmentation, which can quantify the size of defects, determine their morphological characteristics, and assess their severity.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the technical field of equipment surface defect detection, specifically relating to a method for detecting surface defects in aircraft electrical equipment based on a standard sample library. Background Technology

[0002] The surface condition of aircraft electrical equipment is directly related to the insulation performance and conductivity reliability of the power system. Common surface defects such as scratches, cracks, corrosion spots, and stains, if not detected in time, can lead to short circuits, leakage, and other faults, seriously threatening flight safety. Currently, surface defect detection technologies for aircraft electrical equipment are mainly divided into three categories: traditional manual and machine vision inspection, supervised deep learning inspection, and traditional unsupervised inspection. However, all of them have significant technical bottlenecks. Traditional inspection relies on manual visual inspection or simple machine vision algorithms, such as threshold segmentation and edge detection, which are greatly affected by the inspector's experience and fluctuations in lighting conditions. The surfaces of aircraft electrical equipment are mostly made of metal, which easily produces reflections and shadows, resulting in a high rate of missed detection of minor defects. At the same time, the inspection process relies on manual intervention, which is inefficient. Existing defect detection models based on supervised learning, such as CNN and YOLO series, require a large number of labeled defect samples for training. However, as aerospace-grade high-reliability products, aircraft electrical equipment has undergone strict quality control during the design and manufacturing stages, and the probability of defects occurring in actual operation is low. This results in a low natural occurrence rate of defect samples, a relatively scarce total number of samples, and the need for professional aviation maintenance personnel to label defects, which is extremely costly. Even if a small number of defect samples are obtained, their types, sizes, shapes, and background environments are often relatively simple, making it difficult to cover all possible defect patterns in actual applications, thus limiting the model's generalization ability.

[0003] Unsupervised learning eliminates the need for defect sample annotation, identifying defects solely through learning the features of undefected samples, thus addressing the problem of scarce defect samples. However, existing unsupervised detection methods still have shortcomings. Unsupervised models, such as PatchCore, employ CNN models like ResNet, which perform continuous downsampling, easily losing spatial information and detailed features, leading to missed detections of minute defects. Furthermore, using uniform detection rules for different risk areas fails to consider texture differences and defect type variations across different structural regions of the detected object, making it difficult to assign higher detection sensitivity to safety-critical areas in aircraft electrical equipment, resulting in missed detections in high-risk areas and false detections in common areas. PatchCore's in-memory library construction often uses random or greedy sampling, leading to uneven feature distribution and information redundancy, affecting anomaly detection accuracy and efficiency. The anomaly heatmap generated by PatchCore provides only the approximate defect area, with often vague and inaccurate boundaries, failing to quantify the size and shape of the defect or assess its severity.

[0004] Therefore, in order to address the problems of existing detection methods in detecting defects in aircraft electrical equipment, such as scarce samples, extremely high labeling costs, missed detection of minor defects, insufficient detection sensitivity in high-risk areas, ambiguous defect boundaries, and inability to quantify defects, this invention discloses a method for detecting surface defects in aircraft electrical equipment based on a standard sample library. Summary of the Invention

[0005] This invention discloses a method for detecting surface defects in aircraft electrical equipment based on a standard sample library. A standard sample dataset is created based on fused images, and an unsupervised model is trained for detection. This method solves the problems of scarce defect samples in aircraft electrical equipment, extremely high annotation costs, missed detection of minor defects, insufficient detection sensitivity in high-risk areas, blurred defect boundaries, and inability to quantify defects. It enables accurate detection and localization of surface defects in aircraft electrical equipment, significantly improving the reliability, safety, and efficiency of detection.

[0006] This invention is achieved through the following technical solution: A method for detecting surface defects in aircraft electrical equipment based on a standard sample library includes the following steps: Step 1: Acquire standard sample images and test images at different angles and shooting shutter speeds, fuse the standard sample images according to a predetermined sequence, and fuse the test images according to a predetermined sequence. Step 2: Establish a structural region partitioning model using template matching algorithm; perform risk partitioning on the aircraft power distribution equipment drawings using the partitioning model; assign different risk weights to different risk partitions; and set defect judgment thresholds for different risk partitions. Step 3: Introduce the CBAM attention extraction mechanism into the Bottleneck of the PatchCore model, and replace the ResNet network in the PatchCore model with the HRNet network to obtain the improved PatchCore model. Based on the structural importance weight map, set differentiated sampling priorities for the Patch features in the improved PatchCore model according to the regional weights corresponding to their spatial locations. Step 4: Train the improved PatchCore model using the defect-free images obtained from the fusion in Step 1. Construct a memory containing feature vectors in the improved PatchCore model, and perform a hybrid indexing of quantization and inverted indexing on the memory to obtain the trained PatchCore model. Step 5: Use the trained PatchCore model to extract feature vectors from the test image, calculate the feature anomaly score between the current feature vector and its neighboring vectors based on the memory bank, calculate the anomaly heatmap of the current image region based on the feature anomaly score, extract the maximum value in the anomaly heatmap as the region anomaly score of the current image region, and determine whether there is a defect in the current image region based on the region anomaly score. Step 6: Based on the anomaly heatmap, calculate the center coordinates and minimum bounding rectangle of the image region with defects as segmentation hints. Input the test image and segmentation hints into the SAM model to obtain the segmentation mask of the current image region. Calculate the geometric features of the defects in the current image region based on the segmentation mask.

[0007] To better realize the present invention, step 4 further includes: Step 4.1: Input the defect-free image into the feature extractor of the HRNet network, and extract the feature maps of different resolution branches output by the last stage of the HRNet network through the feature extractor. Step 4.2: Perform feature weighting enhancement on each feature map using the CBAM attention extraction mechanism to obtain the enhanced feature map; Step 4.3: Use a sliding window to extract local patches from the feature map to obtain the patch feature set. Merge all training images with the patch feature set to obtain the initial global memory pool. Step 4.4: Based on the structural importance weight map, perform spatial location mapping for each Patch feature in the Patch feature set, use the weighted Euclidean distance of the Patch features as the feature similarity measure, use the K-medoids clustering algorithm to cluster the initial global memory pool, and store the center point of each cluster as a representative feature in the memory bank. Step 4.5: Apply a hybrid index of quantization and inverted index to the memory. The hybrid index includes the memory and the feature extractor and feature similarity measure associated with the memory. The trained PatchCore model is obtained based on the memory.

[0008] To better implement the present invention, further, in step 4.4, the weighted Euclidean distance of the Patch feature is used as the feature similarity measure, and the initial global memory pool is divided into K clusters, the center point of each cluster satisfies the condition that the total deviation of all objects in the Patch feature from the center point of its respective cluster is minimized.

[0009] To better realize the present invention, step 5 further includes: Step 5.1: Perform consistency processing on the fused test image according to the standard sample image to make the test image consistent with the standard sample image in terms of size and pixel value distribution range; Step 5.2: Use the feature extractor of the HRNet network in the trained PatchCore model to extract multi-scale feature maps of the test image, and generate the Patch feature set of the test image based on the multi-scale feature maps according to the consistent Patch generation rules in the model training stage. Step 5.3: For each feature vector in the Patch feature set, retrieve the k nearest neighbor vectors in the memory and calculate the weighted Euclidean distance between the feature vector and its neighbor vectors as the feature anomaly score of the current image region. Step 5.4: Based on the extraction location of the patch, place the feature anomaly scores on the corresponding coordinates of a two-dimensional grid to form a sparse anomaly score matrix. Use the bilinear interpolation algorithm to upsample the sparse anomaly score matrix to obtain the initial anomaly feature map. Step 5.5: Perform weighted fusion on the initial anomaly feature maps of the same size to obtain a fused anomaly feature map, and upsample the fused anomaly feature map to obtain an anomaly heatmap; Step 5.6: Extract the maximum value from the abnormal heatmap as the regional abnormality score of the current image region, and use the defect judgment threshold to divide the abnormal heatmap into regions for judgment; if the regional abnormality score is greater than or equal to the defect judgment threshold, the current region is judged as a defect candidate region; if the regional abnormality score is less than the defect judgment threshold, the current region is judged as a defect-free region.

[0010] To better realize the present invention, further, in step 6, the formula for calculating the center coordinates of the image region with defects is as follows: ; in: P core Ω represents the center coordinates of the image region with defects; Ω represents the set of pixels in the abnormal heatmap whose region anomaly score is greater than or equal to the defect determination threshold. s ( x , y ) indicates that the coordinates in the abnormal heat map are ( x , y The region anomaly score of the pixel at () x Represents pixels in an abnormal heatmap x Coordinate values; y Represents pixels in an abnormal heatmap y Coordinate values.

[0011] To better realize the present invention, further, in step 6, the formula for calculating the minimum bounding rectangle of the image region with defects is as follows: ; Where: Ω represents the set of pixels in the abnormal heatmap whose regional anomaly score is greater than or equal to the defect judgment threshold; x Represents pixels in an abnormal heatmap x Coordinate values; y Represents pixels in an abnormal heatmap y Coordinate values; xmin , y min () represents the pixel coordinates of the top-left corner of the smallest bounding rectangle; x max , y max () represents the pixel coordinates of the bottom right corner of the smallest bounding rectangle.

[0012] To better implement this invention, furthermore, in step 1, the algorithm for fusing the test images is as follows: ; in: I F ( x , y ) represents the pixel coordinates of the test image at a certain angle and shutter speed. x , y The weighted fusion strength value at () This represents the pixel coordinates of the test image at a certain angle and the k-th shutter speed. x , y The normalized weight value at () I k ( x , y ) represents the pixel coordinates of the test image at a certain angle and the k-th shutter speed. x , y The intensity value at ().

[0013] To better realize the present invention, further, in step 1, the algorithm for fusing the standard sample images is as follows: ; in: Indicates the first i The first angle and the second k Pixel coordinates of a standard sample image at a shutter speed ( x , y The weighted fusion strength value at () Indicates the first i The first angle and the second k Pixel coordinates of a standard sample image at a shutter speed ( x , y The normalized weight value at () Indicates the first i The first angle and the second k Pixel coordinates of a standard sample image at a shutter speed ( x , y The intensity value at ().

[0014] To better realize the present invention, further, in step 1, the sharpness of the fused standard sample image is calculated using the Sobel gradient model. If the sharpness of the fused standard sample image is qualified, the distortion of the fused standard sample image is calculated. If the distortion of the fused standard sample image is qualified, the illumination uniformity of the fused standard sample image is calculated. The fused standard sample image with qualified sharpness, distortion, and illumination uniformity is retained.

[0015] Compared with the prior art, the present invention has the following advantages and beneficial effects: This invention establishes a structural functional region segmentation model, configuring differentiated weights, sampling rules, and judgment thresholds for regions with different risk levels. This achieves accurate detection with "high sensitivity in high-risk areas and low false detection rate in normal areas," adapting to the safety requirements of aviation products. Compared to the basic PatchCore model, the use of HRNet combined with CBAM maintains high-resolution features while taking into account both local and global features, enabling better detection of minor defects. The use of weighted K-medoids clustering to construct the memory reduces the memory size, improves detection efficiency, and effectively avoids uneven feature distribution, thus ensuring detection accuracy. Based on the anomaly heatmap obtained from PatchCore, the SAM model is used for defect segmentation, which can quantify the size of defects, determine their morphological characteristics, and assess their severity. Attached Figure Description

[0016] Figure 1 This is a schematic diagram of the steps of the present invention; Figure 2 This is a schematic diagram of the data acquisition device; Figure 3 A flowchart for building and training the PatchCore model; Figure 4 This is a diagram of the PatchCore algorithm architecture. Detailed Implementation

[0017] Example 1: This embodiment presents a method for detecting surface defects in aircraft electrical equipment based on a standard sample library, such as... Figure 1 As shown, it includes the following steps: Image acquisition device debugging; like Figure 2 As shown, the test piece is placed at the center of the rotating stage, with the geometric centerline of the test piece aligned with the central axis of the rotating stage. An industrial camera is fixed at the center of the device, and a ring-shaped LED light is arranged above the camera lens. The position and angle of the ring-shaped LED light are adjusted so that the projected light from the ring-shaped LED light evenly covers the test piece. The position, angle, and parameter settings of the industrial camera are adjusted so that the test piece is completely within the imaging area of ​​the camera and the image is clear.

[0018] Image data acquisition: Acquire images of standard samples; A standard sample of defect-free aircraft electrical equipment is fixed at the center of a rotating stage as the test piece. The stage is rotated, and at each rotation angle, the aperture and ISO of the camera are kept constant. The shutter speed is changed according to a preset exposure value sequence, and the camera is synchronously triggered to acquire images at each shutter speed. The image acquired at the nth shutter speed at the i-th rotation angle is denoted as S. i,n .

[0019] Acquire test images; The aircraft electrical distribution device under test is fixed at the center of the rotating platform as the test piece. At a certain angle, the shutter speed is changed according to the same exposure value sequence as in the above-mentioned standard sample image acquisition steps, and the first image is acquired. i At the first rotation angle n A sequence of test images captured at various shutter speeds. I i,n .

[0020] Image fusion processing; A sequence of standard sample images acquired at different speeds from each angle. S i,n and test image sequence I i,n Image fusion processing is performed, and the fused test image is denoted as... I F The standard sample image is denoted as .

[0021] Prior modeling of aircraft power distribution equipment structural areas: Structural functional area division; Based on the CAD drawings of aircraft electrical equipment, structural functional regions are divided, and a structural importance weight map is generated. This guides K-medoids clustering to compress the memory database size, while retaining hard samples in high-risk regions for supplementation, achieving efficient memory database compression while ensuring that key region feature details are not smoothly lost. For patch features of different weight regions, anomaly scores are calculated based on region weights, and different thresholds are set for different regions to adapt to the defect sensitivity of different regions. Based on the CAD design drawings of aircraft electrical equipment, a structural region division model is established using a template matching algorithm, dividing the image space into three types of structural functional regions: High-risk area - terminal block area; medium-risk area - fastener area; low-risk area - metal housing area.

[0022] Generation of structural importance weight graph; Based on the safety risk level of each region, different weights are assigned: high-risk areas are assigned weight w1, medium-risk areas are assigned weight w2, and low-risk areas are assigned weight w3, with w1 > w2 > w3, generating a structural importance weight map corresponding to the image size.

[0023] Setting the threshold for determining regional defects; Configure independent anomaly detection thresholds for different regions, with a threshold of T for high-risk regions. H The threshold for medium-risk areas is T. M The threshold for low-risk areas is T. L Regions with higher weights have lower thresholds and higher detection sensitivity. The standard sample images obtained through fusion are used. Create a standard sample dataset; Image normalization preprocessing; First, all the standard sample images obtained from the fusion process... Adaptive median filtering is used to remove noise from industrial cameras while preserving subtle textures. Then, bilinear interpolation is used to scale the size of the denoised image to H×W pixels to unify the size. Finally, local histogram equalization is used to adjust the gray mean of all sample images to the neutral gray range.

[0024] Sample quality assessment and screening; The Sobel gradient model is used to measure image sharpness using the global mean, the mean square error of the images before and after denoising is calculated to measure denoising distortion, the grayscale standard deviation is used to measure illumination uniformity, and a sharpness threshold T is set. c Minimum Distortion Threshold T low The highest distortion threshold T high Illumination uniformity threshold T l Image filtering is performed by comparing with a threshold.

[0025] Data augmentation involves targeted data augmentation of the selected high-quality samples, including minor translations and rotations, small random adjustments to brightness and contrast, and the addition of trace amounts of Gaussian noise.

[0026] Metadata annotation and dataset partitioning; A unique metadata file is generated for each sample image, recording information such as its acquisition location, acquisition parameters, structural region segmentation results, preprocessing method, and enhancement type. The dataset is then divided into training set: validation set: test set = 7:2:1.

[0027] like Figure 3 and Figure 4 As shown, we construct and train the improved PatchCore model.

[0028] The ResNet network in the traditional Patchcore model is replaced by a multi-resolution HRNet network to maintain high-resolution features, thus taking into account both local details and global context. Furthermore, a CBAM attention extraction mechanism is introduced into the Bottleneck of the Patchcore model. This mechanism strengthens the channel weights of effective features through channel attention and highlights the feature responses of high-risk regions through spatial attention, achieving accurate extraction of detailed features.

[0029] A structure-prior-guided weighted K-medoids clustering method is used to construct a memory. When building the memory representing normal patterns, the generated structural importance weight map is used as a basis to assign differentiated sampling priorities to patch features according to the region weights corresponding to their spatial locations. This guides K-medoids clustering to compress the memory size while retaining hard samples in high-risk regions for supplementation, achieving efficient memory compression while ensuring that feature details in key regions are not smoothly lost. For anomaly score calculation based on structural regions, anomaly distance calculation rules matching the region weights are used for patch features in different structural functional regions. Different thresholds are set for each region to adapt to the defect sensitivity of different regions.

[0030] The improved PatchCore model was trained using a standard sample dataset; Input constructs a standard sample dataset ,in S n For the first n Zhang's flawless image, N Given the total number of samples, pixel normalization preprocessing is performed on each image.

[0031] Multi-scale feature extraction; The preprocessed defect-free sample images are input into the HRNet network feature extractor. We extract feature maps from the different resolution branches output by the last stage of HRNet. Let k of the resolution branches be selected; then for the input defect-free image... S n The original set of multi-scale feature maps is obtained as follows: ; in, ,1≤ ≤k, representing the kth The original feature map output by each resolution branch. - This represents the feature maps output by the first to kth resolution branches; This represents the set of feature maps at the current resolution. , , These represent the height, width, and number of channels of the feature map at this resolution.

[0032] Subsequently, each feature map is sequentially enhanced by a channel attention module and a spatial attention module, with the first feature map being weighted and enhanced. Original feature map at each resolution The channel statistics vector Z is obtained through global average pooling, and then the channel attention weights are obtained through mapping by a fully connected layer. ; in, α Channel attention weights; , For the weights of the fully connected layer, , This is the bias value. It is the ReLU activation function. This is the Sigmoid function.

[0033] Channel-weighted feature map , where “·” indicates multiplication by channel.

[0034] Channel-weighted feature map Through global max pooling (GMP) ) and Global Average Pooling GAP ( The spatial statistical map is obtained, and after being stitched together, it is mapped through a convolutional layer to obtain the spatial attention weights. β for: Where: Conv represents convolution.

[0035] The final enhanced feature map is as follows: Where “·” indicates multiplication by channel, 1≤ ≤k.

[0036] Then the enhanced multi-scale feature map set for: ; Generate Patch feature vectors; Feature maps under each branch in the enhanced multi-scale feature map set Local patches are extracted using a sliding window approach. Since the feature map resolutions of different branches of the HRNet network are different, their corresponding receptive fields in the original image are also different. Therefore, a uniform size patch is set for all branches. p × p Let the step size be... s For the first Each branch yields a set of Patch features. for: ; in, For local feature vectors, This is the floor function; Indicates the first The height pixel value of the image; Indicates the first The width of the image in pixels; Indicates the number of channels; s Indicates the step size; p × p Indicates pixel height as p Pixel width is p The size of the block.

[0037] All training images and the patch feature vector sets of all branches are merged to form an initial global memory pool. P all .

[0038] A priori-guided weighted K-medoids clustering memory is constructed. Based on the generated structural importance weight map, for each patch feature, its weight is obtained through spatial location mapping. Weighted Euclidean distance is used as the feature similarity measure. The initial global memory pool is clustered using the K-medoids clustering algorithm, and the centroid of each cluster is used as the representative feature and stored in the memory. The specific steps are as follows: The optimal number of clusters is selected from candidate K values ​​using the silhouette coefficient or elbow rule to ensure that clusters are compact within each cluster and separated between each cluster. Weighted Euclidean distance d w As a similarity metric, the PAM algorithm is used to analyze the global memory pool. P all Divide the data into K clusters, i.e., find K centroids such that the total deviation TD of all objects from the centroid of their respective clusters is minimized: ; in, C i Indicates the first i Clusters, 1≤ i ≤ K ; m i Cluster C i The center point; Indicates the first i Sample To the center of its cluster The weighted Euclidean distance; Indicates the first i Object points in a cluster.

[0039] The center points of all clusters are stored as core features in memory M. To further preserve subtle texture variations in high-risk areas, samples that are far from their center points within high-risk areas are additionally sampled and added to memory as well.

[0040] Add a memory index; The constructed memory M is organized using a hybrid index structure of quantization and inverted index to accelerate retrieval efficiency, resulting in the trained PatchCore model, which is the indexed memory M and its associated feature extractor. and the predefined weighted Euclidean distance d w .

[0041] Surface defect detection of aircraft power distribution equipment with area perception; First, image preprocessing is performed on the test image after multi-exposure fusion. I F Scale normalization and pixel normalization are performed according to the uniform specifications of standard sample images to ensure that the two are completely consistent in terms of image size and pixel value distribution range, providing standardized input for subsequent feature extraction and model detection.

[0042] Feature extraction; Feature extractor based on HRNet network trained Extract multi-scale feature maps from the test images, and then generate the patch feature set P of the test images according to the consistent patch generation rules during the model training phase. test ; Calculate multi-scale anomaly maps; For feature set P test Each feature vector in Search for its k nearest neighbor feature vectors in the trained memory, and calculate the sum of the weighted Euclidean distances between it and its nearest neighbor feature vectors as the anomaly score of the local region: = ; in Indicates abnormal scores; Eigenvectors in the structural importance weight graph Position weight; m Indicates the center point; It represents the sum of the weighted Euclidean distances between an eigenvector and its nearest neighbor eigenvector.

[0043] In the feature space of each branch, based on the extraction position of the patch, the anomaly score is placed at the corresponding coordinates (i, j) of a two-dimensional grid, forming a sparse anomaly score matrix. Subsequently, the sparse matrix is ​​upsampled to the same size as the highest resolution branch using a bilinear interpolation algorithm to generate the initial anomaly feature map. .

[0044] Generate abnormal heatmaps; Pixel-level weighted fusion is performed on K anomaly feature maps of the same size, as shown in the following formula: ; in: For the first Weight coefficients of each abnormal feature map; This is the initial anomaly feature map; This indicates the weighted fusion result.

[0045] The fused anomaly feature map is further upsampled back to size H×W to obtain a high-resolution anomaly heatmap. A final .

[0046] Regional anomaly identification and location; Based on the set anomaly detection thresholds for each structural functional area, the anomaly heatmap is divided into regions for judgment. A final In the above, the maximum value is extracted from different regions as the anomaly score for that region, resulting in: S area =max area ( A final ); S area This represents the anomaly score for the current image region; max area ( A final ) indicates an abnormal heat map A final The maximum value extracted from it.

[0047] If the outlier score S in a certain region area If the threshold value for that area is exceeded, the corresponding area of ​​the device is determined to have a defect, and the highlighted area on the heat map indicates the location of the defect; otherwise, the area is determined to be defect-free.

[0048] SAM model defect segmentation utilizes the SAM model to generate segmentation prompts based on anomaly heatmaps, performs defect segmentation, quantifies the physical size of defects, determines the morphological characteristics of defects, and assesses the severity of defects.

[0049] Based on the anomaly heatmap, the center coordinates and minimum bounding rectangle of the defect candidate region are calculated as segmentation cues for the SAM model. The formula for calculating the center coordinates of the image region containing the defect is: ; in, P core Ω represents the center coordinates of the image region with defects; Ω represents the set of pixels in the abnormal heatmap whose region anomaly score is greater than or equal to the defect determination threshold. s ( x , y ) indicates that the coordinates in the abnormal heat map are ( x , y The region anomaly score of the pixel at () x Represents pixels in an abnormal heatmap x Coordinate values; y Represents pixels in an abnormal heatmap y Coordinate values; The formula for calculating the minimum bounding rectangle of the defective image region is: ; Wherein, Ω represents the set of pixels in the abnormal heatmap whose region anomaly score is greater than or equal to the defect judgment threshold; x Represents pixels in an abnormal heatmap x Coordinate values; y Represents pixels in an abnormal heatmap y Coordinate values; x min , y min () represents the pixel coordinates of the top-left corner of the smallest bounding rectangle; x max , y max () represents the pixel coordinates of the bottom right corner of the smallest bounding rectangle.

[0050] The original test image and the generated prompts are input into the SAM model to obtain the accurate segmentation mask for each candidate region. Based on the segmentation mask, the geometric features of the defect, such as area, perimeter, and aspect ratio, are calculated. The physical size of the defect is quantified through the geometric features, the morphological characteristics of the defect are determined, and the severity of the defect is assessed.

[0051] Example 2: This embodiment discloses a method for detecting surface defects in aircraft electrical equipment based on a standard sample library. It is an improvement upon Embodiment 1. The specific calculation process for image fusion in step 1 is as follows: First, calculate the contrast weight. w c ( x ,y ): ; in, I i,k ( x , y )=1 / 3·[ R i,k ( x , y )+ G i,k ( x , y )+ B i,k ( x , y )], I i,k ( x , y ) represents a pixel ( x , y The intensity value at () For the Laplace operator; R i,k ( x , y ), G i,k ( x , y ), B i,k ( x , y )) respectively represent the RGB three channels at the pixel point ( x , y The intensity value at () Calculate saturation weight w s ( x , y ): ; Calculate the concentration value weight w e ( x , y ): ; in, These are the parameters of the Gaussian function.

[0052] The weights of each pixel are combined, and the calculation formula is as follows: ; The weight of each pixel is normalized, and the calculation formula is as follows: ; Where, λ c , λ s , λ e These represent adjustable weighting coefficients for contrast, saturation, and exposure, respectively controlling detail clarity, color fidelity, and exposure balance.

[0053] The algorithm for weighted fusion of image sequences pixel by pixel, and for fusing the test image, is as follows: ; in, I F ( x , y ) represents the pixel coordinates of the test image at a certain angle and shutter speed. x , y The weighted fusion strength value at () This represents the pixel coordinates of the test image at a certain angle and the k-th shutter speed. x , y The normalized weight value at () I k ( x , y ) indicates a certain angle relative to the first k Test image pixel coordinates at each shutter speed ( x , y The intensity value at () The algorithm for fusing standard sample images is as follows: ; in, This represents the pixel coordinates of the standard sample image at the i-th angle and the k-th shutter speed. x , y The weighted fusion strength value at () This represents the pixel coordinates of the standard sample image at the i-th angle and the k-th shutter speed. x , y The normalized weight value at () This represents the pixel coordinates of the standard sample image at the i-th angle and the k-th shutter speed. x , y The intensity value at ().

[0054] The rest of this embodiment is the same as that of Embodiment 1, so it will not be described again.

[0055] Example 3: This embodiment discloses a method for detecting surface defects in aircraft electrical equipment based on a standard sample library. It optimizes upon embodiment 1 or 2. In step 1, the sharpness of the fused standard sample image is calculated using the Sobel gradient model. If the sharpness of the fused standard sample image is acceptable, the distortion of the fused standard sample image is calculated. If the distortion of the fused standard sample image is acceptable, the illumination uniformity of the fused standard sample image is calculated. The fused standard sample image that meets the requirements for sharpness, distortion, and illumination uniformity is retained. Specifically: Clarity is calculated using the following formula: ; in, H , W These are the height and width of the preprocessed image, respectively. G x ( x , y ), G y ( x , y ) represent the Sobel gradient model in x direction and y The gradient component in the direction.

[0056] like Clarity ≥T c T c If the image meets the sharpness threshold, it is considered sharp enough to ensure that normal texture details are clear and the image is retained; otherwise, the image is removed from the dataset. Distortion MSE The calculation formula is as follows: ; in, H , W These are the height and width of the preprocessed image, respectively. S fuse ( i , j () is a fused image; S pre ( i , j () is the preprocessed sample image; x , y () represents pixel coordinates.

[0057] If T low ≤ MSE ≤T high If the noise reduction algorithm effectively suppresses the noise without distorting the image, the sample image is retained; otherwise, it is discarded. Illumination uniformity LightThe calculation formula is as follows: ; in, μ This represents the global grayscale mean of the preprocessed sample image; S pre ( x , y () represents the preprocessed sample image; H , W These are the height and width of the preprocessed image, respectively; x , y () represents pixel coordinates.

[0058] like If the image illumination uniformity is satisfactory and the brightness distribution is uniform, the sample will be retained; otherwise, it will be discarded.

[0059] The rest of this embodiment is the same as that of embodiment 1 or 2, so it will not be described again.

[0060] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention in any way. Any simple modifications or equivalent changes made to the above embodiments based on the technical essence of the present invention shall fall within the protection scope of the present invention.

Claims

1. A method for detecting surface defects in aircraft electrical equipment based on a standard sample library, characterized in that, Includes the following steps: Step 1: Acquire standard sample images and test images at different angles and shooting shutter speeds, fuse the standard sample images according to a predetermined sequence, and fuse the test images according to a predetermined sequence. Step 2: Establish a structural region partitioning model using template matching algorithm; perform risk partitioning on the aircraft power distribution equipment drawings using the partitioning model; assign different risk weights to different risk partitions; and set defect judgment thresholds for different risk partitions. Step 3: Introduce the CBAM attention extraction mechanism into the Bottleneck of the PatchCore model, and replace the ResNet network in the PatchCore model with the HRNet network to obtain the improved PatchCore model. Based on the structural importance weight map, set differentiated sampling priorities for the Patch features in the improved PatchCore model according to the regional weights corresponding to their spatial locations. Step 4: Train the improved PatchCore model using the defect-free images obtained from the fusion in Step 1. Construct a memory containing feature vectors in the improved PatchCore model, and perform a hybrid indexing of quantization and inverted indexing on the memory to obtain the trained PatchCore model. Step 5: Use the trained PatchCore model to extract feature vectors from the test image, calculate the feature anomaly score between the current feature vector and its neighboring vectors based on the memory bank, calculate the anomaly heatmap of the current image region based on the feature anomaly score, extract the maximum value in the anomaly heatmap as the region anomaly score of the current image region, and determine whether there is a defect in the current image region based on the region anomaly score. Step 6: Based on the anomaly heatmap, calculate the center coordinates and minimum bounding rectangle of the image region with defects as segmentation hints. Input the test image and segmentation hints into the SAM model to obtain the segmentation mask of the current image region. Calculate the geometric features of the defects in the current image region based on the segmentation mask.

2. The method for detecting surface defects in aircraft electrical equipment based on a standard sample library according to claim 1, characterized in that, Step 4 specifically includes: Step 4.1: Input the defect-free image into the feature extractor of the HRNet network, and extract the feature maps of different resolution branches output by the last stage of the HRNet network through the feature extractor. Step 4.2: Perform feature weighting enhancement on each feature map using the CBAM attention extraction mechanism to obtain the enhanced feature map; Step 4.3: Use a sliding window to extract local patches from the feature map to obtain the patch feature set. Merge all training images with the patch feature set to obtain the initial global memory pool. Step 4.4: Based on the structural importance weight map, perform spatial location mapping for each Patch feature in the Patch feature set, use the weighted Euclidean distance of the Patch features as the feature similarity measure, use the K-medoids clustering algorithm to cluster the initial global memory pool, and store the center point of each cluster as a representative feature in the memory bank. Step 4.5: Apply a hybrid index of quantization and inverted index to the memory. The hybrid index includes the memory and the feature extractor and feature similarity measure associated with the memory. The trained PatchCore model is obtained based on the memory.

3. The method for detecting surface defects in aircraft electrical equipment based on a standard sample library according to claim 2, characterized in that, In step 4.4, the weighted Euclidean distance of the Patch feature is used as the feature similarity measure. The initial global memory pool is divided into K clusters, and the center point of each cluster satisfies the condition that the total deviation of all objects in the Patch feature from the center point of its respective cluster is minimized.

4. The method for detecting surface defects in aircraft electrical equipment based on a standard sample library according to any one of claims 1-3, characterized in that, Step 5 specifically includes: Step 5.1: Perform consistency processing on the fused test image according to the standard sample image to make the test image consistent with the standard sample image in terms of size and pixel value distribution range; Step 5.2: Use the feature extractor of the HRNet network in the trained PatchCore model to extract multi-scale feature maps of the test image, and generate the Patch feature set of the test image based on the multi-scale feature maps according to the consistent Patch generation rules in the model training stage. Step 5.3: For each feature vector in the Patch feature set, retrieve the k nearest neighbor vectors in the memory and calculate the weighted Euclidean distance between the feature vector and its neighbor vectors as the feature anomaly score of the current image region. Step 5.4: Based on the extraction location of the patch, place the feature anomaly scores on the corresponding coordinates of a two-dimensional grid to form a sparse anomaly score matrix. Use the bilinear interpolation algorithm to upsample the sparse anomaly score matrix to obtain the initial anomaly feature map. Step 5.5: Perform weighted fusion on the initial anomaly feature maps of the same size to obtain a fused anomaly feature map, and upsample the fused anomaly feature map to obtain an anomaly heatmap; Step 5.6: Extract the maximum value from the abnormal heatmap as the regional abnormality score of the current image region, and use the defect judgment threshold to divide the abnormal heatmap into regions for judgment; if the regional abnormality score is greater than or equal to the defect judgment threshold, the current region is judged as a defect candidate region; if the regional abnormality score is less than the defect judgment threshold, the current region is judged as a defect-free region.

5. The method for detecting surface defects in aircraft electrical equipment based on a standard sample library according to any one of claims 1-3, characterized in that, In step 6, the formula for calculating the center coordinates of the defective image region is: ; in: P core Ω represents the center coordinates of the image region with defects; Ω represents the set of pixels in the abnormal heatmap whose region anomaly score is greater than or equal to the defect determination threshold. s ( x , y ) indicates that the coordinates in the abnormal heat map are ( x , y The region anomaly score of the pixel at () x Represents pixels in an abnormal heatmap x Coordinate values; y Represents pixels in an abnormal heatmap y Coordinate values.

6. The method for detecting surface defects in aircraft electrical equipment based on a standard sample library according to claim 5, characterized in that, In step 6, the formula for calculating the minimum bounding rectangle of the defective image region is: ; Where: Ω represents the set of pixels in the abnormal heatmap whose regional anomaly score is greater than or equal to the defect judgment threshold; x Represents pixels in an abnormal heatmap x Coordinate values; y Represents pixels in an abnormal heatmap y Coordinate values; x min , y min () represents the pixel coordinates of the top-left corner of the smallest bounding rectangle; x max , y max () represents the pixel coordinates of the bottom right corner of the smallest bounding rectangle.

7. The method for detecting surface defects in aircraft electrical equipment based on a standard sample library according to any one of claims 1-3, characterized in that, In step 1, the algorithm for fusing the test images is as follows: ; in: I F ( x , y ) represents the pixel coordinates of the test image at a certain angle and shutter speed. x , y The weighted fusion strength value at () This represents the pixel coordinates of the test image at a certain angle and the k-th shutter speed. x , y The normalized weight value at () I k ( x , y ) represents the pixel coordinates of the test image at a certain angle and the k-th shutter speed. x , y The intensity value at ().

8. The method for detecting surface defects in aircraft electrical equipment based on a standard sample library according to claim 7, characterized in that, In step 1, the algorithm for fusing the standard sample images is as follows: ; in: This represents the pixel coordinates of the standard sample image at the i-th angle and the k-th shutter speed. x , y The weighted fusion strength value at () This represents the pixel coordinates of the standard sample image at the i-th angle and the k-th shutter speed. x , y The normalized weight value at () This represents the pixel coordinates of the standard sample image at the i-th angle and the k-th shutter speed. x , y The intensity value at ().

9. The method for detecting surface defects in aircraft electrical equipment based on a standard sample library according to claim 8, characterized in that, In step 1, the sharpness of the fused standard sample image is calculated using the Sobel gradient model. If the sharpness of the fused standard sample image is qualified, the distortion of the fused standard sample image is calculated. If the distortion of the fused standard sample image is qualified, the illumination uniformity of the fused standard sample image is calculated. The fused standard sample image that is qualified in terms of sharpness, distortion, and illumination uniformity is retained.

Citation Information

Patent Citations

  • Memory matching industrial defect detection method based on adaptive feature fusion

    CN120339195A

  • Fastener defect automatic identification method based on deep learning

    CN121481990A