Defect detection method, device, equipment, storage medium and program product
By generating pixel comparison images and using pixel value differences to determine the defective parts, the problem of low accuracy in existing defect detection models is solved, and higher detection accuracy is achieved.
Patent Information
- Application Number
- CN202511336872.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-18
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2045-09-18
AI Technical Summary
Existing defect detection models suffer from low accuracy and noisy data due to the wide variety of defect types and limited training samples.
By using a pre-trained defect detection model to detect defects in the image, a preliminary pixel comparison map of the defect area is generated. The difference in pixel values is then used to further determine the defect part, reducing noise data and improving detection accuracy.
This improves the accuracy of defect detection results by generating pixel comparison maps to further reduce noise data and ensure the precision of the final detection results.
Smart Images

Figure CN120823218B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of image processing technology, and in particular relates to defect detection methods, devices, equipment, storage media and program products. Background Technology
[0002] With the development of technology, during the product manufacturing process, each sample to be produced is tested, and the samples that meet the factory conditions are selected to ensure the quality of the finished product. For example, the samples are tested to check for defects in appearance, whether the parts are complete, and whether the assembly of the parts conforms to the assembly specifications.
[0003] In related technologies, a defect detection model is pre-trained, and the sample image is input into the defect detection model for defect detection. The output results are used to determine whether the sample has defects.
[0004] However, due to the wide variety of defects, the pre-trained defect detection model cannot cover all types of defects. Furthermore, the limited training samples of the defect detection model result in limited defect detection capabilities, leading to low accuracy in defect detection results. Summary of the Invention
[0005] This application provides a defect detection method, apparatus, device, storage medium, and program product. After obtaining preliminary detection results by performing defect detection on a detection image using a pre-trained defect detection model, a comparison image is generated based on the difference between the pixel values in the defect area and the pixel values in the reference area in the preliminary detection results. The defective part in the detection image is further determined based on the comparison image, thereby improving the accuracy of the defect detection results.
[0006] In a first aspect, embodiments of this application provide a defect detection method, the method comprising:
[0007] Acquire the detection image;
[0008] The detection image is subjected to defect detection by a pre-trained defect detection model to obtain a first defect region corresponding to the detection image. The first defect region includes the region corresponding to the defect part in the detection image. The defect detection model is a neural network model. Multiple first pixels in the first defect region correspond to first pixel values respectively.
[0009] The second pixel value in the reference region of the detected image is obtained. The reference region refers to the region corresponding to a specified position in the first defect region. Multiple second pixels in the reference region correspond to candidate pixel values. The second pixel value is obtained based on the sorting result of multiple candidate pixel values.
[0010] Based on the pixel differences between the plurality of first pixel values and the second pixel values, a pixel comparison map corresponding to the first defect region is generated.
[0011] If the image parameters of the second defect region in the pixel comparison image meet the preset defect conditions, the second defect region is used as the defect detection result corresponding to the detection image. The defect detection result is used to indicate that the second defect region is the region corresponding to the defect part in the detection image.
[0012] Optionally, the plurality of first pixel values includes the i-th first pixel value corresponding to the i-th first pixel point, where i is a positive integer;
[0013] The step of generating a pixel comparison map corresponding to the first defect region based on the pixel differences between the plurality of first pixel values and the second pixel values includes:
[0014] Obtain the pixel value difference between the i-th first pixel value and the second pixel value, and use it as the i-th pixel difference;
[0015] The pixel comparison map is generated based on the pixel differences corresponding to the plurality of first pixel values.
[0016] Optionally, the detected image is a color image, and the i-th first pixel value includes the i-th first sub-value, the i-th second sub-value, and the i-th third sub-value;
[0017] The step of obtaining the pixel value difference between the i-th first pixel value and the second pixel value as the i-th pixel difference includes:
[0018] Obtain the pixel value difference between the i-th first sub-value and the second pixel value, and use it as the i-th first difference value;
[0019] The pixel value difference between the i-th second sub-value and the second pixel value is obtained as the i-th second difference value;
[0020] The pixel value difference between the i-th third sub-value and the second pixel value is obtained as the i-th third difference value;
[0021] The i-th pixel difference is obtained based on the i-th first difference, the i-th second difference, and the i-th third difference.
[0022] Optionally, after generating the pixel comparison map based on the pixel differences corresponding to the plurality of first pixel values, the method further includes:
[0023] Obtain the first weight value, the second weight value, and the third weight value;
[0024] Obtain the i-th first product result between the first weight value and the i-th first difference;
[0025] Obtain the i-th second product result between the second weight value and the i-th second difference;
[0026] Obtain the third product result between the third weight value and the i-th third difference;
[0027] Based on the sum of the i-th first product result, the i-th second product result, and the i-th third product result, the i-th third pixel value corresponding to the i-th first pixel is obtained;
[0028] A defect comparison image is generated based on the third pixel values corresponding to the plurality of first pixel points;
[0029] When the image parameters of the second defect region in the pixel comparison image meet the preset defect conditions, the second defect region is taken as the defect detection result corresponding to the detection image, including:
[0030] If the image parameters of the second defect region in the defect comparison image meet the preset defect conditions, the second defect region is taken as the defect detection result corresponding to the detection image.
[0031] Optionally, the preset defect conditions include at least one of a contrast threshold, a pixel count threshold, or an aspect ratio threshold;
[0032] Before using the second defect region as the defect detection result corresponding to the detection image, the method further includes:
[0033] If the contrast of pixels in the second defect region reaches the contrast threshold, it is determined that the second defect region meets the preset defect condition; and / or;
[0034] If the number of pixels in the second defect region reaches the pixel number threshold, the second defect region is determined to meet the preset defect condition; and / or;
[0035] If the ratio between the length and width of the second defect region reaches the aspect ratio threshold, the second defect region is determined to meet the preset defect condition.
[0036] Optionally, before performing defect detection on the detected image using a pre-trained defect detection model to obtain the first defect region corresponding to the detected image, the method further includes:
[0037] Obtain a first sample image, wherein the first sample image includes a defective portion of the first sample;
[0038] The defective part of the first sample is labeled to obtain the defect label corresponding to the first sample image. The defect label is used to indicate the position and defect features of the defective part of the first sample in the first sample image.
[0039] A first random value is generated based on the aforementioned defect characteristics;
[0040] A second sample image is generated based on the first random value. The second sample image includes a second defect portion, which is randomly generated based on the first random value.
[0041] The defect detection model is obtained by gradient training of the sample detection model based on the first sample image and the second sample image.
[0042] Secondly, embodiments of this application provide a defect detection device, including:
[0043] The acquisition module is used to acquire the detection image;
[0044] The detection module is used to perform defect detection on the detection image using a pre-trained defect detection model to obtain a first defect region corresponding to the detection image. The first defect region includes the region corresponding to the defective part in the detection image. The defect detection model is a neural network model, and multiple first pixels in the first defect region correspond to first pixel values respectively.
[0045] The acquisition module is used to acquire the second pixel value in the reference region of the detection image. The reference region refers to the region corresponding to a specified position in the first defect region. Multiple second pixel points in the reference region correspond to candidate pixel values respectively. The second pixel value is obtained based on the sorting result of multiple candidate pixel values.
[0046] The generation module is used to generate a pixel comparison map corresponding to the first defect region based on the pixel differences between the plurality of first pixel values and the second pixel values respectively;
[0047] The determination module is used to determine the second defect region as the defect detection result corresponding to the detection image when the image parameters of the second defect region in the pixel comparison image meet the preset defect conditions. The defect detection result is used to indicate that the second defect region is the region corresponding to the defect part in the detection image.
[0048] Thirdly, embodiments of this application provide a computer device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the defect detection method described in any one of the first aspects above.
[0049] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the defect detection method described in any one of the first aspects.
[0050] Fifthly, embodiments of this application provide a computer program product that, when run on a computer device, causes the computer device to execute the defect detection method described in any one of the first aspects.
[0051] It is understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant descriptions in the first aspect mentioned above, and will not be repeated here.
[0052] The beneficial effects of the technical solutions provided in this application include at least the following:
[0053] A pre-trained defect detection model is used to detect defects in the image, resulting in a first defect region. A pixel comparison map of the first defect region is generated based on the difference between the first pixel value in the first defect region and the second pixel value in the reference region of the image. This pixel comparison map is then used to further identify a second defect region within the first defect region, which is then taken as the final defect detection result. In other words, after initial defect detection using the model, a pixel comparison map is generated based on the difference between the pixel values in the initial detection result and the reference pixel values. This process further reduces noise in the first defect region, allowing for more accurate defect detection and ultimately improving the accuracy of the final defect detection result. Attached Figure Description
[0054] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0055] Figure 1 This is a flowchart of a defect detection method provided in an embodiment of this application;
[0056] Figure 2This is a flowchart of a defect detection method provided in an embodiment of this application;
[0057] Figure 3 This is a schematic diagram illustrating a defect comparison image generation method provided in an embodiment of this application;
[0058] Figure 4 This is a schematic diagram of the defect detection results provided in an embodiment of this application;
[0059] Figure 5 This is a schematic diagram of a defect label provided in an embodiment of this application;
[0060] Figure 6 This is a schematic diagram of a second sample image provided in an embodiment of this application;
[0061] Figure 7 This is a structural diagram of the defect detection device provided in the embodiments of this application;
[0062] Figure 8 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation
[0063] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.
[0064] It should be understood that, when used in this application specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or a collection thereof.
[0065] It should also be understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0066] As used in this application specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if detected [the described condition or event]" may be interpreted, depending on the context, as meaning "once determined," "in response to determination," "once detected [the described condition or event]," or "in response to detection [the described condition or event]."
[0067] Furthermore, in the description of this application and the appended claims, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0068] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.
[0069] In related technologies, a defect detection model is pre-trained, and a sample image is input into the model for defect detection. The output result is used to determine whether the sample has a defect. However, due to the wide variety of defects, the pre-trained defect detection model cannot cover all types of defects. Furthermore, the training samples for the defect detection model are limited, resulting in limited defect detection capabilities. Additionally, the presence of noisy data in the defect detection results inevitably leads to low accuracy.
[0070] Based on this, embodiments of this application provide a defect detection method. A pre-trained defect detection model is used to detect defects in a detection image, resulting in a first defect region. A pixel comparison map of the first defect region is generated based on the difference between the first pixel value of a pixel in the first defect region and the second pixel value in a reference region of the detection image. The pixel comparison map is then used to further determine a second defect region containing a defective portion within the first defect region, which serves as the defect detection result for the detection image. In other words, after performing preliminary defect detection on the detection image using the defect detection model to obtain a preliminary detection result, a pixel comparison map is generated based on the difference between the pixel values in the preliminary detection result and the reference pixel values. This further reduces noise data in the first defect region, enabling further defect detection in the first defect region and resulting in a more accurate final defect detection result.
[0071] The defect detection method provided in the embodiments of this application will be described in detail below. For illustrative purposes, please refer to the following: Figure 1 The diagram illustrates a flowchart of a defect detection method provided in an exemplary embodiment of this application, which includes steps 110 to 150.
[0072] Step 110: Obtain the detection image.
[0073] In illustrative terms, the detection image is an image obtained by acquiring images of the detection object through an image acquisition device. The image acquisition device includes at least one of the following types: film camera, digital camera, industrial camera (e.g., area scan camera, line scan camera, or smart camera), microscopic imaging device (e.g., optical microscope, electron microscope), astronomical imaging device (radio telescope), electromagnetic wave-based image acquisition device (e.g., infrared thermal imager, X-ray imaging device), three-dimensional imaging device, multispectral imaging device, embedded imaging device (e.g., mobile phone camera, drone-borne camera), light field camera, etc.
[0074] Optionally, the detection image is a single image corresponding to a single detection object; or, the detection image is multiple images corresponding to a single detection object; or, the detection image includes multiple images of multiple detection objects. This application embodiment does not limit this.
[0075] Optionally, the detected image may include the defective portion, or the detected image may not include the defective portion.
[0076] Optionally, the detection image is a three-channel image (RGB image), also known as a color image. In this case, each pixel in the detection image outputs three channel values, namely the red (Red, R) channel value, the green (Green, G) channel value, and the blue (Blue, B) channel value. The pixel value of the pixel in the detection image is determined based on the R channel value, G channel value, and B channel value.
[0077] Optionally, the detection image is a single-channel image, also known as a grayscale image. In this case, each pixel in the detection image outputs a single-channel value, which serves as the pixel value, also known as the grayscale value.
[0078] Step 120: Defect detection is performed on the detection image using a pre-trained defect detection model to obtain the first defect region corresponding to the detection image.
[0079] The first defect region includes the region corresponding to the defect in the detected image. The defect detection model is a neural network model, and the multiple first pixels in the first defect region correspond to the first pixel values.
[0080] In illustrative terms, the first pixel refers to the pixel that constitutes the first defect region.
[0081] In a schematic way, the detection image is input into the defect detection model, the defect detection model performs defect detection on the detection image, and the output result is the first defect region of the detection image.
[0082] The first defect region refers to the region corresponding to the defective part in the detected image.
[0083] Optionally, the defect detection model includes at least one of the following model types:
[0084] The first type is a classification network, which outputs results including whether the image has defects (e.g., 0 indicates no defects, 1 indicates defects) and the defect category (e.g., a: bump; b: scratch).
[0085] The classification networks include the ResNet residual model and the EfficientNet composite scaling model.
[0086] The second type is the object detection network, which adds bounding box recognition on the basis of classification, thereby identifying defect areas in the detected image;
[0087] The object detection networks include Faster R-CNN and the Single Shot MultiBox Detector (SSD).
[0088] The third type is the semantic segmentation network, which classifies the pixels in the detected image by traversing the pixels, generates a mask corresponding to the defect, determines the boundary of the defect based on the mask, and identifies the defect region.
[0089] The semantic segmentation network includes an encoder-decoder model (U-Net) and a lightweight segmentation model based on Transformer (SegFormer).
[0090] It is worth noting that the above-described defect detection model is merely an illustrative example, and the embodiments of this application do not limit it.
[0091] Optionally, the detected image includes one or more first defect regions. If there are multiple first defect regions, they are independent of each other and do not overlap. Alternatively, at least two of the multiple first defect regions may have an overlapping portion. This application does not limit this aspect.
[0092] Optionally, the defects include appearance defects (protrusions, dents, scratches, shadows, stains, partial missing parts, dimensions not meeting size requirements), component defects (missing components, component data exceeding quantity thresholds, component types not meeting type conditions, component assembly not meeting assembly specifications, etc.), structural defects (internal fractures, presence of pores, separation between composite material layers, impurities mixed in the material), and packaging defects (damage, deformation, tearing, incorrect labeling, sealing not meeting sealing standards), etc., which are not limited in this application embodiment.
[0093] Optionally, if the detected image is a multi-channel image, the first pixel value is the red channel value, the green channel value, and the blue channel value; if the detected image is a single-channel image, the first pixel value is the grayscale value.
[0094] Step 130: Obtain the second pixel value in the reference region of the detected image.
[0095] The reference region refers to the region corresponding to the specified location of the first defect region. Multiple second pixels in the reference region correspond to candidate pixel values, and the second pixel values are obtained based on the sorting results of multiple candidate pixel values.
[0096] Indicatively, the reference area refers to the area at a specified location of the first defect area, such as the area adjacent to the first defect area in the detection image.
[0097] Optionally, the reference area can be selected in at least one of the following ways:
[0098] The first method involves obtaining multiple pixel points 1 corresponding to the edge position of the first defect region, determining the coordinate point position of the pixel point whose coordinate distance from the coordinate point position is within a preset range based on the coordinate point positions of the multiple pixel points 1 in the coordinate system established by the detection image, and determining the reference region based on the coordinate point position.
[0099] The second method involves obtaining the region range 1 of the first defect region in the detection image (determined by the coordinate positions of the pixels in the first defect region in the coordinate system established in the detection image), determining the region range 2 based on the region range 1 and the pre-set region rules, and using the region corresponding to the region range 2 as the reference region.
[0100] It is worth noting that the above-described method for selecting the reference area is merely an illustrative example, and the embodiments of this application do not limit it.
[0101] In this embodiment, the region adjacent to the first defect region is used as the reference region. That is, the pixel 1 at the edge of the first defect region and the pixel 2 at the edge of the reference region are adjacent.
[0102] Optionally, the adjacency relationship includes at least one of 4-neighborhood, 8-neighborhood, D-neighborhood, or extended neighborhood.
[0103] Among them, 4-neighborhood refers to the four adjacent pixels located at the top, bottom, left, and right of the target pixel; 8-neighborhood refers to the eight adjacent pixels located at the top, bottom, left, right, and four diagonal directions of the target pixel; D-neighborhood refers to the adjacent pixels in the four diagonal directions of the target pixel; and extended neighborhood refers to defining an M×N rectangular area as the neighborhood with the target pixel as the center, and all pixels in this rectangular area are adjacent pixels of the target pixel.
[0104] Indicatively, the second pixel value is determined based on the pixel values of pixels in the reference area.
[0105] Optionally, the second pixel value is obtained by at least one of the following methods:
[0106] The first method involves arranging the pixel values corresponding to multiple second pixel points in the reference area according to a certain arrangement rule (e.g., from smallest to largest or from largest to smallest) to obtain a pixel value sequence. The pixel value in the middle position of the pixel value sequence is selected as the second pixel value. If the pixel value sequence is an even sequence, the average of the two pixel values in the middle position is calculated to obtain the second pixel value.
[0107] The second method is to calculate the average value of the pixel values corresponding to multiple second pixel points in the reference area and use that result as the second pixel value.
[0108] The third method involves performing bubble processing on the pixel values corresponding to multiple pixels in the reference area to obtain a bubble sequence (e.g., after removing the maximum and minimum pixel values, arrange them in ascending order). Select the pixel value in the middle position from the bubble sequence as the second pixel value. If the bubble sequence is an even sequence, then the average of the two pixel values in the middle position is calculated to obtain the second pixel value.
[0109] It is worth noting that the above-described method for obtaining the second pixel value is merely an illustrative example, and the embodiments of this application do not limit it.
[0110] Indicatively, since the second pixel value is obtained from multiple pixel values in the reference area, and the reference area does not belong to the defect area, the second pixel value can be considered to belong to the pixel value of the non-defective part.
[0111] Optionally, the second pixel value is a grayscale value; or, the second pixel value is a grayscale value obtained by weighted fusion of three channel values; or, the second pixel value includes three channel values, which is not limited in this embodiment of the application.
[0112] Step 140: Generate a pixel comparison map corresponding to the first defect region based on the pixel differences between multiple first pixel values and second pixel values.
[0113] Indicatively, pixel difference refers to the difference between the first pixel value and the second pixel value, which expresses the contrast between the first pixel and the second pixel. The larger the pixel difference, the more obvious the contrast. Therefore, the larger the pixel difference, the higher the probability that the first pixel belongs to the defective part.
[0114] Indicatively, there is a pixel difference between each first pixel value and each second pixel value. In other words, each first pixel point has a corresponding pixel difference. Therefore, a pixel comparison image is constructed based on the pixel differences corresponding to multiple first pixel points.
[0115] For illustration purposes, the pixel comparison image is a single-channel image, or a three-channel image.
[0116] Step 150: If the image parameters of the second defect region in the pixel comparison image meet the preset defect conditions, the second defect region is taken as the defect detection result corresponding to the detection image.
[0117] The defect detection result is used to indicate that the second defect region is the region corresponding to the defect portion in the detected image.
[0118] Indicatively, the second defect region refers to the region corresponding to the defective portion in the final detected image.
[0119] Indicatively, the defect detection results are used to indicate the location of the defect in the detection image, the area of the region corresponding to the defect, and the shape of the defect.
[0120] Optionally, the image parameters include the absolute value of the pixel difference corresponding to each pixel in the second defect region (representing a comparison image of the pixels), the number of pixels in the second defect region (representing the area of the second defect region), or the ratio between the length and width in the second defect region.
[0121] Optionally, the first defect region and the second defect region may be the same, or the first defect region and the second defect region may be different. This application does not limit this.
[0122] The defect detection method provided in this application performs defect detection on a detection image using a pre-trained defect detection model to obtain a first defect region in the detection image. A pixel comparison map of the first defect region is generated based on the difference between the first pixel value of a pixel in the first defect region and the second pixel value in a reference region of the detection image. The pixel comparison map is then used to further determine a second defect region containing a defective portion within the first defect region, which serves as the defect detection result for the detection image. In other words, after performing preliminary defect detection on the detection image using the defect detection model to obtain a preliminary detection result, a pixel comparison map is generated based on the difference between the pixel values in the preliminary detection result and the reference pixel values. This further reduces noise data in the first defect region, enabling further defect detection in the first defect region and resulting in a more accurate final defect detection result.
[0123] The defect detection method is explained in detail below. Please refer to the illustrative examples. Figure 2 This illustrates a flowchart of a defect detection method provided in an exemplary embodiment of this application. Specifically, step 140 further includes steps 141 and 142, and step 150 further includes step 151, as shown below. Figure 2 As shown, the method includes the following steps.
[0124] Step 141: Obtain the pixel value difference between the i-th first pixel value and the second pixel value, and use it as the i-th pixel difference.
[0125] Among the multiple first pixel values, the i-th first pixel value corresponding to the i-th first pixel point is included, where i is a positive integer.
[0126] To illustrate, taking the i-th first pixel in the first defect region as an example, the i-th first pixel corresponds to the i-th first pixel value.
[0127] Wherein, if the i-th first pixel value corresponds to the first gray value and the second pixel value is the second gray value, then the i-th pixel difference is the gray value difference between the first gray value and the second gray value.
[0128] In some embodiments, the detected image is a color image, and the i-th first pixel value includes an i-th first sub-value, an i-th second sub-value, and an i-th third sub-value; the pixel value difference between the i-th first sub-value and the second pixel value is obtained as the i-th first difference; the pixel value difference between the i-th second sub-value and the second pixel value is obtained as the i-th second difference; the pixel value difference between the i-th third sub-value and the second pixel value is obtained as the i-th third difference; and the i-th pixel difference is obtained based on the i-th first difference, the i-th second difference, and the i-th third difference.
[0129] In this embodiment, taking the detection image as a color image as an example, each pixel in the detection image outputs three channel values. Therefore, the i-th first pixel value includes the red channel value (i-th first sub-value), the green channel value (i-th second sub-value), and the blue channel value (i-th third sub-value).
[0130] In this embodiment, if the second pixel value is a grayscale value obtained by grayscale conversion based on the three-channel color values, then the first difference between the red channel value and the second pixel value, the second difference between the green channel value and the second pixel value, and the third difference between the blue channel value and the second pixel value are calculated. The value of the ith pixel is obtained by fusing the values of the first difference, the second difference, and the third difference. For example, the average value of the first difference, the second difference, and the third difference is calculated, or the weighted average value of the first difference, the second difference, and the third difference is calculated.
[0131] In this embodiment, if the second pixel value is a grayscale value obtained by grayscale conversion based on the three-channel color values, then firstly, based on the fusion result between the red channel value, green channel value, and blue channel value, it is converted into the grayscale value corresponding to the i-th first pixel point. For example, the average value between the red channel value, green channel value, and blue channel value is calculated, or the weighted average value between the red channel value, green channel value, and blue channel value is calculated. The pixel difference between the fusion result and the second pixel value is calculated to obtain the i-th pixel difference, which can be referred to Formula 1 for details.
[0132] Formula 1: C = I - G_m
[0133] Where C represents the pixel difference, I represents the first pixel value, and G_m represents the second pixel value.
[0134] In this embodiment, in one case, if the second pixel value also includes three-channel pixel values, then the first difference between the red channel value in the first pixel value and the red channel value in the second pixel value is calculated, the second difference between the green channel value in the first pixel value and the green channel value in the second pixel value is calculated, and the third difference between the blue channel value in the first pixel value and the blue channel value in the second pixel value is calculated. The pixel values in the pixel comparison map are composed of the first difference, the second difference, and the third difference. That is, the pixel comparison map is a three-channel image.
[0135] In this embodiment, in one case, if the second pixel value also includes three-channel pixel values, then the first difference between the red channel value in the first pixel value and the red channel value in the second pixel value is calculated, the second difference between the green channel value in the first pixel value and the green channel value in the second pixel value is calculated, and the third difference between the blue channel value in the first pixel value and the blue channel value in the second pixel value is calculated. The pixel value in the pixel comparison map is obtained by fusing the values of the first difference, the second difference, and the third difference. For example, the average value between the first difference, the second difference, and the third difference is calculated, or the weighted average value between the first difference, the second difference, and the third difference is calculated.
[0136] Step 142: Generate a pixel comparison map based on the pixel differences corresponding to multiple first pixel values.
[0137] In a schematic way, the pixel differences corresponding to multiple first pixel values are used as pixel values in the pixel comparison map to generate the pixel comparison map.
[0138] In some embodiments, a first weight value, a second weight value, and a third weight value are obtained; the i-th first product result between the first weight value and the i-th first difference is obtained; the i-th second product result between the second weight value and the i-th second difference is obtained; the i-th third product result between the third weight value and the i-th third difference is obtained; based on the sum of the i-th first product result, the i-th second product result, and the i-th third product result, the i-th third pixel value corresponding to the i-th first pixel is obtained; and a defect comparison image is generated based on the third pixel values corresponding to the multiple first pixel points respectively.
[0139] In this embodiment, further, if each pixel value in the pixel comparison image outputs a three-channel value, then a first weight value, a second weight value, and a third weight value are pre-generated. The first first product result between the first weight value and the i-th first difference is obtained; the second second product result between the second weight value and the i-th second difference is obtained; the third third product result between the third weight value and the i-th third difference is obtained; based on the sum of the i-th first product result, the i-th second product result, and the i-th third product result, the i-th third pixel value corresponding to the i-th first pixel is obtained, as detailed in Formula 2.
[0140] Formula 2: C1 = 0.299·C_R + 0.587·C_G + 0.114·C_B
[0141] Where C1 represents the pixel value in the defect comparison image, C_R represents the red channel value corresponding to the pixel value in the pixel comparison image, C_G represents the green channel value corresponding to the pixel value in the pixel comparison image, C_B represents the blue channel value corresponding to the pixel value in the pixel comparison image, 0.299 is the first weight value, 0.587 is the second weight value, and 0.114 is the third weight value.
[0142] To illustrate, a defect comparison image is more consistent with pre-defined visual perception than a pixel comparison image because a defect comparison image can more clearly identify the area corresponding to the defect.
[0143] This is illustrative; please refer to it. Figure 3 It illustrates a schematic diagram of a defect comparison image generation method provided in an exemplary embodiment of this application, such as... Figure 3 As shown, the first defect area 310 is currently displayed. According to the above method, a defect comparison image 320 is obtained. It can be seen from the first defect area 310 and the defect comparison image 320 that the defect part is clearer in the defect comparison image 320 than the first defect part 310.
[0144] Step 151: If the image parameters of the second defect region in the defect comparison image meet the preset defect conditions, the second defect region is taken as the defect detection result corresponding to the detection image.
[0145] In some embodiments, the preset defect conditions include at least one of a contrast threshold, a pixel count threshold, or an aspect ratio threshold; if the contrast of the pixels in the second defect region reaches the contrast threshold, the second defect region is determined to meet the preset defect conditions; and / or, if the number of pixels in the second defect region reaches the pixel count threshold, the second defect region is determined to meet the preset defect conditions; and / or, if the ratio between the length and width of the second defect region reaches the aspect ratio threshold, the second defect region is determined to meet the preset defect conditions.
[0146] In this embodiment, a contrast threshold, a pixel count threshold, and an aspect ratio threshold are set. If the contrast of pixels in the second defect region in the defect comparison image reaches the contrast threshold, the second defect region is determined to meet the preset defect conditions. If the number of pixels in the second defect region in the defect comparison image reaches the pixel count threshold, the second defect region is determined to meet the preset defect conditions. If the ratio between the length and width of the second defect region in the defect comparison image reaches the aspect ratio threshold, the second defect region is determined to meet the preset defect conditions.
[0147] This is illustrative; please refer to it. Figure 4 It illustrates a schematic diagram of defect detection results provided by an exemplary embodiment of this application, such as... Figure 4 As shown, the current detection image displays defect detection results, including defect portion 410, defect portion 420, and defect portion 430.
[0148] In illustrative terms, the defect detection method implemented in this application can be executed by a terminal device. Therefore, the final defect detection result is displayed on the terminal device. When the terminal device processes the defect detection task, a parameter setting interface 440 is displayed on the device interface of the terminal device for configuring parameters of the defect detection requirements, such as: detection model, downsampling value, smoothing blur, low contrast threshold, high contrast threshold and area threshold, etc. After the parameters are set, the defect detection result corresponding to the detection image is automatically displayed on the terminal device.
[0149] The training process of the defect detection model will be explained in detail below.
[0150] In some embodiments, a first sample image is acquired, which includes a first sample defect portion; the first sample defect portion is labeled to obtain a defect label corresponding to the first sample image, the defect label indicating the location and defect features of the first sample defect portion in the first sample image; a first random value is generated based on the defect features; a second sample image is generated based on the first random value, which includes a second sample defect portion, the second sample defect portion being randomly generated based on the first random value; and a sample detection model is trained using gradients based on the first sample image and the second sample image to obtain a defect detection model.
[0151] In this embodiment, traditional image processing algorithms are used to initially annotate defects in the sample image, generating an annotation map with defect location and feature information, and thus generating defect labels. For illustrative purposes, please refer to [reference needed]. Figure 5 This illustrates a schematic diagram of a defect label provided in an exemplary embodiment of this application, such as... Figure 5 As shown, the first sample image 500 is currently acquired, and the first sample defect portion 510 in the first sample image is labeled to obtain the defect label corresponding to the first sample defect portion 510. The defect label includes the length, width, pixel value, etc. of the first sample defect portion 510.
[0152] In this embodiment, to address the problem of insufficient real defect samples, a normal distribution random algorithm and other random algorithms are used to generate defect images. During the generation process, key features such as contrast, shape, and dimensions of the defects are made to follow a normal distribution of random values, thereby creating a wide variety of defect samples. The random algorithm refers to using random algorithms (such as data perturbation, Generative Adversarial Networks (GANs), autoencoders, genetic algorithms, etc.) to adjust or simulate the features of the original samples, generating image samples with defect features. For illustrative purposes, please refer to [reference needed]. Figure 6It illustrates a schematic diagram of a second sample image provided in an exemplary embodiment of this application, such as... Figure 6 As shown, multiple second sample images are generated using a random algorithm, including a second sample defect portion 610, a second sample defect portion 620, and a second sample defect portion 630.
[0153] Finally, the defect detection model is trained using defect labels, the first sample image, and the second sample image to obtain the defect detection model. The labeled real images and the generated defects are then compared. Figure 1 The sample data is used as training data and input into the sample defect model for training, so that the model learns various features and patterns of defects, and finally obtains a defect detection model with defect recognition capabilities.
[0154] The defect detection method provided in this application performs defect detection on a detection image using a pre-trained defect detection model to obtain a first defect region in the detection image. A pixel comparison map of the first defect region is generated based on the difference between the first pixel value of a pixel in the first defect region and the second pixel value in a reference region of the detection image. The pixel comparison map is then used to further determine a second defect region containing a defective portion within the first defect region, which serves as the defect detection result for the detection image. In other words, after performing preliminary defect detection on the detection image using the defect detection model to obtain a preliminary detection result, a pixel comparison map is generated based on the difference between the pixel values in the preliminary detection result and the reference pixel values. This further reduces noise data in the first defect region, enabling further defect detection in the first defect region and resulting in a more accurate final defect detection result.
[0155] This application is applicable to the defect detection of most screen types, such as mobile phone screens, tablet screens, laptop screens, watch screens, and car center console screens.
[0156] This application includes the following beneficial effects:
[0157] (1) Defect maps are generated using a normal distribution random algorithm and other random algorithms. The generated defects exhibit normal distribution random values in key features such as contrast, shape, length, and width, thereby creating a wide variety of defect samples. This innovation effectively solves the problem of insufficient real defect samples and too few samples affecting the model training effect and detection accuracy in actual production. It provides rich and diverse training data for the defect detection model and improves the model's ability to identify different types of defects.
[0158] (2) The traditional algorithm is used to label the defects in the image, which replaces the tedious manual labeling work, greatly reduces the workload and time cost of labeling, improves the efficiency of the defect detection process, and ensures that image data with labeled information can be provided quickly and accurately for subsequent model training and detection.
[0159] (3) The secondary screening algorithm re-examines and filters the defect detection results obtained by the defect detection model. This process can accurately identify and eliminate misjudged defects, effectively avoid the over-kill phenomenon that may occur in the defect detection model during the defect detection process, improve the accuracy and reliability of the detection results, and make the final output defect detection results more in line with actual production needs and quality control standards.
[0160] This is illustrative; please refer to it. Figure 7 The diagram illustrates a defect detection apparatus provided in an exemplary embodiment of this application, wherein the defect detection apparatus may specifically include the following modules:
[0161] The acquisition module 710 is used to acquire the detection image;
[0162] The detection module 720 is used to perform defect detection on the detection image using a pre-trained defect detection model to obtain a first defect region corresponding to the detection image. The first defect region includes the region corresponding to the defective part in the detection image. The defect detection model is a neural network model. Multiple first pixels in the first defect region correspond to first pixel values respectively.
[0163] The acquisition module 710 is used to acquire the second pixel value in the reference region of the detection image. The reference region refers to the region corresponding to a specified position in the first defect region. The multiple second pixel points in the reference region correspond to candidate pixel values respectively. The second pixel value is obtained based on the sorting result of the multiple candidate pixel values.
[0164] The generation module 730 is used to generate a pixel comparison map corresponding to the first defect region based on the pixel differences between the plurality of first pixel values and the second pixel values, respectively.
[0165] The determining module 740 is used to determine the second defect region as the defect detection result corresponding to the detection image when the image parameters of the second defect region in the pixel comparison image meet the preset defect conditions. The defect detection result is used to indicate that the second defect region is the region corresponding to the defect part in the detection image.
[0166] Optionally, the plurality of first pixel values includes the i-th first pixel value corresponding to the i-th first pixel point, where i is a positive integer;
[0167] The generation module 730 is used to obtain the pixel value difference between the i-th first pixel value and the second pixel value as the i-th pixel difference; and to generate the pixel comparison map based on the pixel differences corresponding to the plurality of first pixel values respectively.
[0168] Optionally, the detected image is a color image, and the i-th first pixel value includes the i-th first sub-value, the i-th second sub-value, and the i-th third sub-value;
[0169] The generation module 730 is configured to obtain the pixel value difference between the i-th first sub-value and the second pixel value as the i-th first difference; obtain the pixel value difference between the i-th second sub-value and the second pixel value as the i-th second difference; obtain the pixel value difference between the i-th third sub-value and the second pixel value as the i-th third difference; and obtain the i-th pixel difference based on the i-th first difference, the i-th second difference, and the i-th third difference.
[0170] Optionally, the generation module 730 is configured to: obtain a first weight value, a second weight value, and a third weight value; obtain the i-th first product result between the first weight value and the i-th first difference; obtain the i-th second product result between the second weight value and the i-th second difference; obtain the i-th third product result between the third weight value and the i-th third difference; obtain the i-th third pixel value corresponding to the i-th first pixel based on the sum of the i-th first product result, the i-th second product result, and the i-th third product result; generate a defect comparison image based on the third pixel values corresponding to the plurality of first pixels; and, if the image parameters of the second defect region in the defect comparison image meet the preset defect conditions, use the second defect region as the defect detection result corresponding to the detection image.
[0171] Optionally, the preset defect conditions include at least one of a contrast threshold, a pixel count threshold, or an aspect ratio threshold;
[0172] The generation module 730 is configured to determine that the second defect region meets the preset defect conditions when the contrast of the pixels in the second defect region reaches the contrast threshold; and / or, when the number of pixels in the second defect region reaches the number of pixels threshold; and / or, when the ratio between the length and width of the second defect region reaches the aspect ratio threshold.
[0173] Optionally, the acquisition module 710 is used to acquire a first sample image, wherein the first sample image includes a first sample defect portion;
[0174] The defective part of the first sample is labeled to obtain the defect label corresponding to the first sample image. The defect label is used to indicate the position and defect features of the defective part of the first sample in the first sample image.
[0175] A first random value is generated based on the aforementioned defect characteristics;
[0176] A second sample image is generated based on the first random value. The second sample image includes a second sample defect portion, which is randomly generated based on the first random value.
[0177] The sample detection model is trained using gradients based on the first sample image, the defect label, and the second sample image to obtain the defect detection model.
[0178] The defect detection apparatus provided in this application performs defect detection on a detection image using a pre-trained defect detection model to obtain a first defect region in the detection image. A pixel comparison map of the first defect region is generated based on the difference between the first pixel value of a pixel in the first defect region and the second pixel value in a reference region of the detection image. The pixel comparison map is then used to further determine a second defect region containing a defective portion within the first defect region, which serves as the defect detection result for the detection image. In other words, after performing preliminary defect detection on the detection image using the defect detection model to obtain a preliminary detection result, a pixel comparison map is generated based on the difference between the pixel values in the preliminary detection result and the reference pixel values. This further reduces noise data in the first defect region, enabling further defect detection of the first defect region and resulting in a more accurate final defect detection result.
[0179] See Figure 8 This illustration shows a schematic diagram of the structure of a computer device provided in an embodiment of this application. Figure 8 As shown, the computer device 1000 of this embodiment includes: at least one processor 1010 ( Figure 8 (Only one is shown in the image) a processor, a memory 1020, and a computer program 1021 stored in the memory 1020 and capable of running on at least one processor 1010. When the processor 1010 executes the computer program 1021, it implements the steps in the above-described defect detection method embodiments.
[0180] Computer device 1000 can be a desktop computer, laptop, handheld computer, cloud server, or other computing device. This terminal device may include, but is not limited to, processor 1010 and memory 1020. Those skilled in the art will understand that... Figure 8This is merely an example of computer device 1000 and does not constitute a limitation on computer device 1000. It may include more or fewer components than shown in the figure, or combine certain components, or different components, such as input / output devices, network access devices, etc.
[0181] The processor 1010 may be a Central Processing Unit (CPU), or it may be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.
[0182] In some embodiments, memory 1020 may be an internal storage unit of computer device 1000, such as a hard disk or memory of computer device 1000. In other embodiments, memory 1020 may be an external storage device of computer device 1000, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., provided on computer device 1000. Furthermore, memory 1020 may include both internal and external storage units of computer device 1000. Memory 1020 is used to store operating systems, applications, boot loaders, data, and other programs, such as program code for computer programs. Memory 1020 may also be used to temporarily store data that has been output or will be output.
[0183] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0184] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0185] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0186] In the embodiments provided in this application, it should be understood that the disclosed apparatus / computer devices and methods can be implemented in other ways. For example, the apparatus / computer device embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0187] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0188] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0189] If an integrated module / unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying computer program code, recording media, USB flash drives, swivel hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium can be appropriately added or removed according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable medium does not include electrical carrier signals and telecommunication signals.
[0190] The implementation of all or part of the processes in the methods of the above embodiments can also be accomplished by a computer program product. When the computer program product is run on a computer device, the computer device can implement the steps in the various method embodiments described above.
[0191] The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A defect detection method, characterized in that, The method includes: Acquire the detection image; The detection image is subjected to defect detection by a pre-trained defect detection model to obtain a first defect region corresponding to the detection image. The first defect region includes the region corresponding to the defect part in the detection image. The defect detection model is a neural network model. Multiple first pixels in the first defect region correspond to first pixel values respectively. The second pixel value in the reference region of the detected image is obtained. The reference region refers to the region corresponding to a specified position in the first defect region. Multiple second pixels in the reference region correspond to candidate pixel values. The second pixel value is obtained based on the sorting result of multiple candidate pixel values. A pixel comparison map corresponding to the first defect area is generated based on the pixel differences between multiple first pixel values and the second pixel values. If the image parameters of the second defect region in the pixel comparison image meet the preset defect conditions, the second defect region is used as the defect detection result corresponding to the detection image. The defect detection result is used to indicate that the second defect region is the region corresponding to the defect part in the detection image.
2. The method according to claim 1, characterized in that, The plurality of first pixel values includes the i-th first pixel value corresponding to the i-th first pixel point, where i is a positive integer; The step of generating a pixel comparison map corresponding to the first defect region based on the pixel differences between multiple first pixel values and the second pixel values includes: Obtain the pixel value difference between the i-th first pixel value and the second pixel value, and use it as the i-th pixel difference; The pixel comparison map is generated based on the pixel differences corresponding to the plurality of first pixel values.
3. The method according to claim 2, characterized in that, The detected image is a color image, and the i-th first pixel value includes the i-th first sub-value, the i-th second sub-value, and the i-th third sub-value; The step of obtaining the pixel value difference between the i-th first pixel value and the second pixel value as the i-th pixel difference includes: Obtain the pixel value difference between the i-th first sub-value and the second pixel value, and use it as the i-th first difference value; Obtain the pixel value difference between the i-th second sub-value and the second pixel value, and use it as the i-th second difference value; Obtain the pixel value difference between the i-th third sub-value and the second pixel value, and use it as the i-th third difference value; The i-th pixel difference is obtained based on the i-th first difference, the i-th second difference, and the i-th third difference.
4. The method according to claim 3, characterized in that, After generating the pixel comparison map based on the pixel differences corresponding to the plurality of first pixel values, the method further includes: Obtain the first weight value, the second weight value, and the third weight value; Obtain the i-th first product result between the first weight value and the i-th first difference; Obtain the i-th second product result between the second weight value and the i-th second difference; Obtain the third product result between the third weight value and the i-th third difference; Based on the sum of the i-th first product result, the i-th second product result, and the i-th third product result, the i-th third pixel value corresponding to the i-th first pixel is obtained; A defect comparison image is generated based on the third pixel values corresponding to the plurality of first pixel points; When the image parameters of the second defect region in the pixel comparison image meet the preset defect conditions, the second defect region is taken as the defect detection result corresponding to the detection image, including: If the image parameters of the second defect region in the defect comparison image meet the preset defect conditions, the second defect region is taken as the defect detection result corresponding to the detection image.
5. The method according to any one of claims 1 to 4, characterized in that, The preset defect conditions include at least one of a contrast threshold, a pixel count threshold, or an aspect ratio threshold. Before using the second defect region as the defect detection result corresponding to the detection image, the method further includes: If the contrast of pixels in the second defect region reaches the contrast threshold, it is determined that the second defect region meets the preset defect condition; and / or; If the number of pixels in the second defect region reaches the pixel number threshold, the second defect region is determined to meet the preset defect condition; and / or; If the ratio between the length and width of the second defect region reaches the aspect ratio threshold, the second defect region is determined to meet the preset defect condition.
6. The method according to any one of claims 1 to 4, characterized in that, Before performing defect detection on the detected image using a pre-trained defect detection model to obtain the first defect region corresponding to the detected image, the method further includes: Obtain a first sample image, wherein the first sample image includes a defective portion of the first sample; The defective part of the first sample is labeled to obtain the defect label corresponding to the first sample image. The defect label is used to indicate the position and defect features of the defective part of the first sample in the first sample image. A first random value is generated based on the aforementioned defect characteristics; A second sample image is generated based on the first random value. The second sample image includes a second defect portion, which is randomly generated based on the first random value. The defect detection model is obtained by gradient training of the sample detection model based on the first sample image and the second sample image.
7. A defect detection device, characterized in that, The device includes: The acquisition module is used to acquire the detection image; The detection module is used to perform defect detection on the detection image using a pre-trained defect detection model to obtain a first defect region corresponding to the detection image. The first defect region includes the region corresponding to the defective part in the detection image. The defect detection model is a neural network model, and multiple first pixels in the first defect region correspond to first pixel values respectively. The acquisition module is used to acquire the second pixel value in the reference region of the detection image. The reference region refers to the region corresponding to a specified position in the first defect region. Multiple second pixel points in the reference region correspond to candidate pixel values respectively. The second pixel value is obtained based on the sorting result of multiple candidate pixel values. The generation module is used to generate a pixel comparison map corresponding to the first defect area based on the pixel differences between multiple first pixel values and the second pixel values respectively. The determination module is used to determine the second defect region as the defect detection result corresponding to the detection image when the image parameters of the second defect region in the pixel comparison image meet the preset defect conditions. The defect detection result is used to indicate that the second defect region is the region corresponding to the defect part in the detection image.
8. A computer device, characterized in that, The computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the defect detection method as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the defect detection method as described in any one of claims 1 to 6.
10. A computer program product, characterized in that, Includes a computer program, which, when run, causes the defect detection method as described in any one of claims 1 to 6 to be performed.
Citation Information
Patent Citations
Defect region detection method and device
CN106097361A
Image detection method and apparatus, electronic device, and storage medium
WO2025139960A1