Defect image processing method and device and computer equipment

By using background information to fill the interfering defect area in defect image processing, the misclassification, missed detection or out-of-checking problems caused by the classification model due to interfering defects are solved, and the accuracy and stability of defect detection are significantly improved.

CN120219562APending Publication Date: 2025-06-27苏州凌云光工业智能技术有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510161326.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-13
Publication Date
2025-06-27

AI Technical Summary

Technical Problem

In the case of defect aggregation, the prior art classification model may cause misclassification, missed inspection or over-checking due to the influence of surrounding interference defects, resulting in a significant reduction in production accuracy and efficiency.

Method used

By acquiring the initial defect image, the target defect and the interference defect are determined, and the target external pixel matching the internal pixel in the interference defect is determined, and the target external pixel is filled to eliminate the influence of the interference defect, and an image containing only the target defect is obtained.

Benefits of technology

It effectively eliminates the impact of interference defects on target defect detection and classification, improves the accuracy and stability of the classification model, and is suitable for situations of complex backgrounds and large-size interference defects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120219562A_ABST
    Figure CN120219562A_ABST
Patent Text Reader

Abstract

The invention discloses a defect image processing method and device and computer equipment, and belongs to the field of image processing. The method comprises the following steps: acquiring an initial defect image, and determining a target defect and an interference defect in the initial defect image; determining a target external pixel matched with the internal pixel of the interference defect in the external pixel of the interference defect, and filling the matched internal pixel with the target external pixel; all internal pixels of the interference defect are traversed until all internal pixels are filled, and a target defect image is obtained; interference defects of the target defect image are eliminated, so that the target defect image is used for processing the target defect. According to the method, the interference defect image region in the image is filled to generate the defect image only containing the target defect, and the accuracy of subsequent defect classification or other detection tasks is improved by suppressing the influence of the interference defect on the classification model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of image processing, and particularly relates to a method, apparatus, and computer device for defect image processing. Background Art

[0002] With the rapid development of image processing technology, defect detection has become a key link in ensuring product quality in industrial production. In related technologies, through the combination of a defect segmentation model and a classification model, the detection and classification of defects can be achieved. However, when defects are aggregated, the classification model may be affected by surrounding interfering defects and suffer from problems such as misclassification, missed detection, or over-detection. This phenomenon will have a significant impact on production accuracy and efficiency. Summary of the Invention

[0003] This application aims to solve at least one of the technical problems existing in the related technologies. For this purpose, this application provides a method, apparatus, and computer device for defect image processing to improve the accuracy of defect image processing.

[0004] In a first aspect, this application provides a method for defect image processing, the method including:

[0005] Obtain an initial defect image, and determine target defects and interfering defects in the initial defect image;

[0006] Among the external pixels of the interfering defects, determine target external pixels that match the internal pixels of the interfering defects, and fill the matching internal pixels with the target external pixels;

[0007] Traverse all the internal pixels of the interfering defects until all the internal pixels are filled, to obtain a target defect image; the target defect image excludes the interfering defects and is used to process the target defects.

[0008] In the above technical solution, after obtaining the initial defect image, by determining the target defects and interference defects in the initial defect image, and in the external pixels of the interference defects, determining the target external pixels that match the internal pixels of the interference defects, and filling the matching internal pixels with the target external pixels to fill the interference defect area with background information, the influence of the interference defects on the detection and classification of the target defects is effectively eliminated; traversing all the internal pixels of the interference defects until all the internal pixels are filled to obtain the target defect image, and the target defect image excludes the interference defects for processing the target defects. Thus, by only retaining the target defects, it helps the classification model to focus on the target defects, improving the accuracy and stability of the classification. This method uses background information for filling, can adapt to industrial detection environments with complex backgrounds, expands the scope of technical applications, does not rely on specific segmentation or classification models, can be combined with existing detection systems, and has high versatility and practical value.

[0009] According to an embodiment of the present application, determining the target external pixels that match the internal pixels of the interference defects in the external pixels of the interference defects and filling the matching internal pixels with the target external pixels includes:

[0010] For any internal pixel of the interference defect, in the external pixels of the interference defect, determining the nearest background pixel that is closest to the targeted internal pixel;

[0011] Based on the nearest background pixel, searching for candidate external pixels that match the targeted interference pixel;

[0012] When the candidate external pixels meet the preset conditions, taking the candidate external pixels as the target external pixels that match the targeted internal pixel.

[0013] In the above embodiment, by adopting the filling strategy based on the nearest background pixel, it can adapt to the situations of complex backgrounds and large-sized interference defects, and the filled image has a natural transition without introducing new noise. Thus, by constructing an image that only contains the target defects, the interference of the interference defects to the classification model is eliminated, thereby significantly improving the accuracy of the classification model.

[0014] In a second aspect, the present application provides a defect image processing device, and the device includes:

[0015] An acquisition module, configured to acquire an initial defect image and determine the target defects and interference defects in the initial defect image;

[0016] A processing module, configured to determine the target external pixels that match the internal pixels of the interference defects in the external pixels of the interference defects and fill the matching internal pixels with the target external pixels;

[0017] The processing module is further configured to traverse all internal pixels of the interference defect until all internal pixels are filled, so as to obtain a target defect image; the target defect image excludes the interference defect and is used to process the target defect.

[0018] In the above technical solution, after obtaining the initial defect image, by determining the target defect and the interference defect in the initial defect image, and determining, among the external pixels of the interference defect, the target external pixels that match the internal pixels of the interference defect, and filling the matching internal pixels with the target external pixels to fill the interference defect area with background information, the influence of the interference defect on the detection and classification of the target defect is effectively eliminated; traversing all internal pixels of the interference defect until all internal pixels are filled to obtain a target defect image, the target defect image excludes the interference defect and is used to process the target defect. Thus, by only retaining the target defect, it helps the classification model to focus on the target defect, improving the accuracy and stability of classification. This method uses background information for filling, can adapt to industrial detection environments with complex backgrounds, expands the scope of technical applications, does not rely on specific segmentation or classification models, and can be combined with existing detection systems, having high generality and practical value.

[0019] In a third aspect, the present application provides a computer device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, the defect image processing method as described in the first aspect above is implemented.

[0020] In a fourth aspect, the present application provides a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the defect image processing method as described in the first aspect above is implemented.

[0021] In a fifth aspect, the present application provides a chip, which includes a processor and a communication interface. The communication interface is coupled to the processor, and the processor is configured to run programs or instructions to implement the defect image processing method as described in the first aspect above.

