Defect detection method and defect detection device

By acquiring the pixel grayscale range in image detection and enhancing the image, the problem of low detection accuracy of shallow defects in the prior art is solved, and higher detection accuracy and lower missed detection error rate are achieved.

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

Patent Information

Application Number
CN202510187368.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-20
Publication Date
2025-06-03

AI Technical Summary

Technical Problem

When detecting shallow defects, it is difficult to set an accurate grayscale threshold, which leads to difficulty in accurately detecting, and there are problems of missed and missed detection, and the detection accuracy is low.

Method used

By acquiring the pixel grayscale range of defects to be detected in the image to be detected, at least some pixel points are enhanced to improve image quality and reduce the difficulty of setting the grayscale threshold, thereby reducing missed detection and misdetection and improving detection accuracy.

Benefits of technology

It effectively reduces the difficulty of defect detection, reduces missed and missed detection, improves detection accuracy, and enhances the contrast and clarity of the image.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120088225A_ABST
    Figure CN120088225A_ABST
Patent Text Reader

Abstract

The invention discloses a defect detection method and a defect detection device, and belongs to the technical field of defect detection. The defect detection method comprises the following steps: acquiring a pixel gray scale range corresponding to a defect to be detected in an image to be detected; based on the pixel gray scale range, carrying out image enhancement on at least part of pixel points in the to-be-detected image to obtain a first to-be-detected image; and performing defect detection on the first to-be-detected image to obtain defect information corresponding to the first to-be-detected image. According to the defect detection method, on the basis of ensuring the accuracy of the gray threshold, the setting difficulty of the gray threshold is effectively reduced, so that the defect detection difficulty is reduced, missing detection and false detection are reduced, and the detection accuracy is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the technical field of defect detection, and particularly relates to a defect detection method and a defect detection device. Background Art

[0002] In the field of visual inspection, small and low-contrast shallow defects affect the detection performance. In related technologies, mainly through the method of detecting by gray-scale threshold, the image is divided into foreground and background. However, in the scenario of detecting shallow defects, it is difficult to accurately detect shallow defects by the above detection method, and there are problems of missed detection and false detection, and the detection accuracy is low. 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 defect detection method and a defect detection device, which can effectively reduce the difficulty of setting the gray-scale threshold on the basis of ensuring the accuracy of the gray-scale threshold, thereby reducing the difficulty of defect detection, reducing missed detection and false detection, and improving the detection accuracy.

[0004] In a first aspect, this application provides a defect detection method, which includes:

[0005] Obtain the pixel gray-scale range corresponding to the defect to be detected in the image to be detected;

[0006] Based on the pixel gray-scale range, perform image enhancement on at least some pixel points in the image to be detected to obtain a first image to be detected;

[0007] Perform defect detection on the first image to be detected to obtain defect information corresponding to the first image to be detected.

[0008] According to the defect detection method of this application, by obtaining the pixel gray-scale range corresponding to the defect to be detected in the image to be detected, performing image enhancement on at least some pixel points in the image to be detected, a first image to be detected with an obvious difference degree between the pixel region where at least some pixel points are located and other pixel regions in the image to be detected is obtained, the image quality of the first image to be detected is improved, the difficulty of setting the gray-scale threshold is effectively reduced on the basis of ensuring the accuracy of the gray-scale threshold, thereby reducing the difficulty of defect detection, reducing missed detection and false detection, and improving the detection accuracy.

[0009] According to the defect detection method of this application, the step of performing image enhancement on at least some pixel points in the image to be detected based on the pixel gray-scale range to obtain a first image to be detected includes:

[0010] Based on the pixel gray-scale range, determine a target gray-scale mapping function;

[0011] Based on the target gray-scale mapping function, perform image enhancement on at least some of the pixel points in the image to be detected, and obtain the first image to be detected.

[0012] According to the defect detection method of the present application, the target gray-scale mapping function includes: a first gray-scale mapping function. Determining the target gray-scale mapping function based on the pixel gray-scale range includes:

[0013] When the pixel gray-scale range can be obtained, determine that the target gray-scale mapping function is the first gray-scale mapping function; the first gray-scale mapping function is constructed based on a preset gray value and a preset enhanced gray value, and the preset gray value and the preset enhanced gray value are determined based on the pixel gray-scale range.

[0014] According to the defect detection method of the present application, the target gray-scale mapping function includes: a second gray-scale mapping function. Determining the target gray-scale mapping function based on the pixel gray-scale range includes:

[0015] When the pixel gray-scale range cannot be obtained, determine that the target gray-scale mapping function is the second gray-scale mapping function; the second gray-scale mapping function is constructed based on the background gray value corresponding to the image to be detected, the noise gray value corresponding to the image to be detected, and a preset enhancement intensity.

[0016] According to the defect detection method of the present application, performing defect detection on the first image to be detected to obtain defect information corresponding to the first image to be detected includes:

[0017] Perform defect detection on the first image to be detected based on at least one gray-scale defect threshold, and obtain defect information corresponding to the first image to be detected.

[0018] According to the defect detection method of the present application, performing defect detection on the first image to be detected based on at least one gray-scale defect threshold to obtain defect information corresponding to the first image to be detected includes:

[0019] Perform statistical analysis on the image to be detected to obtain a template image corresponding to the image to be detected;

[0020] Perform a difference operation on the template image and the first image to be detected to obtain a target defect area in the first image to be detected;

[0021] Perform defect detection on the target defect area based on the at least one gray-scale defect threshold, and obtain defect information corresponding to the target defect area.

[0022] According to the defect detection method of the present application, before performing image enhancement on at least some pixel points in the to-be-detected image based on the pixel gray-scale range to obtain a first to-be-detected image, the method further includes:

[0023] Obtain an initial detection image;

[0024] Perform image preprocessing on the initial detection image to obtain the to-be-detected image.

[0025] In a second aspect, the present application provides a defect detection device, which includes:

[0026] A first processing module, configured to obtain the pixel gray-scale range corresponding to the to-be-detected defect in the to-be-detected image;

[0027] A second processing module, configured to perform image enhancement on at least some pixel points in the to-be-detected image based on the pixel gray-scale range to obtain a first to-be-detected image;

