Scratch detection method and device

By automatically detecting screen scratches using machine vision methods and employing image processing technology to eliminate main textures and construct gradient consistency scores, the problems of low efficiency and inconsistent accuracy of manual detection are solved, achieving efficient and reliable scratch detection.

CN121544582APending Publication Date: 2026-02-17SHENZHEN QIANHAI EVOC ASIA-PACIFIC ELECTRONIC EQUIP TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511777876.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-28
Publication Date
2026-02-17

AI Technical Summary

Technical Problem

In existing technologies, screen scratch detection relies on manual inspection, which results in high labor intensity, low efficiency, inconsistent accuracy, and the inspection results depend on the subjective judgment of the inspectors.

Method used

Using machine vision methods, the main texture frequency is determined by acquiring the power spectral density of the image. After removing the main texture, band-stop filtering is performed to obtain the pointing angle and magnitude of the gradient direction. A comprehensive gradient consistency score is then constructed to achieve automatic scratch detection.

Benefits of technology

It improves testing efficiency, reduces testing costs, and achieves consistency and reliability of test results, providing a unified testing standard.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121544582A_ABST
    Figure CN121544582A_ABST
Patent Text Reader

Abstract

The invention provides a scratch detection method, and the method comprises the steps: obtaining a main texture frequency corresponding to a to-be-detected image according to the power spectrum density of the to-be-detected image; eliminating the main texture of the to-be-detected image according to the main texture frequency to obtain a contrast-improved image; obtaining a pointing angle of a gradient direction of each pixel in the contrast-enhanced image, and determining a standard deviation of the pointing angles of all the pixels; obtaining a gradient magnitude of each pixel in the contrast-enhanced image, and determining a gradient magnitude variable coefficient of the contrast-enhanced image according to the gradient magnitude of each pixel; and determining a gradient consistency comprehensive score of the contrast-improved image according to the standard deviation and the gradient amplitude variable coefficient, and determining whether a scratch exists in the to-be-detected image according to the gradient consistency comprehensive score. According to the invention, automatic detection of scratches can be realized, the detection efficiency is effectively improved, and the detection standard is unified.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of product testing technology, and in particular to a scratch detection method and apparatus. Background Technology

[0002] Currently, screen scratch inspection is done manually. However, scratch inspection, especially against complex backgrounds, requires significant manual labor, which can easily lead to operator fatigue, reduced efficiency, and increased costs over extended periods. Furthermore, manual inspection results often rely on the inspector's subjective judgment, resulting in inconsistent inspection accuracy. Summary of the Invention

[0003] The scratch detection method and apparatus provided by this invention can realize automatic scratch detection, effectively improve detection efficiency, and unify detection standards.

[0004] In a first aspect, the present invention provides a scratch detection method, the method comprising: Based on the power spectral density of the image to be detected, the main texture frequency corresponding to the image to be detected is obtained; Based on the main texture frequency, the main texture of the image to be detected is eliminated to obtain a contrast-enhanced image; Obtain the pointing angle of the gradient direction for each pixel in the contrast-enhanced image, and determine the standard deviation of the pointing angles for all pixels; Obtain the gradient magnitude of each pixel in the contrast-enhanced image, and determine the gradient magnitude variation coefficient of the contrast-enhanced image based on the gradient magnitude of each pixel; Based on the standard deviation and the gradient magnitude variation coefficient, a gradient consistency comprehensive score for the contrast-enhanced image is determined, and the presence of scratches in the image to be detected is determined based on the gradient consistency comprehensive score.

[0005] Optionally, obtaining the main texture frequency corresponding to the image to be detected based on the power spectral density of the image to be detected includes: The image to be detected is subjected to a fast Fourier transform to obtain the frequency domain spectrum corresponding to the image to be detected. Obtain the power spectral density of the frequency domain spectrum, and determine the main texture frequency based on the peak value of the power spectral density.

[0006] Optionally, the step of eliminating the main texture of the image to be detected based on the main texture frequency to obtain a contrast-enhanced image includes: The image to be detected is subjected to a fast Fourier transform to obtain the frequency domain spectrum corresponding to the image to be detected. A band-stop filter is constructed based on the main texture frequency, and the band-stop filter is used to perform band-stop filtering on the frequency domain spectrum to eliminate the frequency corresponding to the main texture in the image to be detected, thereby obtaining the filtered frequency domain spectrum. The filtered frequency domain spectrum is subjected to inverse Fourier transform to obtain a contrast-enhanced image.