[0022] In a sixth aspect, the present application provides a computer program product, including a computer program. When the computer program is executed by a processor, the defect image processing method as described in the first aspect above is implemented.

[0023] Additional aspects and advantages of the present application will be given in part in the following description, become apparent in part from the following description, or be learned through the practice of the present application. Description of the Drawings

[0024] The above and / or additional aspects and advantages of the present application will become apparent and be readily understood from the following description of embodiments in conjunction with the accompanying drawings, where:

[0025] Figure 1 is a schematic diagram of the process steps of a defective image processing method provided in some embodiments of the present application;

[0026] Figure 2 is a schematic diagram of the process of a defective image processing method provided in some embodiments of the present application;

[0027] Figure 3 is a schematic diagram of the images of a target defect and an interference defect provided in some embodiments of the present application;

[0028] Figure 4 is a schematic diagram of the process of determining target external pixels provided in some embodiments of the present application;

[0029] Figure 5 is a schematic diagram of the principle of determining target external pixels provided in some embodiments of the present application;

[0030] Figure 6 is a schematic diagram of the process of a defective image processing method provided in some other embodiments of the present application;

[0031] Figure 7A is a schematic diagram of the original image provided in some embodiments of the present application;

[0032] Figure 7B is a schematic diagram of the mask image provided in some embodiments of the present application;

[0033] Figure 7C is a schematic diagram of the effect of determining the nearest background pixel provided in some embodiments of the present application;

[0034] Figure 7D is a schematic diagram of the principle of determining target external pixels provided in some embodiments of the present application;

[0035] Figure 7E is a schematic diagram of the effect after filling the interference defect provided in some embodiments of the present application;

[0036] Figure 8 is a schematic diagram of the structure of a defective image processing device provided in some embodiments of the present application;

[0037] Figure 9 is a schematic diagram of the structure of a computer device provided in some embodiments of the present application. Detailed implementation manners

[0038] Next, the technical solutions in the embodiments of the present application will be clearly described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art belong to the scope of protection of the present application.

[0039] Unless otherwise defined, all technical and scientific terms used in the present application have the same meaning as commonly understood by those of ordinary skill in the technical field to which the present application belongs; the terms used in the specification of the present application are only for the purpose of describing specific embodiments, and are not intended to limit the present application; the terms "including" and "having" and any variations thereof in the specification and claims of the present application and the above drawings are intended to cover non-exclusive inclusion. The terms "first", "second", etc. in the specification and claims of the present application or the above drawings are used to distinguish different objects, rather than to describe a specific order or primary-secondary relationship.

[0040] Referring to "embodiments" in the present application means that specific features, structures or characteristics described in connection with the embodiments can be included in at least one embodiment of the present application. The phrase appears in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. Those skilled in the art will explicitly and implicitly understand that the embodiments described in the present application can be combined with other embodiments.

[0041] In the description of the present application, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "connected", "connected", "attached" should be understood in a broad sense. For example, it can be a fixed connection, a detachable connection, or an integral connection; it can be directly connected, or indirectly connected through an intermediate medium, and it can be the communication inside two elements. For those of ordinary skill in the art, the specific meanings of the above terms in the present application can be understood according to specific situations.

[0042] The term "and / or" in the present application is only a description of the association relationship of associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist simultaneously, and B exists alone. In addition, the character " / " in the present application generally represents an "or" relationship between the front and rear associated objects.

[0043] The term "plurality" as used in the present application refers to two or more (including two). Similarly, "multiple groups" refers to two or more groups (including two groups), and "multiple pieces" refers to two or more pieces (including two pieces).

[0044] With the continuous development of artificial intelligence, the use of artificial intelligence for defect detection has been increasingly widely applied in the field of industrial quality inspection. Through the training of defect recognition models, production defects can be classified and graded in real time during the actual production inspection process, thus ensuring production quality.

[0045] Defect recognition models in the field of industrial quality inspection can be roughly classified into two categories: defect segmentation models and defect classification models. Defect segmentation models can strip real-time production defects from the inspection object to obtain information such as defect location and size. Defect classification models can obtain the specific classification of defects according to the defect morphology and the difference from the background based on the trained defect labels. Currently, the application of defect models in the field of industrial quality inspection often adopts a combination of classification and segmentation models. After using the segmentation model to obtain defect location and size information, the single segmentation result is sent into the classification model to supplement the type information of the defect. This detection method can separate multiple defect segmentation results for classification, thus avoiding the classification interference of other defects on the current defect to the greatest extent and reducing misjudgment.

[0046] However, when defect aggregation occurs, this method will fail, including four situations: misclassification, over-detection, missed detection, and classification error. Among them:

[0047] (1) Misclassification: When inputting the current defect into the classification model, it will inevitably lead to the introduction of other defects, resulting in the attention shift of the classification model, and then misclassification occurs;

[0048] (2) Over-detection: In the current situation of detecting minor defects, when there are serious defects around the minor defect, it may cause the classification model to detect the serious defect instead of the minor defect, and then over-detection occurs;

[0049] (3) Missed detection: In the current situation of detecting serious defects, when there are minor defects around the serious defect, it may cause the classification model to detect the minor defect instead of the serious defect, and then missed detection occurs;

[0050] (4) Classification error: When classifying the current defect, if there are other defects with similar features around the current defect, it may cause the classification model to detect other defects instead of the current defect, resulting in a classification error for the current defect.

[0051] Therefore, for aggregated defects, the problem of attention shift in the classification model existing in the traditional method may lead to serious production accidents, and it has increasingly become an issue that cannot be ignored in the detection field.

[0052] In view of this, the embodiments of the present application provide a method, apparatus, and computer device for defect image processing. By extracting background information and filling the interference defect areas, an image containing only the current defect is constructed, thereby suppressing the influence of interference defects on the classification model, enabling the classification model to more accurately classify the current defect in the image, or improving the accuracy of subsequent other detection tasks. This method is based on an attention shift suppression algorithm for background filling and adopts a robust background filling design. Compared with the traditional OpenCV algorithm, it can better adapt to complex scenes and large-size interference defects, ensure natural background transition while focusing on the detection object, and solve the problem of inaccurate classification caused by aggregated defects in industrial quality inspection. Compared with the traditional method, this method can automatically identify interference defects and their surrounding background information, fill the interference defect areas with the background information in a natural transition manner, with a more natural edge transition, effectively excluding interference defects without introducing new interference defects, and ensuring that subsequent detections focus on the target defect, thus significantly improving the accuracy and reliability of the detection results.