[0028] A third processing module, configured to perform defect detection on the first to-be-detected image to obtain the defect information corresponding to the first to-be-detected image.

[0029] According to the defect detection device of the present application, by obtaining the pixel gray-scale range corresponding to the to-be-detected defect in the to-be-detected image, performing image enhancement on at least some pixel points in the to-be-detected image, and obtaining a first to-be-detected image in which the difference degree between the pixel region where at least some pixel points are located and other pixel regions in the to-be-detected image is obvious, the image quality of the first to-be-detected image is improved. On the basis of ensuring the accuracy of the gray-scale threshold, the difficulty of setting the gray-scale threshold is effectively reduced, thereby reducing the difficulty of defect detection, reducing missed detections and false detections, and improving the detection accuracy.

[0030] In a third aspect, the present application provides an electronic 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 detection method described in the first aspect above is implemented.

[0031] 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 detection method described in the first aspect above is implemented.

[0032] In a fifth aspect, the present application provides a computer program product, including a computer program. When the computer program is executed by a processor, the defect detection method described in the first aspect above is implemented.

[0033] One or more of the above technical solutions in the embodiments of the present application have at least one of the following technical effects:

[0034] By acquiring the pixel grayscale range corresponding to the defect to be detected in the image to be detected, image enhancement is performed on at least some of the pixels in the image to be detected, and a first image to be detected is obtained in which the pixel area where at least some of the pixels are located is obviously different from other pixel areas in the image to be detected, thereby improving the image quality of the first image to be detected, and effectively reducing the difficulty of setting the grayscale threshold while ensuring the accuracy of the grayscale threshold, thereby reducing the difficulty of defect detection, reducing missed detections and false detections, and improving detection accuracy.

[0035] Furthermore, by determining the grayscale range of pixels that can be acquired and automatically constructing a first grayscale mapping function based on preset grayscale values ​​and preset enhanced grayscale values ​​to perform image enhancement on at least some pixels, it is possible to specifically construct a first grayscale mapping function suitable for the image to be detected based on the actual situation of the defect to be detected, without the need to perform image enhancement on pixel areas that do not need to be enhanced in the area to be detected, thereby improving the accuracy and efficiency of image enhancement, enhancing the available rows of the first image to be detected, and reducing the difficulty of detecting the defect to be detected.

[0036] Furthermore, by determining that the pixel grayscale range cannot be obtained, a second grayscale mapping function that can automatically improve the contrast is selected, and at least part of the pixels that need to be enhanced in the image to be detected are enhanced, thereby improving the image quality of the first image to be detected, and there is no need to perform image enhancement on the background and noise, thereby improving the efficiency of image enhancement. In addition, the second grayscale mapping function can expand the use scenarios of image enhancement, without having to pay attention to the pixel characteristics of the defects to be detected in advance, and has a wide range of applications.

[0037] Furthermore, by performing statistical analysis on the image to be detected, a template image corresponding to the image to be detected is obtained, and based on the difference between the template image and the image to be detected, the target defect area is determined. Defect detection is performed on the target defect area through one or more grayscale defect thresholds, effectively reducing the area for defect detection and improving detection efficiency.

[0038] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the description of the embodiments in conjunction with the following drawings, in which:

[0040] Figure 1 It is a flowchart of a defect detection method provided in an embodiment of the present application;

[0041] Figure 2 This is one of the principle schematic diagrams of the defect detection method provided in the embodiment of the present application;

[0042] Figure 3 It is the second schematic diagram of the principle of the defect detection method provided by the embodiment of the present application;

[0043] Figure 4 It is the structural schematic diagram of the defect detection device provided by the embodiment of the present application;

[0044] Figure 5 It is the structural schematic diagram of the electronic device provided by the embodiment of the present application. Detailed implementation manners

[0045] 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.

[0046] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, rather than to describe a specific order or sequence. It should be understood that such used data can be interchanged under appropriate circumstances so that the embodiments of the present application can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first", "second", etc. generally belong to the same category, and the number of objects is not limited. For example, the first object can be one or multiple. In addition, "and / or" in the specification and claims means at least one of the connected objects, and the character " / " generally means an "or" relationship between the associated objects before and after.

[0047] Next, in conjunction with the accompanying drawings, the defect detection method, defect detection device, electronic device, and readable storage medium provided by the embodiments of the present application will be described in detail through specific embodiments and their application scenarios.

[0048] Among them, the defect detection method can be applied to a terminal, and specifically can be executed by hardware or software in the terminal.

[0049] The terminal includes, but is not limited to, portable communication devices such as mobile phones or tablet computers. It should also be understood that in some embodiments, the terminal may not be a portable communication device, but a desktop computer.

[0050] In the following various embodiments, a terminal including a display and a touch-sensitive surface is described. However, it should be understood that the terminal may include one or more other physical user interface devices such as a physical keyboard, a mouse, and a joystick.

[0051] The defect detection method provided in the embodiment of the present application may be executed by an electronic device or a functional module or functional entity in the electronic device that can implement the defect detection method. The electronic devices mentioned in the embodiment of the present application include but are not limited to mobile phones, tablet computers, computers, cameras, and wearable devices. The defect detection method provided in the embodiment of the present application is described below using the electronic device as an example of the execution subject.

[0052] like Figure 1 As shown, the defect detection method includes: step 110, step 120 and step 130.

[0053] Step 110, obtaining a pixel grayscale range corresponding to a defect to be detected in the image to be detected;

[0054] In this step, the image to be inspected is a captured image of the object to be inspected that needs to be inspected for defects.

[0055] The objects to be detected can be items in different industrial scenarios.

[0056] For example, in the metal industry scenario, the objects to be inspected may be automotive parts, aerospace components, and precision machinery parts.

[0057] For example, in the electronic product industry scenario, the objects to be inspected may be printed circuit boards, integrated circuit chips, and connectors.

[0058] The image to be detected can be acquired by an image sensor.

[0059] The defect to be detected is a pixel region in which the object to be detected shown in the image to be detected has a defect.

[0060] The defect to be detected may be a shallow defect with low contrast.

[0061] Defects to be detected may include: bright defects and dark defects.

[0062] Bright defects are defects with a brightness higher than the background but a small contrast with the background.