[0007] Optionally, obtaining the pointing angle of the gradient direction of each pixel in the contrast-enhanced image and determining the standard deviation of the pointing angles of all pixels includes: Obtain the pixel gradient magnitude between each pixel and its neighboring pixels; Based on the pixel gradient magnitude, the pointing angle of the pixel gradient magnitude is calculated using the four-quadrant arctangent function; The pointing angles of all pixels are statistically analyzed, and the standard deviation of the pointing angles of all pixels is determined.

[0008] Optionally, before the step of calculating the pointing angle of the pixel gradient using the four-quadrant arctangent function based on the pixel gradient, the method further includes: Construct a coordinate system with the horizontal and vertical pixel gradients as axes; When the coordinate point formed by the horizontal pixel gradient and the vertical pixel gradient is in the first quadrant of the coordinate system, the value range of the pointing angle is 0~π / 2. When the coordinate point formed by the horizontal pixel gradient and the vertical pixel gradient is in the second quadrant of the coordinate system, the value range of the pointing angle is π / 2 to π. When the coordinate point formed by the horizontal pixel gradient and the vertical pixel gradient is in the third quadrant of the coordinate system, the value range of the pointing angle is -π to -π / 2. When the coordinate point formed by the horizontal and vertical pixel gradients is in the fourth quadrant of the coordinate system, the value range of the pointing angle is -π / 2 to 0.

[0009] Optionally, obtaining the gradient magnitude of each pixel in the contrast-enhanced image and determining the gradient magnitude variation coefficient of the contrast-enhanced image based on the gradient magnitude of each pixel includes: Obtain the pixel gradient magnitude between each pixel and its neighboring pixels; Statistically analyze the pixel gradient magnitude of all pixels to determine the standard deviation and average value of the pixel gradient magnitude of all pixels; The ratio of the standard deviation to the mean of the pixel gradient magnitude of all pixels is determined as the gradient magnitude variation coefficient.

[0010] Optionally, obtaining the pixel gradient magnitude of each pixel and its neighboring pixels includes: The Gaussian derivative operator is used to calculate the derivative of each pixel in the contrast-enhanced image in the horizontal and vertical directions, respectively, to determine the pixel gradient magnitude of each pixel with respect to its neighboring pixels.

[0011] Optionally, determining the gradient consistency comprehensive score of the contrast-enhanced image based on the standard deviation and the gradient magnitude variation coefficient includes: The first intermediate value is determined by using the natural constant as the base and the negative value of the standard deviation as the exponent; Using the natural constant as the base and the negative value of the gradient magnitude variation coefficient as the exponent, the second intermediate value is determined; The first and second intermediate values ​​are weighted and summed to determine the gradient consistency comprehensive score.

[0012] Optionally, determining whether scratches exist in the image to be detected based on the gradient consistency comprehensive score includes: When the gradient consistency comprehensive score is less than a preset value, it is determined that there are scratches in the image to be detected; When the gradient consistency comprehensive score is not less than a preset value, it is determined that there are no scratches in the image to be detected.

[0013] Secondly, the present invention also provides a scratch detection device, comprising: Conveying equipment, used to carry products to be tested and continuously transport them along the target direction; The light source includes two sub-light sources symmetrically arranged along the center line of the conveying device. The two sub-light sources are located on both sides above the conveying device and are used to symmetrically illuminate the product to be tested when the product to be tested is conveyed to the preset position. A camera is positioned directly above the conveying device, with its optical axis perpendicular to the conveying device. The camera is used to acquire an image of the product to be inspected when the product to be inspected is conveyed to a preset position. A triggering device is used to detect whether the product to be tested has been transported to a preset position, and to send an instruction to the camera to acquire the image of the product to be tested when the product to be tested is transported to the preset position; A detection device, which is communicatively connected to the camera, is used to acquire the image to be detected from the camera and perform the scratch detection method described in any of the preceding descriptions.