[0053] The following will combine the accompanying drawings and elaborate in detail on the defect image processing method and the like provided by the embodiments of the present application through specific embodiments and their application scenarios.

[0054] The defect image processing method provided by the embodiments of the present application can be applied to the process links as Figure 1 shown. Among them, the defect detection model or defect segmentation model outputs an image for defect classification, and this image needs to be input into the defect classification model for processing to identify the defect category to which the defect contained in the image belongs. Taking the metal processing field as an example, the defect categories can be, for example, scratches, cracks, pits, oxidation spots, burrs, or corrosion, etc.; or, taking the semiconductor electronics manufacturing field as an example, the defect categories can be, for example, short circuits, short circuits, particle attachments, or solder joint defects, etc. Of course, it is not limited to this. Different defect categories can be determined according to the industrial field to which the method applies. For example, it can also be textile detection, glass manufacturing, plastic and composite material fields, etc.

[0055] The defect image processing method provided by the embodiments of the present application is applied before the image is input into the defect classification model for processing. The computer device processes the image input into the defect classification model, identifies the target defect and interference defect in the image, and fills and smooths the interference defect with the background information, so that the image only contains the target defect to be recognized subsequently, thereby suppressing the influence of the interference defect on the classification model, and further improving the accuracy of the classification model for classifying the target defect or subsequent other detection tasks.

[0056] The defect image processing method provided by the embodiments of this application is applicable to industrial quality inspection environments with multiple defect aggregations, such as metal surface scratch detection, etc., and is also applicable to image detection with complex backgrounds, such as detecting the surface of products with textures or patterns; and is applicable to tasks that require high-precision defect classification, with a wide range of application scenarios.

[0057] The defect image processing method provided by the embodiments of this application can be applied to computer devices, and can be specifically executed by hardware or software in the computer device.

[0058] Exemplarily, the computer device includes, but is not limited to, one or more of various desktop computers, laptop computers, smartphones, tablet computers, in-vehicle terminals, Internet of Things devices, or portable wearable devices, etc. The Internet of Things devices can be one or more of smart speakers, smart TVs, smart air conditioners, or in-vehicle smart devices, etc. The portable wearable devices can be one or more of smart watches, smart bracelets, or head-mounted devices, etc. The server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, and big data and artificial intelligence platforms.

[0059] The defect image processing method provided by the embodiments of this application, the execution subject of this defect image processing method can be a computer device or a functional module or functional entity in the computer device that can implement this defect image processing method. Hereinafter, taking the computer device as the execution subject as an example, the defect image processing method provided by the embodiments of this application will be described.

[0060] As Figure 2 shown, this defect image processing method includes: Step 210 to Step 230.

[0061] Step 210, obtain an initial defect image, and determine the target defects and interference defects in the initial defect image.

[0062] Among them, the initial defect image refers to an image containing defects. This initial defect image is output through a defect detection model or a defect segmentation model. The initial defect image can be collected by an industrial camera or other imaging devices, or generated through image processing techniques (such as segmentation algorithms).

[0063] The initial defect image includes information on target defects, interference defects, and background regions. Among them, the target defect refers to the defect to be detected and classified in the initial defect image. Exemplarily, as Figure 3As shown, the initial defect image includes a target defect A and one or more interfering defects B. The target defect is the focus of the current processing, and its location and characteristics can be determined by algorithms or manual annotation in the initial defect image. Interfering defects refer to other defects in the initial defect image except the target defect, and these defects will interfere with the detection, classification or grading of the target defect. Interfering defects can be identified by differences in their locations and characteristics from the target defect.

[0064] Step 220: Among the external pixels of the interfering defect, determine the target external pixels that match the internal pixels of the interfering defect, and fill the matching internal pixels with the target external pixels.

[0065] The external pixels of the interfering defect are the pixel points outside the interfering defect area, and these pixel points are outside the boundary of the interfering defect. The external pixels of the interfering defect can be used to fill the internal pixels of the interfering defect. The internal pixels of the interfering defect refer to the pixel points inside the interfering defect area, and these pixel points contain the main information of the interfering defect. In the embodiments of the present application, the internal pixels of the interfering defect need to be filled with external pixels to eliminate the interference of this interfering defect.

[0066] Among the external pixels, not all pixels can be used to fill the internal pixels of the interfering defect. For example, the pixels at the image boundary, or the pixels of the target defect, etc. If these pixels are used to fill the internal pixels, new interference may be introduced. Therefore, the computer device needs to find and determine the external pixels that match its internal pixels among the external pixels of the interfering defect, which are called target external pixels, and fill the corresponding internal pixels with the target external pixels.

[0067] Among them, the target external pixels that match the internal pixels of the interfering defect refer to the background pixel points selected from the external pixels of the interfering defect. Under specific calculation rules, this background pixel point has a matching relationship with the internal pixels of the interfering defect and is used to fill the internal pixels.

[0068] Filling refers to the process of selecting target external pixels and assigning their pixel values to the internal pixels of the interfering defect. The purpose of filling is to replace the interfering defect area with background information, so as to generate an image with the interfering defect removed, making the detection or classification of the target defect more accurate. The filling process can be iterated to ensure the complete repair of the interfering defect.

[0069] Step 230: Traverse all the internal pixels of the interfering defect until all the internal pixels are filled, and obtain the target defect image; the target defect image excludes the interfering defect and is used to process the target defect.

[0070] In the external pixels of the interference defect of the computer device, the target external pixels matching the internal pixels of the interference defect are determined in sequence to traverse all internal pixels. When all the internal pixels of the interference defect are filled, the interference defect can "disappear" visually from the image, and the obtained target defect image only contains the target defect. Subsequently, when classifying or performing other detection tasks on the target defect, the attention of the model will not shift. In other words, each time the classification model only needs to focus on the target defect, and the model processing process will not be interfered by the interference defect, improving the accuracy of defect detection, positioning, and classification.

[0071] The defect image processing method provided by the embodiments of the present application, after obtaining the initial defect image, determines the target defect and the interference defect in the initial defect image, and in the external pixels of the interference defect, determines the target external pixels matching the internal pixels of the interference defect, and fills the matching internal pixels with the target external pixels, filling the interference defect area with background information, effectively eliminating the influence of the interference defect on the detection and classification of the target defect; traverses all the internal pixels of the interference defect until all the internal pixels are filled, obtaining the target defect image, and the target defect image excludes the interference defect for processing the target defect. Thus, by only retaining the target defect, it helps the classification model to focus its attention on the target defect, improving the accuracy and stability of classification. This method uses background information for filling, can adapt to industrial detection environments with complex backgrounds, expands the scope of technical applications, does not rely on specific segmentation or classification models, can be combined with existing detection systems, and has high versatility and practical value.