[0063] A dark defect is a defect whose brightness is lower than that of the background but whose contrast with the background is small.

[0064] The pixel grayscale range is the range in which the pixel grayscale value of the defect to be detected can be obtained.

[0065] The pixel grayscale range may be known or unknown, that is, the pixel grayscale range corresponding to the defect to be detected in the image to be detected may be obtained, or the pixel grayscale range corresponding to the defect to be detected in the image to be detected may not be obtained.

[0066] In the actual execution process, when the user detects detection objects of the same type as the detection object to be detected, the user can obtain the prior knowledge of the defect to be detected in the image to be detected based on the gray value of the defect in the image that has undergone defect detection. The user can determine the pixel gray range corresponding to the defect to be detected in the image to be detected through the prior knowledge.

[0067] In some embodiments, the pixel gray range corresponding to the defect to be detected in the image to be detected input by the user can be received.

[0068] When the user inputs the pixel gray range, the pixel gray range corresponding to the defect to be detected in the image to be detected can be obtained. When the user does not input the pixel gray range, the pixel gray range corresponding to the defect to be detected in the image to be detected cannot be obtained.

[0069] In some other embodiments, a database storing the pixel gray ranges corresponding to the defects of different types of detection objects to be detected can be constructed, and the pixel gray range corresponding to the defect to be detected in the image to be detected can be obtained from the database.

[0070] In the actual execution process, the category of the detection object to be detected in the image to be detected can be determined by recognizing the image to be detected. Based on the category of the detection object to be detected, the pixel gray range corresponding to the defect to be detected in the image to be detected can be retrieved from the database.

[0071] When the pixel gray range corresponding to the defect to be detected in the image to be detected can be retrieved from the database, the pixel gray range corresponding to the defect to be detected in the image to be detected can be obtained.

[0072] When the pixel gray range corresponding to the defect to be detected in the image to be detected cannot be retrieved from the database, the pixel gray range corresponding to the defect to be detected in the image to be detected cannot be obtained.

[0073] Step 120: Based on the pixel gray range, perform image enhancement on at least some pixel points in the image to be detected to obtain a first image to be detected;

[0074] In this step, at least some pixel points are the pixel points in the image to be detected that need to be enhanced.

[0075] At least some pixel points may be the pixel points corresponding to the defect to be detected or the pixel points corresponding to the background.

[0076] Image enhancement is an operation to enhance the gray value of at least some pixel points to improve the contrast between at least some pixel points and the background.

[0077] The first image to be detected is an image highlighting at least some pixel points in the image to be detected.

[0078] In the actual execution process, after obtaining the actual values of the pixel gray-scale range, the gray-scale values of at least some of the pixel points in the image to be detected whose gray-scale values are within the pixel gray-scale range can be increased. For example, the gray-scale values of at least some of the pixel points are increased by 20 or increased by 30 to obtain the first image to be detected.

[0079] In the actual execution process, in the case where the actual values of the pixel gray-scale range cannot be obtained, the contrast of at least some of the pixel points in the image to be detected can be enhanced by means such as linear stretching and histogram equalization to obtain the first image to be detected.

[0080] In the actual execution process, the image enhancement of at least some of the pixel points in the image to be detected can also be performed by means of the enhancement of the generative adversarial network to obtain the first image to be detected.

[0081] Step 130: Perform defect detection on the first image to be detected to obtain defect information corresponding to the first image to be detected.

[0082] In this step, the defect information is whether there are defects in the image to be detected.

[0083] In the case where there are defects in the image to be detected, the defect information may further include the defect category. For example, the defect is a shallow defect, or the defect is a dark defect, etc.

[0084] In the actual execution process, after obtaining the first image to be detected, the first image to be detected can be recognized by an image recognition algorithm to obtain the defect information in the first image to be detected.

[0085] The image recognition model can be a neural network model, a machine learning model, an artificial intelligence model, etc.

[0086] The specific selection of the image recognition model can be determined based on the actual situation, and the present application does not make any limitations.

[0087] The inventors found in the R & D process that in the related art, the image is mainly divided into foreground and background by the method of gray-scale threshold detection; however, in the above detection method, in the scenario of detecting shallow defects, it is difficult to set an accurate gray-scale threshold, making it difficult to accurately detect shallow defects, and there are problems of missed detection and false detection.

[0088] In this application, based on the situation of the pixel gray-scale range corresponding to the defect to be detected in the image to be detected, image enhancement is performed on at least some of the pixel points in the image to be detected, so as to improve the contrast between the pixel regions where at least some of the pixel points are located and other pixel regions in the image to be detected, increase the difference degree between the pixel regions where at least some of the pixel points are located and other pixel regions, make the gray-scale values of bright defects higher than the flat-field value even higher, and the gray-scale values of dark defects lower, improve the image quality of the obtained first image to be detected, reduce the difficulty of setting an accurate gray-scale threshold, and accurately identify the defect information corresponding to the first image to be detected by performing defect detection on the first image to be detected, thereby reducing the missed detection and false detection of defects.

[0089] According to the defect detection method of this application, by obtaining the pixel gray-scale range corresponding to the defect to be detected in the image to be detected, image enhancement is performed on at least some of the pixel points in the image to be detected, and a first image to be detected with an obvious difference degree between the pixel regions where at least some of the pixel points are located and other pixel regions in the image to be detected is obtained, the image quality of the first image to be detected is improved, and on the basis of ensuring the accuracy of the gray-scale threshold, the difficulty of setting the gray-scale threshold is effectively reduced, thereby reducing the difficulty of defect detection, reducing missed detection and false detection, and improving the detection accuracy.

[0090] In some embodiments, step 120 may further include:

[0091] Based on the pixel gray-scale range, determine the target gray-scale mapping function;

[0092] Based on the target gray-scale mapping function, perform image enhancement on at least some of the pixel points in the image to be detected to obtain the first image to be detected.

[0093] In this embodiment, the target gray-scale mapping function is a mapping function used to redistribute the gray-scale values of at least some of the pixel points to enhance the image details of at least some of the pixel points.

[0094] The target gray-scale mapping function may include: a linear mapping function, a non-linear mapping function, a gamma transformation mapping function, and a kernel function mapping transformation function.