[0014] In the technical solution provided by this invention, the main texture of the image to be detected is eliminated, making the scratches more obvious. Then, a gradient consistency comprehensive score is constructed using the standard deviation of the pointing angle and the coefficient of variation of the gradient amplitude, providing a unified detection standard for scratch detection. Because the technical solution provided by this invention uses machine vision to detect scratches, it effectively improves detection efficiency, reduces detection costs, and enhances the consistency, stability, and reliability of the detection results. Attached Figure Description

[0015] Figure 1 This is a flowchart of a scratch detection method according to an embodiment of the present invention; Figure 2 This is a flowchart illustrating the method for determining the main texture in another embodiment of the scratch detection method of the present invention; Figure 3 This is a flowchart illustrating the method for determining a contrast-enhanced image in another embodiment of the scratch detection method of the present invention; Figure 4 This is a flowchart illustrating the standard deviation of the pointing angle in another embodiment of the scratch detection method of the present invention; Figure 5 This is a flowchart illustrating the determination of the gradient amplitude variation coefficient in a scratch detection method according to another embodiment of the present invention; Figure 6 This is a vertical layout diagram of a scratch detection device according to an embodiment of the present invention; Figure 7 This is a horizontal layout diagram of a scratch detection device according to an embodiment of the present invention. Detailed Implementation

[0016] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0017] This invention provides a scratch detection method, such as... Figure 1 As shown, the method includes: Based on the power spectral density of the image to be detected, the main texture frequency corresponding to the image to be detected is obtained; In some embodiments, when calculating the power spectral density of an image to be detected, the frequency domain information of the image to be detected can be obtained by first performing a fast Fourier transform on the image to be detected, and then the power spectral density can be calculated based on the frequency domain information. In the power spectral density curve, the main texture frequency will correspond to the peak value of the power spectral density curve.

[0018] Based on the main texture frequency, the main texture of the image to be detected is eliminated to obtain a contrast-enhanced image; In some embodiments, band-stop filtering of the image to be detected based on the main texture frequency can eliminate the frequencies corresponding to complex background textures, thereby highlighting the scratch features in the image. Then, through inverse Fourier transform, an image with background textures eliminated can be obtained. After eliminating the background textures, the scratch features in the image will be more prominent, which is more conducive to scratch detection.

[0019] Obtain the pointing angle of the gradient direction for each pixel in the contrast-enhanced image, and determine the standard deviation of the pointing angles for all pixels; In some embodiments, the pointing angle of the gradient direction of each pixel in the contrast-enhanced image refers to the angle data obtained by applying the arctangent function of the gradient in the horizontal and vertical directions of each pixel to the four quadrants. The standard deviation of the angles of all pixels is obtained by statistically analyzing the pointing angles of all pixels.

[0020] Obtain the gradient magnitude of each pixel in the contrast-enhanced image, and determine the gradient magnitude variation coefficient of the contrast-enhanced image based on the gradient magnitude of each pixel; In some embodiments, the gradient magnitude of each pixel refers to the gradient magnitude calculated based on the pixel gradients in the horizontal and vertical directions, for example, by using Euclidean distance (L2 norm) or the sum of absolute values ​​(L1 norm). The coefficient of variation of the gradient magnitude is the gradient magnitude variation obtained by statistically analyzing the gradient magnitudes of all pixels.

[0021] Based on the standard deviation and the gradient magnitude variation coefficient, a gradient consistency comprehensive score for the contrast-enhanced image is determined, and the presence of scratches in the image to be detected is determined based on the gradient consistency comprehensive score.

[0022] In some embodiments, after eliminating the influence of background texture, if there are scratch features in the image to be detected, the aforementioned standard deviation and gradient magnitude variation coefficient will increase significantly, and the gradient consistency comprehensive score constructed based on the standard deviation and gradient magnitude variation coefficient will also change significantly. Therefore, the gradient consistency comprehensive score can be used to detect whether scratches exist.

[0023] In the technical solution provided by this invention, filtering in the frequency domain eliminates texture patterns, making scratches more visible in the image. Then, a gradient consistency comprehensive score is constructed using the standard deviation of the pointing angle and the coefficient of variation of the gradient amplitude, providing a unified detection standard for scratch detection. Because the technical solution provided by this invention uses machine vision to detect scratches, it effectively improves detection efficiency, reduces detection costs, and enhances the consistency, stability, and reliability of the detection results.