[0072] In addition to the target defect in the initial defect image, there may be multiple interference defects. The computer device processes the interference defects separately, which can be processed sequentially or in parallel, etc. For each interference defect, the computer device performs the above steps. The following takes one interference defect as an example to illustrate how to determine and fill the target external pixels matching the internal pixels of the interference defect.

[0073] In some embodiments, determining the target external pixels matching the internal pixels of the interference defect in the external pixels of the interference defect and filling the matching internal pixels with the target external pixels includes steps 410 to 430:

[0074] Step 410: For any internal pixel of the interference defect, in the external pixels of the interference defect, determine the nearest background pixel closest to the targeted internal pixel.

[0075] For the current interference defect, the interference defect includes at least one internal pixel. For each internal pixel, the computer device calculates the distance between it and the surrounding external pixels and finds the nearest background pixel as the nearest background pixel.

[0076] Among them, the distance between the internal pixel and the external pixel can be determined by one or more of Euclidean Distance, Manhattan Distance, Chebyshev Distance, Mahalanobis Distance, Hamming Distance, etc.

[0077] Exemplarily, in the embodiments of the present application, the computer device calculates the Euclidean distance between the internal pixel and each external pixel respectively, and the specific process can be characterized as:

[0078]

[0079] Where D is the distance, (x0, y0) is the internal pixel, and (x1, y1) is the external pixel.

[0080] Step 420: Based on the nearest background pixel, search for candidate external pixels that match the targeted interfering pixel.

[0081] Thus, after determining the background pixel closest to the internal pixel, that is, the nearest background pixel, the computer device filters candidate external pixels from the external pixels based on the nearest background pixel, such as pixels with a gray value difference less than a certain threshold.

[0082] Step 430: When the candidate external pixel meets the preset condition, use the candidate external pixel as the target external pixel that matches the targeted internal pixel.

[0083] When the candidate external pixel meets the preset condition, the computer device uses it as the target external pixel and fills the corresponding interfering defective internal pixel with the color value of this pixel, gradually traversing and filling all the interfering defective internal pixels.

[0084] Among them, the preset condition is used to determine whether the candidate external pixel is available. In some embodiments, the candidate external pixel meeting the preset condition includes: the candidate external pixel is the background pixel corresponding to the interfering defect and is not an image boundary pixel.

[0085] Among them, background pixels refer to pixels that do not belong to any defect area, which are the normal parts in the image that are not marked as defects, and are usually represented as areas with obvious contrast to interfering defects, such as different colors, brightness, or texture features, etc. In some embodiments, after the defect segmentation model outputs the defect segmentation result, the defect information and background information are represented by a mask image. The defect information includes at least one of, but is not limited to, the image features of the defect, the defect pixel coordinates, and the defect location, etc. The background information includes, but is not limited to, the background image areas corresponding to each defect respectively, etc.

[0086] Among them, the mask image can be a mask image for all defects, or it can be a mask image corresponding to each defect separately. The generation of the mask image is to highlight the defect and mask other areas. For example, the defect area is represented by white pixel values, and the image area other than the defect area, that is, the background area corresponding to the defect, is represented by black pixel values. This can ensure that the attention of the classification model is completely focused on the current defect without being interfered by other defects.

[0087] Image boundary pixels refer to the pixel points at the edge of the image. These pixels may not be able to provide effective background information due to the lack of surrounding data support.

[0088] Thus, through the limitation of the above preset conditions, it can be ensured that the candidate external pixels have high-quality background information, and at the same time, the overall effect will not be affected by the lack of boundary pixels during the filling process, thereby improving the naturality of the filled image and the accuracy of defect processing.

[0089] In the above embodiments, by adopting the filling strategy based on the nearest background pixel, it can adapt to the situation of complex backgrounds and large-size interfering defects, and the filled image has a natural transition without introducing new noise. Thus, by constructing an image containing only the target defect, the interference of the interfering defect to the classification model is eliminated, thereby significantly improving the accuracy of the classification model.

[0090] In the process of dealing with interfering defects, one of the problems to be solved is how to make the filled image area smooth and natural without introducing new interference information. For this reason, in some embodiments, based on the nearest background pixel, candidate external pixels that match the targeted interfering pixel are searched for, including: determining the extension line of the connection line between the target background pixel and the targeted internal pixel; on the extension line, the external pixel symmetric to the target background pixel is used as the candidate external pixel that matches the targeted interfering pixel.

[0091] In the external pixels of the computer device, starting from the internal pixel, a connection line is formed by connecting the internal pixel and the nearest background pixel. Then, the connection line is extended along the direction of the internal pixel - nearest background pixel to obtain an extended connection line. Next, the computer device selects external pixels that are symmetric to the nearest background pixel on the extended connection line as candidate external pixels that match the targeted interference pixel.

[0092] As Figure 5 shown, taking one of the internal pixels P1 in the interference defect as an example, the computer device first finds the nearest background pixel P2 with the shortest distance to it, and then determines the extended connection line of the internal pixel P1 and the nearest background pixel P2, as Figure 5 shown by the dashed line in. On the extended connection line, the computer device selects the external pixel P3 that is symmetric to the nearest background pixel as the candidate external pixel that matches the targeted interference pixel. That is to say, the external pixel P3 and the internal pixel P1 are mirror-symmetric based on the nearest background pixel P2.

[0093] In the above embodiment, by finding the external pixels that are symmetric to the nearest background pixel on the extended connection line of the internal pixel and its nearest background pixel as the candidate external pixels that match the targeted interference pixel, on the one hand, the geometric symmetry property is used to quickly find the candidate external pixels, with less computational amount, which can greatly improve the computational efficiency; on the other hand, it is applicable to various complex background and interference defect situations, and can make the filled area very smooth and natural, and no new interference defects will be introduced.

[0094] If the candidate external pixel meets the preset conditions, that is, the candidate external pixel is the background pixel corresponding to the interference defect and it is not an image boundary pixel, then the computer device takes the candidate external pixel as the target external pixel that matches the targeted internal pixel, and fills the internal pixel with the target external pixel. For example, the pixel value of the target external pixel is used to replace the pixel value of the internal pixel. Then, the computer device selects the next internal pixel for processing... until all internal pixels have been traversed.