[0095] The specific selection of the target gray-scale mapping function can be determined based on the actual situation, and this application does not make any limitations.

[0096] In the actual execution process, based on one or more of the characteristics of the image to be detected and the actual enhancement requirements, different target gray-scale mapping functions are selected to perform image enhancement on at least some of the pixel points in the image to be detected.

[0097] For example, in the case where it is necessary to enhance the gray-scale value of the image to be detected according to a fixed ratio, the linear mapping function can be used to perform image enhancement on at least some of the pixel points in the image to be detected to obtain the first image to be detected.

[0098] For another example, in a case where a more complex transformation needs to be performed on the image to be detected to enhance the image to be detected, at least some pixel points in the image to be detected can be enhanced by a non-linear mapping function, such as a logarithmic function or an exponential function, to obtain a first image to be detected.

[0099] During the actual execution process, different target gray-scale mapping functions can be selected based on the actual situation of the obtained pixel gray-scale range. Through the target gray-scale mapping function, at least some pixel points in the image to be detected are enhanced to increase the contrast between at least some pixel points and the background, thereby obtaining a first image to be detected.

[0100] According to the defect detection method provided by the embodiments of the present application, by determining the target gray-scale mapping function for image enhancement based on the actual situation of the pixel gray-scale range, and enhancing at least some pixel points in the image to be detected through the target gray-scale mapping function, the change in the gray-scale value of at least some pixel points in the image to be detected can be precisely controlled, the contrast between at least some pixel points and the background in the obtained first image to be detected can be increased, and the clarity of the image can be improved. Moreover, by enhancing at least some pixel points in the image to be detected through the gray-scale mapping function, the calculation process is simple, the image enhancement efficiency is improved, and the calculation cost is reduced.

[0101] In some embodiments, the target gray-scale mapping function includes: a first gray-scale mapping function. Based on the pixel gray-scale range, the target gray-scale mapping function is determined, and it may further include:

[0102] When the pixel gray-scale range can be obtained, the target gray-scale mapping function is determined to be the first gray-scale mapping function. The first gray-scale mapping function is constructed based on a preset gray-scale value and a preset enhanced gray-scale value, and the preset gray-scale value and the preset enhanced gray-scale value are determined based on the pixel gray-scale range.

[0103] In this embodiment,

[0104] The first gray-scale mapping function is a mapping function that can independently enhance the gray-scale value corresponding to the defect to be detected without enhancing other pixel regions other than the defect to be detected.

[0105] Other pixel regions are regions in the image to be detected other than the pixel region where the defect to be detected is located.

[0106] Other pixel regions may include a background region, or a pixel region with a high contrast defect region, etc., which do not require image enhancement.

[0107] The first gray-scale mapping function is constructed based on a preset gray-scale value and a preset enhanced gray-scale value.

[0108] The preset gray value and the preset enhanced gray value are determined based on the pixel gray range.

[0109] The preset gray value and the preset enhanced gray value can be determined based on user-defined settings or based on the actual situation, which is not limited in this application.

[0110] The preset gray value is the gray value corresponding to the defect to be detected.

[0111] The preset enhanced gray value is the gray value after enhancing the preset gray value.

[0112] For example, when the possible pixel gray range of the defect to be detected is 150 - 200, the preset gray value can be 175, and the preset enhanced gray value can be 200.

[0113] During the actual execution process, after obtaining the preset gray value and the preset enhanced gray value, the first gray mapping function can be constructed based on the following formula:

[0114] Xe = Yp + d 2

[0115] Xs = Yp - d 1

[0116]

[0117] Where, Xs is the starting gray value; Xe is the ending gray value; d 1 is the first empirical value; d 2 is the second empirical value; Xp is the preset gray value; Yp is the enhanced preset gray value.

[0118] The starting gray value is the starting gray value for enhancing the defect to be detected.

[0119] The starting gray value can include: the starting gray value corresponding to a bright defect and the starting gray value corresponding to a dark defect.

[0120] The ending gray value is the gray value at which to stop enhancing the defect to be detected.

[0121] The ending gray value can include: the ending gray value corresponding to a bright defect and the ending gray value corresponding to a bright defect.

[0122] The first empirical value and the second empirical value are empirical values determined based on multiple experiments to keep the first gray mapping function monotonically increasing.

[0123] The second empirical value can be a fixed value. The specific selection of the second empirical value can be determined based on experiments. For example, the second empirical value can be 5 or 10, etc., which is not limited in this application.

[0124] Taking the second empirical value as 5 as an example, the construction method of the first gray mapping function corresponding to the bright defect will be described below.

[0125] Based on the pixel gray range corresponding to the bright defect, select a suitable preset gray value and a preset enhanced gray value.

[0126] After determining the second empirical value, the preset gray value, and the preset enhanced gray value, substitute the second empirical value, the preset gray value, and the preset enhanced gray value into to obtain the first empirical value.

[0127] Substitute the preset enhanced gray value and the first empirical value into Xs = Yp - d 1 to obtain the starting gray value corresponding to the bright defect.

[0128] Substitute the preset enhanced gray value and the second empirical value into Xe = Yp + d 2 to obtain the ending gray value corresponding to the bright defect.

[0129] Determine the first coordinate position based on the starting gray value corresponding to the bright defect, that is, the coordinate point where both the abscissa and the ordinate are the starting gray value.

[0130] Determine the second coordinate position based on the ending gray value corresponding to the bright defect, that is, the coordinate point where both the abscissa and the ordinate are the ending gray value.

[0131] Determine the third coordinate position based on the preset gray value and the preset enhanced gray value, that is, the coordinate point where the abscissa is the preset gray value and the ordinate is the preset enhanced gray value.

[0132] Based on the first coordinate position and the third coordinate position, the first broken line can be determined, that is, the broken line corresponding to Xs to Xp in the gray mapping function as Figure 2 shown.

[0133] Based on the second coordinate position and the third coordinate position, the second broken line can be determined, that is, the broken line corresponding to Xp to Xe in the gray mapping function as Figure 2 shown.

[0134] In the actual execution process, the gray value corresponding to the bright defect can be image-enhanced through the first broken line and the second broken line, that is, when the gray value corresponding to at least some pixel points is between the starting gray value corresponding to the bright defect and the ending gray value corresponding to the bright defect, the gray value corresponding to at least some pixel points can be enhanced through the first broken line and the second broken line.