[0024] As an optional implementation method, such as Figure 2 As shown, obtaining the main texture frequency corresponding to the image to be detected based on the power spectral density of the image to be detected includes: The image to be detected is subjected to a fast Fourier transform to obtain the frequency domain spectrum corresponding to the image to be detected. Obtain the power spectral density of the frequency domain spectrum, and determine the main texture frequency based on the peak value of the power spectral density.

[0025] In some embodiments, when performing a Fast Fourier Transform (FFT) on the image to be detected to transform it to the frequency domain, the following formula can be used for the transformation:

[0026] Where f(x,y) is the pixel value of the input image at (x,y), F(u,v) is the frequency domain representation, that is, the intensity and phase at (u,v) in the frequency domain, M is the image width, N is the image height, u is the frequency in the horizontal direction, and v is the frequency in the vertical direction.

[0027] After performing the Fast Fourier Transform, the main texture frequency can be obtained using the following formula:

[0028] in, Let be the power intensity at the frequency domain (u,v).

[0029] By squaring and normalizing the frequency amplitude using the aforementioned formula, the power spectral density is obtained. Then, by finding the maximum power spectral density value, the main texture frequency can be determined. For example, the main texture frequency can be determined using the following formula:

[0030] in, That is, the primary texture frequency.

[0031] As an optional implementation method, such as Figure 3 As shown, the step of eliminating the main texture of the image to be detected based on the main texture frequency to obtain a contrast-enhanced image includes: The image to be detected is subjected to a fast Fourier transform to obtain the frequency domain spectrum corresponding to the image to be detected. A band-stop filter is constructed based on the main texture frequency, and the band-stop filter is used to filter the frequency domain spectrum to eliminate the frequency corresponding to the main texture in the image to be detected, thereby obtaining the filtered frequency domain spectrum. The filtered frequency domain spectrum is subjected to inverse Fourier transform to obtain a contrast-enhanced image.

[0032] In some embodiments, when determining the band-stop filter, the band-stop filter is generated based on the main texture frequency. The purpose is to enhance the visibility of the scratch by blocking signals within a specific frequency range, such as blocking the main texture signal, thereby preserving the edge or structural features of the scratch in the image. Specifically, the band-stop filter can be designed using, for example, the following formula:

[0033] in, , The main texture frequency is extracted through power spectrum analysis. This represents the standard deviation of the band-stop filter, primarily used to control its bandwidth.