[0095] If the candidate external pixel does not meet the preset conditions, for example, the candidate external pixel is not the background pixel corresponding to the interference defect, or the candidate external pixel is an image boundary pixel. At this time, if the candidate external pixel is directly used to fill the corresponding internal pixel, it may cause uneven or unnatural filling, or may introduce new defects or interference factors. Therefore, in some embodiments, the above method further includes: when the candidate external pixel does not meet the preset conditions, skipping the targeted internal pixel, and taking the next internal pixel as the next targeted internal pixel until all internal pixels in this iteration are traversed; based on all the internal pixels skipped in this iteration, re-determining the interference defect in the initial defect image, and returning to the step of determining the target external pixel that matches the internal pixel of the interference defect among the external pixels of the interference defect to continue execution until all internal pixels are filled to obtain the target defect image.

[0096] That is to say, the filling process can be divided into multiple cyclic iteration processes. Ideally, the computer device only needs to traverse once to fill the interference defect area with background information. However, in some scenarios, for a certain internal pixel, the candidate external pixel determined by the computer device may be other defect pixels or edge pixels, then the computer device skips this internal pixel and takes the next internal pixel as the processing object until all internal pixels in the current interference defect area are traversed. In this way, after the first traversal, at least one internal pixel will be left unfilled, and the other internal pixels in the interference defect will be filled.

[0097] For all the internal pixels that are not filled during the initial filling process, the computer device re-identifies and marks them as a new interference defect area, and at the same time retains the filled internal pixels as the new background information. Then, the computer device based on the re-marked interference defect area, executes the steps from "determining the target external pixel" to "filling the internal pixel" again until all internal pixels are filled. In each iteration process, the latest background information is used to ensure the accuracy of filling. After all internal pixels are filled, a target defect image containing only the target defect is obtained for subsequent classification or other processing.

[0098] In the above embodiments, through the iterative filling strategy, the internal pixels missed in the initial filling can be reprocessed to ensure that all internal pixels of interfering defects are effectively filled, thereby ensuring the integrity of the filling and the quality of the target defect image. For interfering defects with complex shapes or large sizes, the design of relabeling the interfering regions and iteratively filling them significantly improves the robustness of the method and is applicable to various industrial inspection scenarios. Only the target defects are retained in the finally generated target defect image, the background filling has a natural transition, and no new interfering defects are added, providing a cleaner data input for the subsequent classification model and reducing the probability of classification errors. The overall method can complete the global optimization filling process without manual intervention by automatically identifying unfilled pixels and relabeling the interfering defect regions, improving the automation level and processing efficiency of defect detection.

[0099] During the process of filling the interfering defect regions, the computer device needs to perform the filling based on the background information of the current defect. If the same mask information is shared by each defect, then when processing the interfering regions, other undetected defects may affect the filling result. Therefore, in some embodiments, different defects can correspond to different mask images or different regions of the same mask image. Correspondingly, when determining whether a candidate external pixel meets the preset conditions, the computer device not only needs to determine whether it is a background pixel (it cannot be a pixel of other defects), but also needs to determine whether it is a background pixel corresponding to the current interfering defect, which can further improve the smoothness and naturalness of the filling to further improve the accuracy of subsequent defect classification or other detection tasks.

[0100] In some embodiments, the computer device determines whether a candidate external pixel is an external background pixel that matches the internal pixel being targeted. For example, it can calculate in advance the pixel value range (such as the minimum and maximum values of color or grayscale) of the background region of the current defect and check whether the point to be filled falls within this range. If so, it indicates that the candidate external pixel is the external background pixel corresponding to the internal pixel being targeted. Another example is that the computer device can also divide the background region of the current defect based on the spatial characteristics of the background (such as connected component analysis) and determine whether the candidate external pixel and the internal pixel being targeted come from the same background region. If so, the candidate external pixel is an external background pixel that matches the internal pixel being targeted.

[0101] Generally speaking, for complex scenarios with multiple defects, the original image needs to be segmented to extract the defect regions, and further cut into initial defect images that fit the input size of the classification model. This processing method can not only reduce the computational pressure on the classification model, but also improve the model's attention to local defect information, laying a foundation for subsequent defect classification and processing. To this end, in some embodiments, before obtaining the initial defect images, the above method further includes: obtaining the original image output by the defect segmentation model; cutting the original image based on a preset size to obtain multiple initial defect images; the preset size matches the input limit of the defect classification model.

[0102] Specifically, the computer device detects, for example, the surface of an industrial product through the defect segmentation model and outputs the detected image, for example, generating an original image containing defects and the background.

[0103] Furthermore, the computer device cuts the original image into multiple small-sized initial defect images based on the input limit of the classification model. The preset size can be flexibly adjusted according to the input requirements of the classification model. For example, if the input limit of the classification model is 224×224 or 512×512, then the preset size is this size, and the computer device cuts the original image according to 224×224 or 512×512, thereby obtaining multiple initial defect images with relatively smaller sizes. Each initial defect image contains one or more defect regions for subsequent defect detection or classification. The integrity of all defect information is retained during the cutting process, and the spatial distribution characteristics of the background and defects are not damaged.

[0104] In the above embodiments, after the operations of segmenting and cutting the original image, the generated initial defect images can meet the input size limit of the classification model, avoiding the problem of information loss caused by image scaling or cropping. Moreover, the cut images are more focused on the local defect regions, with reduced background interference, providing clearer input data for the classification model, thereby improving the reliability of the classification results.

[0105] In some embodiments, the cutting process can be designed based on the distribution of the defect regions to ensure the complete presentation of the defect information in each initial defect image, avoiding possible omissions during the defect segmentation or classification process.

[0106] In tasks such as defect classification, in order to focus on target defects and reduce the impact of interference factors on the classification model, it is necessary to classify and label the defects in the initial defect image. Based on the defect information, the target defects and interference defects can be determined, providing a basis for subsequent processing. To this end, in some embodiments, determining the target defects and interference defects in the initial defect image includes: for any initial defect image, obtaining the defect information corresponding to the initial defect image; based on the defect information, determining one or more defects in the targeted initial defect image; among the one or more defects, taking the defect located at the middle position of the targeted initial defect image as the target defect, and taking the other defects other than the target defect as interference defects.

[0107] Specifically, for any initial defect image, the computer device uses a segmentation model or other algorithms to obtain the defect information included in the image, including the position, shape, boundary, and background information of the defects, etc. Exemplarily, the background information can be characterized by a mask image, that is, the computer device simultaneously obtains the initial defect image and the mask image corresponding to the initial defect image, or a part of the mask area in the mask image corresponding to the initial defect image.