[0135] Similarly, based on the same method, a first gray-scale mapping function corresponding to the dark defect can be constructed. To avoid repetition, it will not be elaborated here. During the actual execution process, when the pixel gray-scale range can be obtained, appropriate preset gray-scale values and preset enhanced gray-scale values can be determined based on the pixel gray-scale range, and the first gray-scale mapping function can be automatically generated. At least some pixel points in the image to be detected are enhanced through the first gray-scale mapping function.

[0136] During the actual execution process, the preset gray-scale value and the preset enhanced gray-scale value input by the user can be received. Additionally, based on the obtained pixel gray-scale range, the image to be detected and the pixel gray-scale range can be analyzed through an algorithm to select appropriate preset gray-scale values and preset enhanced gray-scale values to obtain the preset gray-scale value and the preset enhanced gray-scale value.

[0137] It should be noted that different preset gray-scale values and preset enhanced gray-scale values may generate different first gray-scale mapping functions.

[0138] According to the defect detection method provided by the embodiments of the present application, by determining that the pixel gray-scale range can be obtained, and at least some pixel points are enhanced through the first gray-scale mapping function automatically constructed based on the preset gray-scale value and the preset enhanced gray-scale value, a first gray-scale mapping function suitable for the image to be detected can be specifically constructed based on the actual situation of the defect to be detected. There is no need to enhance the pixel area that does not need to be enhanced in the area to be detected, improving the accuracy and efficiency of image enhancement, enhancing the usability of the first image to be detected, and reducing the detection difficulty of the defect to be detected.

[0139] In some embodiments, the target gray-scale mapping function includes: a second gray-scale mapping function. Based on the pixel gray-scale range, determining the target gray-scale mapping function includes:

[0140] In the case where the pixel gray-scale range cannot be obtained, the target gray-scale mapping function is determined to be the second gray-scale mapping function; the second gray-scale mapping function is constructed based on the background gray-scale value corresponding to the image to be detected, the noise gray-scale value corresponding to the image to be detected, and the preset enhancement intensity. In this embodiment, the second gray-scale mapping function is a mapping function for enhancing at least some pixel points in the image to be detected except for the relevant pixel area determined based on the background gray-scale value and the noise gray-scale value.

[0141] The relevant pixel area determined based on the background gray-scale value and the noise gray-scale value can be the pixel area determined based on the first gray-scale value and the second gray-scale value.

[0142] The first gray-scale value can be obtained by taking the difference between the background gray-scale value and the noise gray-scale value.

[0143] The second gray-scale value can be obtained by adding the background gray-scale value and the noise gray-scale value.

[0144] In the actual execution process, the second gray-scale mapping function can be constructed based on the following formula:

[0145]

[0146] where x is the gray value; tanK is the preset enhancement intensity; x bg is the background gray value corresponding to the image to be detected; x noise is the noise gray value corresponding to the image to be detected.

[0147] The preset enhancement intensity can be determined according to the actual situation. For example, K can be set to 20 degrees or 30 degrees, etc. This application does not make any limitations.

[0148] In the actual execution process, the background gray value corresponding to the image to be detected can be processed into the same pixel range, such as 128 or 130, and the noise gray value corresponding to the image to be detected can be processed into the same pixel range, such as 12 or 15.

[0149] Of course, in the actual execution process, the background gray value corresponding to the image to be detected and the noise gray value corresponding to the image to be detected can also be determined by any other achievable means.

[0150] As Figure 3 shown, K is the angle of inclination based on a straight line with a slope of 1.

[0151] In the actual execution process, based on (tanK + 1) * (x - x bg - x noise ) + x bg + x noise the third broken line with the sum of the background gray value corresponding to the image to be detected and the noise gray value corresponding to the image to be detected as the starting pixel point can be determined, that is, the broken line between the abscissa approaching 150 and the abscissa approaching 200 in the second gray-scale mapping function as Figure 3 shown.

[0152] Based on the coordinate point with the abscissa of X e2 on the third broken line and the coordinate point with the coordinate value of (255, 255) for interpolation, the fourth broken line is obtained. Based on the third broken line and the fourth broken line, the second gray-scale mapping function corresponding to the bright defect can be determined, that is, the broken line between the abscissa approaching 200 and the abscissa approaching 255 in the second gray-scale mapping function as Figure 3 shown.

[0153] Similarly, based on (tanK + 1) * (x - x bg + x noise ) + x bg - x noiseDetermine the fifth broken line of the termination pixel points by taking the difference between the background gray value corresponding to the image to be detected and the noise gray value corresponding to the image to be detected, that is, the broken line between the abscissa approaching 70 and the abscissa approaching 120 in the second gray mapping function as shown in Figure 3 Figure.

[0154] Interpolate based on the coordinate point with abscissa X e1 on the fifth broken line and the coordinate point with coordinate value (0, 0) to obtain the sixth broken line. Based on the fifth broken line and the sixth broken line, the second gray mapping function corresponding to the dark defect can be determined, that is, the broken line between abscissa 0 and the abscissa approaching 70 in the second gray mapping function as shown in Figure 3 Figure.

[0155] It should be noted that the specific values of X e1 and X e2 can be user-defined or determined based on the actual situation, and this application does not make any limitations.

[0156] The second gray mapping function can reduce the influence on the defects to be detected corresponding to gray levels 0 and 255.

[0157] In the actual execution process, in the case where the pixel gray range cannot be obtained, the second gray mapping function can be constructed based on the background gray value corresponding to the image to be detected, the noise gray value corresponding to the image to be detected, and the preset enhancement intensity, and at least some pixel points in the image to be detected are enhanced through the second gray mapping function.

[0158] In the actual execution process, the background gray value corresponding to the image to be detected and the noise gray value corresponding to the image to be detected can be obtained through an image processing tool, and the preset enhancement intensity can be obtained by receiving user input or determined by analyzing the characteristics of the image to be detected.