[0034] The aforementioned band-stop filter is a Gaussian band-stop filter with dual center frequencies, achieving a stopband located at ( , )and( , This band-stop filter covers a symmetrical region of positive and negative frequencies. It avoids the ringing effect of rational filters; simultaneously, energy near the center frequency is exponentially attenuated, suppressing interference in the main texture frequency band; and, with Euclidean distance... Define the filtering range, suitable for non-directional textures. Therefore, it effectively maintains signal integrity and significantly improves anti-interference capability.

[0035] When performing band-stop filtering, the band-stop filter can be multiplied with the frequency domain spectrum to obtain the filtered frequency domain spectrum. For example, the following formula can be used for calculation.

[0036] in, This is the filtered frequency domain spectrum.

[0037] Then, the filtered frequency domain spectrum is subjected to an inverse Fourier transform to obtain a contrast-enhanced image. For example, the inverse Fourier transform can be performed using the following formula:

[0038] in, To enhance image contrast The pixel value at that location.

[0039] As an optional implementation method, such as Figure 4 As shown, obtaining the pointing angle of the gradient direction of each pixel in the contrast-enhanced image and determining the standard deviation of the pointing angles of all pixels includes: Obtain the pixel gradient magnitude between each pixel and its neighboring pixels; Based on the pixel gradient magnitude, the pointing angle of the pixel gradient magnitude is calculated using the four-quadrant arctangent function; The pointing angles of all pixels are statistically analyzed, and the standard deviation of the pointing angles of all pixels is determined.

[0040] In some embodiments, the following formula can be used to calculate the pointing angle:

[0041] in, Let be the pointing angle of the i-th pixel. Let be the pixel gradient magnitude of the i-th pixel in the y-direction. Let be the pixel gradient magnitude of the i-th pixel in the x-direction.

[0042] The standard deviation of all pointing angles can be calculated using the following formula:

[0043] in, Let K be the standard deviation of all pointing angles, and K be the number of pixels.

[0044] As an optional implementation, before the step of calculating the pointing angle of the pixel gradient using the four-quadrant arctangent function based on the pixel gradient, the method further includes: Construct a coordinate system with the horizontal and vertical pixel gradients as axes; When the coordinate point formed by the horizontal pixel gradient and the vertical pixel gradient is in the first quadrant of the coordinate system, the value range of the pointing angle is 0~π / 2. When the coordinate point formed by the horizontal pixel gradient and the vertical pixel gradient is in the second quadrant of the coordinate system, the value range of the pointing angle is π / 2 to π. When the coordinate point formed by the horizontal pixel gradient and the vertical pixel gradient is in the third quadrant of the coordinate system, the value range of the pointing angle is -π to -π / 2. When the coordinate point formed by the horizontal and vertical pixel gradients is in the fourth quadrant of the coordinate system, the value range of the pointing angle is -π / 2 to 0.

[0045] In some embodiments, the value of the arctangent in the 4th quadrant depends not only on the tangent value. / It also depends on the point ( Which quadrant it falls into, therefore, requires defining its range of values: When the point ( When it falls into the first quadrant, arctan2( , The range of ) is 0 to π / 2; When the point ( When it falls into the second quadrant, arctan2( , The range of π / 2 to π; When the point ( When it falls into the third quadrant, arctan2( , The range of ) is -π to -π / 2; When the point ( When it falls into the fourth quadrant, arctan2( , The range of ) is -π to -π / 2.

[0046] As an optional implementation method, such as Figure 5 As shown, the step of obtaining the gradient magnitude of each pixel in the contrast-enhanced image and determining the gradient magnitude variation coefficient of the contrast-enhanced image based on the gradient magnitude of each pixel includes: Obtain the pixel gradient magnitude between each pixel and its neighboring pixels; Statistically analyze the pixel gradient magnitude of all pixels to determine the standard deviation and average value of the pixel gradient magnitude of all pixels; The ratio of the standard deviation to the mean of the pixel gradient magnitude of all pixels is determined as the gradient magnitude variation coefficient.

[0047] In some embodiments, the gradient magnitude variation coefficient can be calculated using the following formula:

[0048] in, The gradient magnitude variation coefficient is... Let be the gradient magnitude of the i-th pixel.

[0049] As an optional implementation, obtaining the pixel gradient magnitude between each pixel and its neighboring pixels includes: The Gaussian derivative operator is used to calculate the derivative of each pixel in the contrast-enhanced image in the horizontal and vertical directions, respectively, to determine the pixel gradient magnitude of each pixel with respect to its neighboring pixels.

[0050] In some embodiments, the pixel gradient can be calculated using the following formula:

[0051]

[0052]

[0053] in, The Gaussian derivative operator, σ, is the standard deviation of the Gaussian kernel, used to control the smoothing intensity (blurring degree). The larger σ is, the more blurred the image. When performing the calculation, σ must first be specified. The width of the Gaussian kernel can be calculated based on σ, following the 3σ principle (the sum of element values ​​within this region exceeds 99.7% of the total element values). When σ=1, the effective kernel width is approximately 1+2*(3*1)=7 pixels; when σ=3, the effective kernel width is 1+2*(3*3)=19 pixels.

[0054] As an optional implementation, determining the gradient consistency comprehensive score of the contrast-enhanced image based on the standard deviation and the gradient magnitude variation coefficient includes: The first intermediate value is determined by using the natural constant as the base and the negative value of the standard deviation as the exponent; Using the natural constant as the base and the negative value of the gradient magnitude variation coefficient as the exponent, the second intermediate value is determined; The first and second intermediate values ​​are weighted and summed to determine the gradient consistency comprehensive score.

[0055] In some embodiments, the gradient consistency comprehensive score can be calculated, for example, according to the following formula:

[0056] in, The overall score is based on gradient consistency. This is the weighting coefficient, with a value ranging from 0 to 1.

[0057] As an optional implementation, determining whether scratches exist in the image to be detected based on the gradient consistency comprehensive score includes: When the gradient consistency comprehensive score is less than a preset value, it is determined that there are scratches in the image to be detected; When the gradient consistency comprehensive score is not less than a preset value, it is determined that there are no scratches in the image to be detected.

[0058] In some embodiments, for example, it can be when A value less than 0.85 confirms the presence of scratches.

[0059] This invention also provides a scratch detection device, such as... Figure 6-7 As shown, the scratch detection device includes: Conveying device 4 is used to carry the product 2 to be tested and continuously transport it along the target direction; The light source includes two sub-light sources 5 symmetrically arranged along the center line of the conveying device 4. The two sub-light sources 5 are arranged on both sides above the conveying device 4. The two sub-light sources 5 are used to symmetrically illuminate the product to be tested 2 when the product to be tested 2 is conveyed to the preset position. Camera 3 is positioned directly above the conveying device 4, with its optical axis perpendicular to the conveying device 4. Camera 3 is used to acquire an image of the product 2 to be inspected when the product 2 to be inspected is conveyed to a preset position. Triggering device 1, the triggering device 1 is used to detect whether the product to be tested 2 is transported to a preset position, and when the product to be tested 2 is transported to the preset position, it sends an instruction to the camera 3 to acquire the image to be tested of the product to be tested 2; A detection device, which is communicatively connected to the camera, is used to acquire the image to be detected from the camera and perform the scratch detection method described in any of the preceding descriptions.

[0060] In some embodiments, when inspecting the product 2, the product 2 is first placed on the inspection equipment station, i.e., the conveyor 4. A front light source is used at the predetermined position, and the camera 3 and lens are arranged directly above it. When the conveyor 4 carrying the product 2 arrives at the inspection station, i.e., the predetermined position, the photoelectric sensor is triggered, i.e., the triggering device 1, and the camera 3 begins to take pictures. This device allows the product 2 to continuously enter the inspection station along with the conveyor 4, completing the inspection without stopping the conveyor 4, thus not affecting the original production efficiency of the production line.

[0061] Those skilled in the art will understand that all or part of the processes in the above method embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.

[0062] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.

Claims

1. A scratch detection method characterized by, The method comprises: According to the power spectral density of the image to be detected, the main texture frequency corresponding to the image to be detected is obtained; According to the main texture frequency, the main texture of the image to be detected is eliminated to obtain a contrast-enhanced image; The pointing angle of the gradient direction of each pixel in the contrast-enhanced image is obtained, and the standard deviation of the pointing angle of all pixels is determined; The gradient amplitude of each pixel in the contrast-enhanced image is obtained, and the gradient amplitude variation coefficient of the contrast-enhanced image is determined according to the gradient amplitude of each pixel; According to the standard deviation and the gradient amplitude variation coefficient, the gradient consistency comprehensive score of the contrast-enhanced image is determined, and whether there is a scratch in the image to be detected is determined according to the gradient consistency comprehensive score.

2. The method of claim 1, wherein, According to the power spectral density of the image to be detected, the main texture frequency corresponding to the image to be detected is obtained, which comprises: The image to be detected is subjected to fast Fourier transform to obtain a frequency domain spectrum corresponding to the image to be detected; The power spectral density of the frequency domain spectrum is obtained, and the main texture frequency is determined according to the peak value of the power spectral density.

3. The method of claim 1, wherein, According to the main texture frequency, the main texture of the image to be detected is eliminated to obtain a contrast-enhanced image, which comprises: The image to be detected is subjected to fast Fourier transform to obtain a frequency domain spectrum corresponding to the image to be detected; According to the main texture frequency, a band-stop filter is constructed, and the band-stop filter is used to filter the frequency domain spectrum to eliminate the frequency corresponding to the main texture in the image to be detected, thereby obtaining a filtered frequency domain spectrum; The filtered frequency domain spectrum is subjected to inverse Fourier transform to obtain the contrast-enhanced image.

4. The method of claim 1, wherein, The pointing angle of the gradient direction of each pixel in the contrast-enhanced image is obtained, and the standard deviation of the pointing angle of all pixels is determined, which comprises: The pixel gradient amplitude of each pixel and the adjacent pixel is obtained; According to the pixel gradient amplitude, the pointing angle of the pixel gradient amplitude is calculated by using the four-quadrant inverse tangent function; The pointing angles of all pixels are counted to determine the standard deviation of the pointing angles of all pixels.

5. The method of claim 4, wherein, Before the step of calculating the pointing angle of the pixel gradient by using the four-quadrant inverse tangent function according to the pixel gradient, it further comprises: A coordinate system is constructed with the horizontal direction pixel gradient and the vertical direction pixel gradient as the axes; When the coordinate point formed by the horizontal direction pixel gradient and the vertical direction pixel gradient is in the first quadrant of the coordinate system, the value range of the pointing angle is 0~π / 2; When the coordinate point formed by the horizontal direction pixel gradient and the vertical direction pixel gradient is in the second quadrant of the coordinate system, the value range of the pointing angle is π / 2~π; When the coordinate point formed by the horizontal direction pixel gradient and the vertical direction pixel gradient is in the third quadrant of the coordinate system, the value range of the pointing angle is -π~-π / 2; When the coordinate point formed by the horizontal direction pixel gradient and the vertical direction pixel gradient is in the fourth quadrant of the coordinate system, the value range of the pointing angle is -π / 2~0.

6. The method of claim 1, wherein, The method comprises the following steps: obtaining the gradient amplitude of each pixel in the contrast-enhanced image, and determining the gradient amplitude variation coefficient of the contrast-enhanced image according to the gradient amplitude of each pixel comprises: obtaining the pixel gradient amplitude of each pixel and adjacent pixels; statistically processing the pixel gradient amplitudes of all pixels to determine the standard deviation and the average value of the pixel gradient amplitudes of all pixels; 7. The method according to claim 4 or 6, characterized in that, determining the ratio of the standard deviation and the average value of the pixel gradient amplitudes of all pixels as the gradient amplitude variation coefficient. The method comprises the following steps:

8. The method of claim 1, wherein, obtaining the pixel gradient amplitude of each pixel and adjacent pixels comprises: respectively calculating the derivative of each pixel in the contrast-enhanced image in the horizontal direction and the vertical direction by using the Gaussian derivative operator to determine the pixel gradient amplitude of each pixel and adjacent pixels. The method comprises the following steps: determining the gradient consistency comprehensive score of the contrast-enhanced image according to the standard deviation and the gradient amplitude variation coefficient comprises:

9. The method of claim 1, wherein, determining a first intermediate value by taking a natural constant as the base and the negative value of the standard deviation as the exponent; determining a second intermediate value by taking a natural constant as the base and the negative value of the gradient amplitude variation coefficient as the exponent; determining the gradient consistency comprehensive score by weighted sum of the first intermediate value and the second intermediate value.

10. A scratch detection device, characterized by The method comprises the following steps: determining whether there is a scratch in the to-be-detected image according to the gradient consistency comprehensive score comprises: when the gradient consistency comprehensive score is less than a preset value, it is determined that there is a scratch in the to-be-detected image; when the gradient consistency comprehensive score is not less than the preset value, it is determined that there is no scratch in the to-be-detected image. The method comprises the following steps: a conveying device for carrying a to-be-detected product and continuously conveying in a target direction; a light source comprising two sub-light sources symmetrically arranged along the center line of the conveying device, the two sub-light sources being arranged above the two sides of the conveying device, and the two sub-light sources being used for symmetrically irradiating the to-be-detected product when the to-be-detected product is conveyed to a preset position; a camera arranged directly above the conveying device, the optical axis of the camera being perpendicular to the conveying device, and the camera being used for obtaining a to-be-detected image of the to-be-detected product when the to-be-detected product is conveyed to the preset position; a triggering device for detecting whether the to-be-detected product is conveyed to the preset position, and sending an instruction to the camera to obtain the to-be-detected image of the to-be-detected product when the to-be-detected product is conveyed to the preset position; a detection device in communication connection with the camera, the detection device being used for obtaining the to-be-detected image from the camera and executing the scratch detection method according to any one of claims 1-9.