[0108] Furthermore, based on the defect information, the computer device analyzes the positions of all defects in the initial defect image and marks the defect located at the middle position of the image as the target defect. Except for the target defect, the computer device marks all other defect areas as interference defects.

[0109] Exemplarily, the size of a certain initial defect image is 512×512 pixels. The computer device detects three defect areas in the image through a defect segmentation model: Defect A: the position is (200, 200), located at the center of the image; Defect B: the position is (50, 450), close to the edge of the image; Defect C: the position is (400, 100), close to the corner of the image. Then the computer device marks Defect A as the target defect and marks Defect B and Defect C as interference defects. Thus, the computer device fills and processes Defect B and Defect C respectively.

[0110] In the above embodiments, by defining the target defect as the defect located at the middle position of the initial defect image, it is ensured that the subsequent classification model can focus on the current defect to be detected, reduce the interference of the background and other defects, and make the classification of the target defect by the classification model more accurate. This method is particularly suitable for complex scenarios containing multiple defects, can flexibly adapt to different defect distribution patterns, and effectively classify target defects and interference defects. Through precise defect classification, combined with the subsequent interference defect filling step, the defect classification model still has high robustness and adaptability in complex backgrounds.

[0111] After obtaining the target defect image, the target defect image is input into a defect classification model for classification, which can quickly identify the category of the target defect, thereby providing a reliable basis for defect management and decision-making in the production process. To this end, in some embodiments, the above method further includes: inputting the target defect image into the defect classification model for processing to identify the defect category to which the target defect in the target defect image belongs. Thus, through the preprocessing of the target defect image (such as interference defect filling), the accuracy and robustness of the classification model can be significantly improved.

[0112] Specifically, after the computer device completes the filling process of the interference defect and obtains the target defect image, the target defect image is input into the trained defect classification model. The defect classification model identifies the category to which the target defect belongs based on the feature information of the target defect image and outputs a classification result. The classification result may include specific category labels of the defect, such as scratches, cracks, pits, etc. Then, the computer device can perform corresponding subsequent operations according to the defect category, such as recording the classification result, triggering an alarm mechanism, or generating a maintenance suggestion, etc.

[0113] In the above embodiments, through the preprocessing of the target defect image, the interference of the interference defect and the complex background to the classification model is eliminated, thereby significantly improving the accuracy and confidence of the classification. The purification process of the defect image ensures that the model can focus on the target defect, effectively reducing the misjudgment rate, especially in the multi-defect scenario. The classification steps combined with the interference defect filling can adapt to various scenarios such as complex backgrounds and noise interference, further enhancing its robustness and practicality.

[0114] Illustrated with a specific example, as Figure 6 shown, the defect image processing method proposed by this method realizes the suppression of the model attention shift based on background filling, and its main process steps are as follows:

[0115] Step 601, the computer device obtains the original image and the mask image with background and defect information. For the case of a complex background, the computer device only needs to obtain the mask image output by model segmentation, traditional image algorithm threshold segmentation, etc., and carrying different background information. Exemplarily, the original image can be as Figure 7A shown, and the mask image can be as Figure 7B shown.

[0116] Step 602, the computer device obtains all background information according to the input mask image, extracts the background and defect position information, and obtains the processing boundary of each defect in the current image to clarify the position area of the defect.

[0117] Step 603, the computer device traverses and analyzes all defects and records the background information of each defect.

[0118] Step 604: Based on the size limit of the subsequent classification model, the computer device divides the original image into multiple initial defect images based on a preset size. For the sake of description, it is assumed here that the size of the initial defect image is the same as that of the original image. Of course, it is easy to understand that the computer device can also directly obtain the segmented initial defect images in Step 601. In Step 604, the computer device marks the defect located in the middle position as the target defect and marks other defects as interference defects. As Figure 7A and Figure 7B shown, the defect above the image is an interference defect, while the defect below the image is the target defect.

[0119] Step 605: The computer device traverses and analyzes the interference defects;

[0120] Step 606: The computer device obtains the nearest background information of the interference defect through distance transformation, as Figure 7C shown. Each pixel point of each interference defect corresponds to a nearest background pixel. Exemplarily, the computer device can calculate the nearest background pixel through the Euclidean distance.

[0121] Step 607: The computer device traverses all the internal pixels within the interference defect. For each internal pixel, as Figure 7D shown, the computer device obtains the pixel at the position symmetric to the nearest background point on the extension line of the connection between this internal pixel and its nearest background pixel as the candidate external pixel. If the candidate external pixel is not background information, is an image boundary pixel, or is inconsistent with the background information corresponding to the interference defect, the computer device skips this point and processes the next internal pixel. Otherwise, the computer device takes the candidate external pixel as the target external pixel and fills this internal pixel with the target external pixel. After all the internal pixels that can find appropriate filling information are filled, the computer device obtains a new mask image based on the result of one round of filling and re-executes Steps 605 to 607 until all the interference defects are filled.

[0122] Step 608: The computer device completes the filling of all the internal pixels of the interference defect to obtain the target defect image. Exemplarily, as Figure 7E shown, the target defect image realizes the smooth and natural filling of the interference defect, so that the image only contains the target defect, which can greatly improve the accuracy of subsequent model classification or other subsequent detection tasks.

[0123] Step 609: The computer device traverses the original image until all defect detections and the filling of all interference defects are completed.

[0124] The defect image processing method provided by this application addresses the problem of defect detection in image processing and proposes a defect processing method based on background information filling. The aim is to improve the accuracy and robustness of subsequent classification models by removing interfering defects. By filling the interfering defects in the defect image, interfering factors are removed, making the target defect image cleaner and better able to adapt to subsequent classification models. Due to the reduction of noise and interference, the classification model can more accurately identify the categories of target defects, greatly improving the accuracy of the classification results. Moreover, through precise background information filling, on the one hand, the problem of false positives caused by the existence of interfering defects is effectively avoided. The filled defect image can ensure that the classification model focuses on the actual target defects, thereby reducing the misjudgment rate. On the other hand, using background information filling can ensure the naturalness of the background transition, making the transition of the filled area smooth and avoiding the appearance of hard boundaries, ensuring a more natural visual effect.