[0159] According to the defect detection method provided by the embodiments of the present application, by determining that the pixel gray range cannot be obtained, the second gray mapping function that can automatically improve the contrast is selected to enhance at least some pixel points in the image to be detected that need to be enhanced, improving the image quality of the obtained first image to be detected, and there is no need to perform image enhancement on the background and noise, improving the efficiency of image enhancement. In addition, the second gray mapping function can expand the application scenario of image enhancement, without prior attention to the pixel characteristics of the defects to be detected, and has a wide range of applications.

[0160] In some embodiments, based on the target gray mapping function, performing image enhancement on at least some pixel points in the image to be detected to obtain the first image to be detected may further include:

[0161] Based on the target gray mapping function, map the initial gray value corresponding to at least some pixel points in the image to be detected to the target gray value;

[0162] Replace the initial gray values corresponding to at least some of the pixel points with target gray values to perform image enhancement on at least some of the pixel points in the image to be detected, and obtain a first image to be detected.

[0163] In this embodiment, the initial gray value is the actual gray value of the pixel points in the image to be detected.

[0164] The target gray value is the gray value after enhancing the actual gray value. In the actual execution process, through the target gray mapping function, the initial gray values corresponding to at least some of the pixel points in the image to be detected can be mapped to larger target gray values, so as to replace the initial gray values corresponding to at least some of the pixel points with target gray values to enhance at least some of the pixel points.

[0165] When the target gray mapping function is the first gray mapping function, the initial gray values of at least some of the pixel points (at least some of the pixel points are bright defects) can be replaced with larger target gray values, that is, increase the gray values of the pixel points corresponding to the range of the broken line of the first gray mapping function above the proportional function.

[0166] Replace the initial gray values of at least some of the pixel points (at least some of the pixel points are dark defects) with smaller target gray values, that is, reduce the gray values of the pixel points corresponding to the range of the broken line of the first gray mapping function below the proportional function, so as to increase the contrast between the defect to be detected and the background, and obtain a first image to be detected.

[0167] It can be understood that there may be bright defects or dark defects among at least some of the pixel points.

[0168] When at least some of the pixel points in the image to be detected are the pixel points corresponding to bright defects, the gray values corresponding to at least some of the pixel points may increase, that is, the target gray value is greater than the initial gray value.

[0169] When at least some of the pixel points in the image to be detected are the pixel points corresponding to dark defects, the gray values corresponding to at least some of the pixel points may decrease, that is, the target gray value is less than the initial gray value.

[0170] The gray values of the other pixel points in the image to be detected except at least some of the pixel points may remain unchanged, that is, the pixel values of the pixel points in the gray range where the first gray mapping function overlaps with the proportional function remain unchanged.

[0171] Similarly, when the target gray mapping function is the second gray mapping function, each pixel point in the image to be detected can be processed through the second gray mapping function to obtain the target gray value corresponding to the initial gray value of each pixel point.

[0172] The target gray values corresponding to at least some of the pixels in the image to be detected may be greater than the initial gray value, the target gray values corresponding to at least some of the pixels in the image to be detected may also be less than the initial gray value, and the target gray values corresponding to the other pixels in the image to be detected except for at least some of the pixels may be equal to the initial gray value.

[0173] In the actual execution process, after obtaining the target gray values corresponding to at least some of the pixels, the initial gray values of at least some of the pixels are replaced with larger target gray values, and the initial gray values of at least some of the pixels are replaced with smaller target gray values, so as to increase the contrast between the defect to be detected and the background and obtain a first image to be detected.

[0174] According to the defect detection method provided by the embodiments of the present application, through the target gray mapping function, the initial gray values corresponding to at least some of the pixels are effectively mapped to larger target gray values, so that the initial gray values corresponding to at least some of the pixels are replaced with target gray values, increasing the gray values of at least some of the pixels, thereby enhancing the contrast between at least some of the pixels and the background. The image enhancement method is simple, convenient and easy to operate.

[0175] In some embodiments, step 130 may further include:

[0176] Based on at least one gray defect threshold, defect detection is performed on the first image to be detected to obtain defect information corresponding to the first image to be detected.

[0177] In this embodiment, the gray defect threshold is a preset value for identifying defects.

[0178] The gray defect threshold may include: a gray defect threshold for identifying bright defects and a gray defect threshold for identifying dark defects.

[0179] It should be noted that after image enhancement of the image to be detected, the contrast between at least some of the pixels and the background is increased. During the process of setting the gray defect threshold, there is a larger selection range, and the accuracy requirement for the gray defect threshold is reduced.

[0180] In the actual execution process, after obtaining the first image to be detected, defect detection can be performed on the first image to be detected through one or more gray defect thresholds. For example, the bright defects in the first image to be detected are detected through the gray defect threshold for identifying bright defects, and the dark defects in the first image to be detected are detected through the gray defect threshold for identifying dark defects, so as to obtain various defect information in the first image to be detected.

[0181] After obtaining the defects to be detected in the image to be detected, operations such as merging and feature calculation can be further performed on the identified bright defects, and operations such as merging and feature calculation can be performed on the identified dark defects, so that the defects to be detected are more complete and the features are clearer.

[0182] In the actual execution process, the specific features of the defects to be detected can be identified through an image recognition algorithm. For example, the defects to be detected are scratches, holes, wear, etc.

[0183] According to the defect detection method provided by the embodiments of the present application, through one or more gray defect thresholds, the defect area in the first image to be detected is effectively identified, the difficulty of determining the defect area is reduced, so as to identify the defect area, provide the defect information corresponding to the first image to be detected, and perform subsequent correction work based on the defect information, improving the user experience.

[0184] In some embodiments, based on at least one gray defect threshold, performing defect detection on the first image to be detected to obtain the defect information corresponding to the first image to be detected may further include:

[0185] Performing statistical analysis on the image to be detected to obtain a template image corresponding to the image to be detected;

[0186] Performing a difference operation on the template image and the first image to be detected to obtain the target defect area in the first image to be detected;

[0187] Based on at least one gray defect threshold, performing defect detection on the target defect area to obtain the defect information corresponding to the target defect area.

[0188] In this embodiment, the template image is an image representing the background information of the image to be detected.

[0189] The target defect area is the defect area in the image to be detected.

[0190] The target defect area includes a pixel area obtained after enhancing at least some pixel points in the image to be detected.

[0191] The target defect area may include one or more discrete areas.

[0192] Statistical analysis is an operation of statistically analyzing information such as the mean, maximum value, and minimum value of the background in the image to be detected.

[0193] In the actual execution process, multiple images to be detected can be collected, the background gray mean value of each column in each image to be detected is statistically analyzed, and based on the background gray mean value of the corresponding column in each image to be detected, the background gray value of the template image is determined.

[0194] Taking the background gray scale means of the first column in three images to be detected as 127, 128, and 129 respectively as an example, calculate the mean of 127, 128, and 129 to obtain 128. Take the background gray scale mean 128 as the background gray scale value of the first column of the template image. For other columns, the above operations can be performed to obtain the background gray scale values of each column of the template image, thereby determining the template image.

[0195] In the actual execution process, one image to be detected with better image quality can be selected from multiple images to be detected as the image to be detected for subsequent defect detection.

[0196] Statistically analyze the background gray scale mean of each column in the selected image to be detected, and replace the gray scale values of each column in the image to be detected with the calculated background gray scale mean to obtain the template image.

[0197] After obtaining the template image, the template image and the image to be detected can be subjected to a difference operation to obtain the target defect area. Compare the gray scale values of the target defect area with one or more gray scale defect thresholds respectively to determine the defect category of the target defect area. For example, the target defect area is a bright defect, the target defect area is a dark defect, or the target defect area includes both bright and dark defects.

[0198] According to the defect detection method provided in the embodiments of the present application, by statistically analyzing the image to be detected, the corresponding template image of the image to be detected is obtained. Based on the difference between the template image and the image to be detected, the target defect area is determined. Through one or more gray scale defect thresholds, defect detection is performed on the target defect area, effectively reducing the area for defect detection and improving the detection efficiency.

[0199] In some embodiments, before performing image enhancement on at least some pixel points in the image to be detected based on the pixel gray scale range to obtain the first image to be detected, the method may further include:

[0200] Obtain the initial detection image;

[0201] Perform image preprocessing on the initial detection image to obtain the image to be detected.

[0202] In this embodiment, the initial detection image is the original image of the object to be detected collected.

[0203] Image preprocessing is an operation performed to improve the image quality of the initial detection image.

[0204] Image preprocessing may include: removing non-detection areas and adjusting the brightness of the initial detection image, etc.

[0205] In the actual execution process, the boundary of the object to be detected in the initial detection image can be determined through an edge tracing algorithm to remove the interference of non-detection areas.

[0206] The brightness uniformity of the initial detection image can also be adjusted by a flat-field correction method so that the background gray levels of each column of the image to be detected are consistent.

[0207] In the actual execution process, other image preprocessing operations, such as smoothing processing and filtering processing, etc., can also be performed based on the specific features of the initial detection image, which are not limited in this application.

[0208] According to the defect detection method provided by the embodiments of the present application, by performing image preprocessing on the obtained initial detection image, the image quality of the resulting image to be detected is effectively improved.

[0209] For the defect detection method provided by the embodiments of the present application, the execution subject can be a defect detection device. In the embodiments of the present application, taking the defect detection device executing the defect detection method as an example, the defect detection device provided by the embodiments of the present application is described.

[0210] The embodiments of the present application also provide a defect detection device.

[0211] As Figure 4 shown, the defect detection device includes: a first processing module 410, a second processing module 420, and a third processing module 430.

[0212] The first processing module 410 is configured to obtain the pixel gray level range corresponding to the defect to be detected in the image to be detected;

[0213] The second processing module 420 is configured to perform image enhancement on at least some pixel points in the image to be detected based on the pixel gray level range to obtain a first image to be detected;

[0214] The third processing module 430 is configured to perform defect detection on the first image to be detected to obtain defect information corresponding to the first image to be detected.

[0215] According to the defect detection device provided by the embodiments of the present application, by obtaining the pixel gray level range corresponding to the defect to be detected in the image to be detected, performing image enhancement on at least some pixel points in the image to be detected, a first image to be detected with an obvious difference degree between the pixel region where at least some pixel points are located and other pixel regions in the image to be detected is obtained, the image quality of the first image to be detected is improved, and on the basis of ensuring the accuracy of the gray level threshold, the difficulty of setting the gray level threshold is effectively reduced, thereby reducing the difficulty of defect detection, reducing missed detections and false detections, and improving the detection accuracy.

[0216] In some embodiments, the second processing module 420 can also be configured to:

[0217] Determine a target gray level mapping function based on the pixel gray level range;

[0218] Based on the target gray-scale mapping function, at least some of the pixel points in the image to be detected are subjected to image enhancement to obtain a first image to be detected.

[0219] In some embodiments, the target gray-scale mapping function includes: a first gray-scale mapping function, and the second processing module 420 can also be used for:

[0220] When the pixel gray-scale range can be obtained, determining the target gray-scale mapping function as the first gray-scale mapping function; the first gray-scale mapping function is constructed based on a preset gray value and a preset enhanced gray value, and the preset gray value and the preset enhanced gray value are determined based on the pixel gray-scale range.

[0221] In some embodiments, the target gray-scale mapping function includes: a second gray-scale mapping function, and the second processing module 420 can also be used for:

[0222] When the pixel gray-scale range cannot be obtained, determining the target gray-scale mapping function as the second gray-scale mapping function; the second gray-scale mapping function is constructed based on the background gray value corresponding to the image to be detected, the noise gray value corresponding to the image to be detected, and a preset enhancement intensity.

[0223] In some embodiments, the third processing module 430 can also be used for:

[0224] Based on at least one gray-scale defect threshold, defect detection is performed on the first image to be detected to obtain defect information corresponding to the first image to be detected.

[0225] In some embodiments, the third processing module 430 can also be used for:

[0226] Performing statistical analysis on the image to be detected to obtain a template image corresponding to the image to be detected;

[0227] Performing a difference operation on the template image and the first image to be detected to obtain a target defect region in the first image to be detected;

[0228] Based on at least one gray-scale defect threshold, defect detection is performed on the target defect region to obtain defect information corresponding to the target defect region.

[0229] In some embodiments, the device may further include a fourth processing module for:

[0230] Obtaining an initial detection image;

[0231] Performing image preprocessing on the initial detection image to obtain an image to be detected.