[0125] Due to the adoption of a robust filling method based on background information, it can handle defect classification tasks in complex backgrounds. Whether in the case of large interfering defects or strong background noise, the algorithm can accurately perform background filling and defect extraction, enhancing the robustness of the algorithm in a changing environment. In the case of multiple defects and complex backgrounds, it ensures that each target defect can be separately extracted and classified. This method is particularly suitable for the field of industrial quality inspection, especially in scenarios where surface defects are complex and intertwined, and can effectively handle difficult-to-classify situations such as aggregated defects and interfering defects.

[0126] The above method can be used in conjunction with existing defect segmentation models and defect classification models through adaptive image segmentation and processing, with strong flexibility and facilitating integration in practical applications.

[0127] In the embodiment of this application, the execution subject of the defect image processing method can be a defect image processing device. In the embodiment of this application, taking the defect image processing device executing the defect image processing method as an example, the defect image processing device provided by the embodiment of this application is described.

[0128] The embodiment of this application also provides a defect image processing device, which is applied to a computer device. As Figure 8 shown, the defect image processing device includes an acquisition module 801 and a processing module 802. Among them:

[0129] The acquisition module 801 is used to acquire an initial defect image and determine the target defects and interfering defects in the initial defect image.

[0130] The processing module 802 is used to determine target external pixels that match the internal pixels of the interfering defect among the external pixels of the interfering defect, and fill the matching internal pixels with the target external pixels.

[0131] The processing module 802 is further configured to traverse all internal pixels of the interference defect until all internal pixels are filled, so as to obtain a target defect image; the target defect image excludes the interference defect and is used to process the target defect.

[0132] According to the defect image processing device provided by the embodiments of the present application, after obtaining the initial defect image, by determining the target defect and the interference defect in the initial defect image, and determining, among the external pixels of the interference defect, the target external pixels that match the internal pixels of the interference defect, and filling the matching internal pixels with the target external pixels to fill the interference defect area with background information, the influence of the interference defect on the detection and classification of the target defect is effectively eliminated; traversing all internal pixels of the interference defect until all internal pixels are filled to obtain a target defect image, and the target defect image excludes the interference defect and is used to process the target defect. Thus, by only retaining the target defect, it helps the classification model to focus on the target defect and improve the accuracy and stability of classification. This method uses background information for filling, can adapt to industrial detection environments with complex backgrounds, expands the scope of technical applications, does not rely on specific segmentation or classification models, can be combined with existing detection systems, and has high versatility and practical value.

[0133] In some embodiments, the processing module is further configured to, for any internal pixel of the interference defect, determine, among the external pixels of the interference defect, the nearest background pixel that is closest to the targeted internal pixel; based on the nearest background pixel, search for candidate external pixels that match the targeted interference pixel; and when the candidate external pixels meet the preset conditions, use the candidate external pixels as the target external pixels that match the targeted internal pixel.

[0134] In some embodiments, the processing module is further configured to determine the extension line of the connection line between the target background pixel and the targeted internal pixel; and on the extension line, use the external pixels that are symmetric with respect to the target background pixel as the candidate external pixels that match the targeted interference pixel.

[0135] In some embodiments, the candidate external pixels meeting the preset conditions include: the candidate external pixels are background pixels corresponding to the interference defect and are not image boundary pixels.

[0136] In some embodiments, the processing module is further configured to skip the targeted internal pixel when the candidate external pixel does not meet the preset condition, and use the next internal pixel as the next targeted internal pixel until all the internal pixels in the current iteration are traversed; based on all the internal pixels skipped in the current iteration, re-determine the interfering defects in the initial defect image, and return to the step of determining the target external pixel that matches the internal pixel of the interfering defect among the external pixels of the interfering defect, and continue to execute until all the internal pixels are filled, obtaining the target defect image.

[0137] In some embodiments, the acquisition module is further configured to acquire the original image output by the defect segmentation model; segment the original image based on a preset size to obtain multiple initial defect images; the preset size matches the input limit of the defect classification model.

[0138] In some embodiments, the acquisition module is further configured to, for any initial defect image, acquire the defect information corresponding to the initial defect image; determine one or more defects in the targeted initial defect image based on the defect information; among the one or more defects, use the defect located at the middle position of the targeted initial defect image as the target defect, and use the other defects except the target defect as interfering defects.

[0139] In some embodiments, the above device further includes an output module, configured to input the target defect image into the defect classification model for processing to identify the defect category to which the target defect in the target defect image belongs.

[0140] The defect image processing device in the embodiments of the present application may be a computer device or a component in a computer device, such as an integrated circuit or a chip. The computer device may be a terminal device or a server. Exemplarily, the computer device may be a mobile phone, a tablet computer, a laptop computer, a handheld computer, an in-vehicle computer device, a Mobile Internet Device (MID), an Augmented Reality (AR) / Virtual Reality (VR) device, a robot, a wearable device, an Ultra-mobile Personal Computer (UMPC), a netbook, or a Personal Digital Assistant (PDA), etc., and may also be a server, a Network Attached Storage (NAS), a Personal Computer (PC), a Television (TV), a teller machine, or a self-service machine, etc. The embodiments of the present application do not make specific limitations.

[0141] The defect image processing device in the embodiments of the present application can be a device with an operating system. The operating system can be the Microsoft (Windows) operating system, the Android operating system, the IOS operating system, or other possible operating systems, which are not specifically limited in the embodiments of the present application.

[0142] The defect image processing device provided by the embodiments of the present application can implement Figure 2 , Figure 4 , Figure 6 each process implemented by the method embodiments. To avoid repetition, it will not be elaborated here.

[0143] In some embodiments, as Figure 9 shown, the embodiments of the present application further provide a computer device 900, including a processor 901, a memory 902, and a computer program stored on the memory 902 and executable on the processor 901. When the program is executed by the processor 901, it implements each process of the above method embodiments and can achieve the same technical effects. To avoid repetition, it will not be elaborated here.

[0144] It should be noted that the computer device in the embodiments of the present application includes the above-mentioned mobile computer device and non-mobile computer device.

[0145] The embodiments of the present application further provide a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it implements each process of the above-mentioned defect image processing method embodiments and can achieve the same technical effects. To avoid repetition, it will not be elaborated here.

[0146] Among them, the processor is the processor in the computer device described in the above embodiments. The readable storage medium includes computer-readable storage media, such as computer read-only memory ROM, random access memory RAM, magnetic disks, or optical discs, etc.

[0147] The embodiments of the present application further provide a computer program product, including a computer program, which implements the above-mentioned defect image processing method when executed by a processor.