[0232] The defect detection device in the embodiments of the present application can be an electronic device or a component in an electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal or other devices other than terminals. Exemplarily, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a handheld computer, a vehicle-mounted electronic 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 can 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.

[0233] The defect detection device in the embodiments of the present application can be a device with an operating system. The operating system can be an Android operating system, an IOS operating system, or other possible operating systems. The embodiments of the present application do not make specific limitations.

[0234] The defect detection device provided by the embodiments of the present application can implement Figures 1 to 3 each process implemented by the method embodiments. To avoid repetition, it will not be elaborated here.

[0235] In some embodiments, as Figure 5 shown, the embodiments of the present application further provide an electronic device 500, including a processor 501, a memory 502, and a computer program stored on the memory 502 and executable on the processor 501. When the program is executed by the processor 501, it implements each process of the above-mentioned defect detection method embodiment and can achieve the same technical effect. To avoid repetition, it will not be elaborated here.

[0236] It should be noted that the electronic devices in the embodiments of the present application include the above-mentioned mobile electronic devices and non-mobile electronic devices.

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

[0238] Among them, the processor is the processor in the electronic 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.

[0239] The embodiment of the present application also provides a computer program product, including a computer program, which when executed by a processor implements the above-mentioned defect detection method.

[0240] Among them, the processor is the processor in the electronic 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.

[0241] The 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 used to run programs or instructions to implement each process of the above-mentioned defect detection method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be elaborated here.

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

[0243] It should be noted that in this article, the term "including", "comprising", or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article, or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed, or further includes elements inherent to such process, method, article, or device. Without more limitations, the element defined by the statement "including one..." does not exclude the existence of other identical elements in the process, method, article, or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is 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.

[0244] Through the description of the above embodiments, those skilled in the art can clearly understand that the methods of the above embodiments 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 such an understanding, the technical solution of the present application, in essence or the part that contributes to the related technology, can be embodied in the form of a computer software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to enable a terminal (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in various embodiments of the present application.

[0245] The embodiments of the present application have been described above in conjunction with the accompanying drawings. However, the present application is not limited to the above specific implementation manners. The above specific implementation manners are merely illustrative and not restrictive. Under the inspiration of the present application, those of ordinary skill in the art can also make many forms without departing from the purpose of the present application and the scope protected by the claims, and all of them belong to the protection scope of the present application.

[0246] In the description of this specification, the description of reference terms such as "one embodiment", "some embodiments", "illustrative embodiments", "examples", "specific examples", or "some examples" means 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 the present application. In this specification, the schematic representations 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 any one or more embodiments or examples in a suitable manner.

[0247] Although the embodiments of the present application have been shown and described, those of ordinary skill in the art can understand that various changes, modifications, substitutions, and variations can be made to these embodiments without departing from the principle and purpose of the present application. The scope of the present application is defined by the claims and their equivalents.

Claims

1. A defect detection method, characterized in that: include: Obtaining the pixel grayscale range corresponding to the defect to be detected in the image to be detected; Based on the pixel grayscale range, performing image enhancement on at least some of the pixels in the image to be detected to obtain a first image to be detected; Perform defect detection on the first image to be detected to obtain defect information corresponding to the first image to be detected.

2. The defect detection method according to claim 1, characterized in that: The step of performing image enhancement on at least some pixels in the image to be detected based on the pixel grayscale range to obtain a first image to be detected includes: Based on the pixel grayscale range, determining a target grayscale mapping function; Based on the target grayscale mapping function, image enhancement is performed on at least part of the pixels in the image to be detected to obtain the first image to be detected.

3. The defect detection method according to claim 2, characterized in that: The target grayscale mapping function includes: a first grayscale mapping function, and the determining of the target grayscale mapping function based on the pixel grayscale range includes: When the pixel grayscale range can be obtained, the target grayscale mapping function is determined to be a first grayscale mapping function; the first grayscale mapping function is constructed based on a preset grayscale value and a preset enhanced grayscale value, and the preset grayscale value and the preset enhanced grayscale value are determined based on the pixel grayscale range.

4. The defect detection method according to claim 2, characterized in that: The target grayscale mapping function includes: a second grayscale mapping function, and the determining of the target grayscale mapping function based on the pixel grayscale range includes: When the pixel grayscale range cannot be obtained, the target grayscale mapping function is determined to be a second grayscale mapping function; the second grayscale mapping function is constructed based on the background grayscale value corresponding to the image to be detected, the noise grayscale value corresponding to the image to be detected, and a preset enhancement intensity.

5. The defect detection method according to any one of claims 1 to 4, characterized in that: The performing defect detection on the first image to be detected to obtain defect information corresponding to the first image to be detected includes: Based on at least one grayscale defect threshold, defect detection is performed on the first image to be detected to obtain defect information corresponding to the first image to be detected.

6. The defect detection method according to claim 5, characterized in that: The performing defect detection on the first image to be detected based on at least one grayscale defect threshold to obtain defect information corresponding to the first image to be detected includes: Performing statistical analysis on the image to be detected to obtain a template image corresponding to the image to be detected; Performing a difference operation on the template image and the first image to be detected to obtain a target defect area in the first image to be detected; Based on the at least one grayscale defect threshold, defect detection is performed on the target defect area to obtain defect information corresponding to the target defect area.

7. The defect detection method according to any one of claims 1 to 4, characterized in that: Before performing image enhancement on at least some pixels in the image to be detected based on the pixel grayscale range to obtain the first image to be detected, the method further includes: Acquire an initial detection image; Perform image preprocessing on the initial detection image to obtain the image to be detected.

8. A defect detection device, characterized in that: include: The first processing module is used to obtain the pixel grayscale range corresponding to the defect to be detected in the image to be detected; A second processing module, configured to perform image enhancement on at least some pixels in the image to be detected based on the pixel grayscale range, to obtain a first image to be detected; The third processing module is used to perform defect detection on the first image to be detected to obtain defect information corresponding to the first image to be detected.

9. An electronic 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 defect detection method according to any one of claims 1 to 7 is implemented.

10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the defect detection method according to any one of claims 1 to 7 is implemented.

Citation Information

Cited By

  • Defect enhancement method and device based on image adaptive threshold segmentation

    CN121213444A