[0148] Among them, the processor is the processor in the computer device described in the above embodiments. The readable storage medium includes computer-readable storage media, such as computer read-only memory ROM, random access memory RAM, magnetic disks, or optical discs, etc.

[0149] Another embodiment of the present application further provides a chip, which includes a processor and a communication interface. The communication interface is coupled to the processor. The processor is configured to run programs or instructions to implement each process of the above-described embodiment of the defect image processing method and can achieve the same technical effects. To avoid repetition, details are not described herein again.

[0150] It should be understood that the chip mentioned in the embodiments of the present application may also be referred to as a system-on-chip, system chip, chip system, or system-on-chip, etc.

[0151] It should be noted that in this document, the terms "include", "comprise", or any other variation thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device that includes a series of elements includes not only those elements but also other elements not explicitly listed, or elements that are inherent to such process, method, article, or device. Without further limitation, an element defined by the statement "including a..." does not exclude the existence of additional identical elements in the process, method, article, or device that includes the element. In addition, it should be pointed out that the methods and devices in the embodiments of the present application are not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in a reverse order according to the functions involved. For example, the described methods may be performed in an order different from that described, and various steps may be added, omitted, or combined. Additionally, the features described with reference to certain examples may be combined in other examples.

[0152] Through the above description of the embodiments, those skilled in the art can clearly understand that the above-described embodiment methods can be implemented by means of software plus a necessary general hardware platform. Of course, they can also be implemented by hardware, but in many cases, the former is a better implementation method. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the related art, can be embodied in the form of a computer software product. The computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions for causing a terminal (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of the present application.

[0153] The above has described the embodiments of the present application in conjunction with the accompanying drawings. However, the present application is not limited to the above specific embodiments. The above specific embodiments are merely illustrative and not restrictive. Those of ordinary skill in the art, under the inspiration of the present application and without departing from the spirit and scope protected by the present application's claims, can still make many forms, all of which fall within the protection scope of the present application.

[0154] In the description of this specification, the descriptions referring to terms such as "one embodiment", "some embodiments", "schematic embodiments", "examples", "specific examples", or "some examples", etc. mean that the specific features, structures, materials, or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of this application. In this specification, the schematic expressions of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described can be combined in a suitable manner in any one or more embodiments or examples.

[0155] If there is no special instruction, all the implementation manners and optional implementation manners of this application can be combined with each other to form a new technical solution.

[0156] If there is no special instruction, all the technical features and optional technical features of this application can be combined with each other to form a new technical solution.

[0157] If there is no special instruction, all the steps of this application can be carried out in sequence or randomly, and preferably in sequence. For example, the method includes steps (a) and (b), which means that the method can include steps (a) and (b) carried out in sequence, or can also include steps (b) and (a) carried out in sequence. For example, it is mentioned that the method may further include step (c), which means that step (c) can be added to the method in any order. For example, the method can include steps (a), (b), and (c), or can also include steps (a), (c), and (b), or can also include steps (c), (a), and (b), etc.

[0158] The above are only the preferred embodiments of this application and are not used to limit this application. For those skilled in the art, this application can have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of this application shall be included in the protection scope of this application.

Claims

1. A defect image processing method, characterized in that: The method comprises: Acquire an initial defect image, and determine a target defect and an interference defect in the initial defect image; Determine, among the external pixels of the interference defect, target external pixels that match the internal pixels of the interference defect, and fill the matching internal pixels with the target external pixels; All internal pixels of the interference defect are traversed until all internal pixels are filled to obtain a target defect image; the target defect image excludes the interference defect to be used for processing the target defect.

2. The method according to claim 1, characterized in that: The step of determining, among the external pixels of the interference defect, target external pixels that match the internal pixels of the interference defect, and filling the matching internal pixels with the target external pixels comprises: For any internal pixel of the interference defect, determine, among the external pixels of the interference defect, a nearest background pixel that is closest to the targeted internal pixel; Based on the nearest background pixel, searching for a candidate external pixel that matches the targeted interference pixel; In the case where the candidate external pixel meets a preset condition, the candidate external pixel is used as a target external pixel that matches the targeted internal pixel.

3. The method according to claim 2, characterized in that The step of searching for a candidate external pixel matching the interference pixel based on the nearest background pixel comprises: Determine an extension line of a line connecting the nearest background pixel and the targeted internal pixel; On the extension line of the connecting line, external pixels that are symmetrical with respect to the nearest background pixel are taken as candidate external pixels that match the targeted interference pixel.

4. The method according to claim 2 or 3, characterized in that: The candidate external pixel satisfies a preset condition, which includes: the candidate external pixel is a background pixel corresponding to the interference defect and is not an image boundary pixel.

5. The method according to claim 2, characterized in that: The method further comprises: If the candidate external pixel does not meet the preset condition, the internal pixel targeted is skipped, and the next internal pixel is used as the next internal pixel targeted, until all the internal pixels of the current time are traversed; Based on all the internal pixels skipped this time, the interference defect in the initial defect image is re-determined, and the step of returning to the external pixels of the interference defect and determining the target external pixels that match the internal pixels of the interference defect is continued until all the internal pixels are filled to obtain the target defect image.

6. The method according to claim 1, characterized in that Before acquiring the initial defect image, the method further includes: Obtain the original image output by the defect segmentation model; The original image is segmented based on a preset size to obtain a plurality of initial defect images; the preset size matches the input limit of the defect classification model.

7. The method according to claim 1 or 6, characterized in that: The determining of the target defect and the interference defect in the initial defect image comprises: For any initial defect image, obtaining defect information corresponding to the initial defect image; Based on the defect information, determining one or more defects in the targeted initial defect image; Among the one or more defects, a defect located at a middle position of the targeted initial defect image is taken as a target defect, and other defects other than the target defect are taken as interference defects.

8. The method according to claim 1, characterized in that After obtaining the target defect image, the method further includes: The target defect image is input into a defect classification model for processing to identify the defect category to which the target defect in the target defect image belongs.

9. A defect image processing device, characterized in that: The device comprises: An acquisition module, used to acquire an initial defect image and determine a target defect and an interference defect in the initial defect image; A processing module, configured to determine, among the external pixels of the interference defect, target external pixels that match the internal pixels of the interference defect, and fill the matching internal pixels with the target external pixels; The processing module is further used to traverse all internal pixels of the interference defect until all internal pixels are filled to obtain a target defect image; the target defect image excludes the interference defect to be used for processing the target defect.

10. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the defective image processing method according to any one of claims 1 to 8 is implemented.