CN112288745B - Product surface defect detection method based on wavelet transformation, memory and processor - Google Patents

Product surface defect detection method based on wavelet transformation, memory and processor Download PDF

Info

Publication number
CN112288745B
CN112288745B CN202011559294.3A CN202011559294A CN112288745B CN 112288745 B CN112288745 B CN 112288745B CN 202011559294 A CN202011559294 A CN 202011559294A CN 112288745 B CN112288745 B CN 112288745B
Authority
CN
China
Prior art keywords
wavelet
image
kernel
defect
detection method
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202011559294.3A
Other languages
Chinese (zh)
Other versions
CN112288745A (en
Inventor
吴巍
刘亮
王建刚
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Huagong Measurement Engineering Technology Co ltd
Original Assignee
Wuhan Huagong Laser Engineering Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Wuhan Huagong Laser Engineering Co Ltd filed Critical Wuhan Huagong Laser Engineering Co Ltd
Priority to CN202011559294.3A priority Critical patent/CN112288745B/en
Publication of CN112288745A publication Critical patent/CN112288745A/en
Application granted granted Critical
Publication of CN112288745B publication Critical patent/CN112288745B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/0002Inspection of images, e.g. flaw detection
    • G06T7/0004Industrial image inspection
    • GPHYSICS
    • G01MEASURING; TESTING
    • G01NINVESTIGATING OR ANALYSING MATERIALS BY DETERMINING THEIR CHEMICAL OR PHYSICAL PROPERTIES
    • G01N21/00Investigating or analysing materials by the use of optical means, i.e. using sub-millimetre waves, infrared, visible or ultraviolet light
    • G01N21/84Systems specially adapted for particular applications
    • G01N21/88Investigating the presence of flaws or contamination
    • G01N21/8851Scan or image signal processing specially adapted therefor, e.g. for scan signal adjustment, for detecting different kinds of defects, for compensating for structures, markings, edges
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/20Image enhancement or restoration by the use of local operators
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/11Region-based segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/136Segmentation; Edge detection involving thresholding
    • GPHYSICS
    • G01MEASURING; TESTING
    • G01NINVESTIGATING OR ANALYSING MATERIALS BY DETERMINING THEIR CHEMICAL OR PHYSICAL PROPERTIES
    • G01N21/00Investigating or analysing materials by the use of optical means, i.e. using sub-millimetre waves, infrared, visible or ultraviolet light
    • G01N21/84Systems specially adapted for particular applications
    • G01N21/88Investigating the presence of flaws or contamination
    • G01N21/8851Scan or image signal processing specially adapted therefor, e.g. for scan signal adjustment, for detecting different kinds of defects, for compensating for structures, markings, edges
    • G01N2021/8887Scan or image signal processing specially adapted therefor, e.g. for scan signal adjustment, for detecting different kinds of defects, for compensating for structures, markings, edges based on image processing techniques
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20024Filtering details
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20048Transform domain processing
    • G06T2207/20064Wavelet transform [DWT]

Abstract

The invention discloses a product surface defect detection method based on wavelet transformation, a memory and a processor, wherein an original image of a product is read firstly, then the size and the direction of a wavelet kernel are input, the wavelet kernel is generated by utilizing the wavelet transformation calculation, and then the wavelet kernel and the original image of the product are utilized to carry out convolution operation to obtain a filtering image, so that the self-adaptive filtering of a complex image background is realized, and a defect area is highlighted; for different types of defects, wavelet kernels with different sizes and wavelet directions can be input for defect detection, the purpose of detecting different types of defects by one method is achieved, image processing algorithms do not need to be developed for certain types or certain types of defects, and development cost is greatly reduced.

Description

Product surface defect detection method based on wavelet transformation, memory and processor
Technical Field
The invention relates to the technical field of product surface defect detection, in particular to a wavelet transform-based product surface defect detection method, a memory and a processor.
Background
At present, with the development of the machine vision industry, the detection of the surface defects of products is more and more performed by using machine equipment to replace manual visual inspection. In appearance detection, the common defects include scratches, stabbing wounds, concave-convex pits, stamping, edge breakage, different colors, ink deficiency and the like. The defects are generally distributed in different areas of the product, and due to different occurrence positions of different types of defects, the background of the defects is different, which brings great inconvenience to image analysis.
The mainstream detection equipment in the industry basically adopts an industrial camera to collect images and then utilizes a software algorithm to analyze the images. For example, the Chinese patent application publication No. CN110570393A, 2019, 12 and 13 discloses a mobile phone glass cover plate window area defect detection method based on machine vision, which mainly comprises two parts of rough inspection and fine inspection, wherein the rough inspection process comprises four key steps of standard template manufacturing, template matching, affine transformation and region comparison; the fine inspection part mainly extracts and classifies defects, the defect extraction process comprises four parts, namely image preprocessing, image blocking, image enhancement and threshold segmentation, and before defect classification, clustering processing is carried out on extracted defect regions; dividing the defects into point-shaped, linear and planar defects by adopting a neural network classifier, and comparing the point-shaped, linear and planar defects with corresponding point-shaped, linear and planar detection standards; and (4) defect reclassification is carried out on the scratch, the floating broken filament, the light-color dirty and the dark-color dirty which are difficult to distinguish by adopting a deep learning classifier. The patent application detects the similar defects of scratch, floating broken filament, light color dirt and dark color dirt, and has higher algorithm complexity and weak practicability.
In order to solve the problem that the existing method is not practical, China with the publication number of CN111693549A specially facilitates 9/22/2020, discloses a mobile phone cover glass defect detection and classification method, is sensitive to the concave-convex transformation of the cover glass surface and is used for judging surface damage type defects based on a phase diagram of image sequence analysis of reflected sine stripe structured light, starts with improving the cover glass defect acquisition stability and directly carrying out concave-convex measurement on the defects, enhances the input of defect information, improves the accuracy and stability of the mobile phone cover glass defect detection and classification, and solves the problem that the existing method is not practical. However, the defect detection method of the patent application is also used for detecting the specific type of defects, the problem of detection practicability of the specific type of defects is solved, and the detection method has certain limitations.
It can be seen that, in the current detection method, a corresponding image processing algorithm is developed in a targeted manner for a certain type of defect or a certain number of similar types of defects, and the developed algorithm can only detect the targeted type or the certain type of defects, cannot be used for detecting other types of defects, and cannot achieve the purpose of detecting different types of defects by using the same algorithm by changing only a certain parameter.
In order to achieve a better defect detection effect, a Gabor wavelet function is proposed to be used for defect detection, but the more the algorithm for defect detection based on Gabor wavelet transformation is proposed at present, the more the purpose of optimizing the detection effect is, the more the algorithm research personnel is oriented, the more debugging parameters of the proposed algorithm are, and the more the debugging process is complex. For users in actual defect detection operation, the wavelet processing process is not understood like research and development personnel, so that the parameter debugging process of the image processing algorithm is very difficult to operate and takes long time for users without research and development bases, which is also a main reason that the defect detection method based on wavelet transformation has good detection effect but poor application and popularization effect.
Therefore, the invention provides a product surface defect detection method based on wavelet transformation, which is oriented to actual users on a production line, so that the users only need to know what result is obtained when a wavelet kernel becomes larger or smaller or what result is obtained when the wavelet direction changes, the relation among all parameters of the wavelet is not needed to be understood, the purpose of detecting different types of defects can be achieved only by adjusting the size of the wavelet kernel and the direction of the wavelet, the invention can also achieve the purpose of detecting different types of defects by using one image processing algorithm by debugging the parameters of the same algorithm, the development cost is reduced, and the practicability and the application range of the defect detection method are improved.
Disclosure of Invention
In order to overcome the defects of the prior art, the invention provides a product surface defect detection method based on wavelet transformation, a memory and a processor.
According to one embodiment of the invention, a method for detecting surface defects of a product based on wavelet transformation is provided, which comprises the following steps:
acquiring an original image;
inputting wavelet kernel size and wavelet direction, wherein the range of the wavelet kernel size is 15-60 x 60, the range of the wavelet direction is 0-2 pi, performing wavelet transformation by adopting a Gabor wavelet function, and calculating a wavelet kernel;
performing convolution operation on the generated wavelet kernel and the original image to obtain a filtering image;
and extracting the defect area by adopting a hysteresis threshold value mode based on the filtered image.
In the technical scheme, an original image of a product is read firstly, then the size and the direction of a wavelet kernel are input, the wavelet kernel is generated by utilizing wavelet transformation calculation, and then convolution operation is carried out on the wavelet kernel and the original image of the product to obtain a filtered image, so that the self-adaptive filtering of a complex image background is realized, and a defect area is highlighted; for different types of defects, wavelet kernels with different sizes and wavelet directions can be input for defect detection, and the purpose of detecting different types of defects by one method is achieved; in the detection process, a user only needs to know what result is obtained when the wavelet core becomes large or small or what result is obtained when the wavelet direction changes, the relation among all parameters of the wavelet does not need to be considered, the detection of different types of defects is realized by inputting different wavelet core sizes and wavelet directions, the detection method is simple, the parameter debugging process is visual, the method is suitable for actual operators on a production line, and the method has good application and popularization values.
Furthermore, multiple groups of parameters can be input for the original image of the same product to perform wavelet kernel calculation and convolution filtering to obtain multiple groups of filtering images, and then different types of defect regions can be extracted through the multiple groups of filtering images. When the difference between the values of the two groups of input parameters is large, filtering images containing different defect types can be obtained; when the values of the two groups of input parameters are different, the defect types contained in the two obtained filtered images may coincide. In actual operation, the input parameters may be adjusted according to circumstances, for example, the difference between two adjacent sets of input parameters is increased or decreased, so that the coincidence degree of the defect types included in two adjacent filtered images is within a preset range, thereby achieving the purpose of detecting all the input parameters and avoiding the waste of computing resources caused by repeated detection.
As a further technical solution, the Gabor wavelet function includes 5 input parameters, wherein the phase offset, the aspect ratio, and the standard deviation are fixed parameters, which have been set before actual detection; the wavelength and the direction are variable parameters and can be adjusted within a preset range in the actual detection process; the wavelength is the product of the wavelet kernel size and a scaling factor that is set to an empirical constant. The fixed parameters are parameters necessary for calculating the wavelet kernel by wavelet transformation, and the parameters have small influence on actual defect detection, and influence caused by change of the parameters can be ignored within certain detection precision, so that the parameters can be set as fixed values. The variable parameters are parameters necessary for calculating wavelet kernels through wavelet transformation, and the parameters have a large influence on actual defect detection. When the method is used for detecting the surface defects of the product, the defect detection can be realized only by adjusting the variable parameters.
Both experiments and theory show that the change in phase shift, which can be understood as a shift in the Gabor wavelet, has little effect on the result, while the aspect ratio is fixed to 0.3, so that the effects of phase shift and aspect ratio on actual defect detection are negligible. The wavelet bandwidth, the standard deviation and the wavelength have a certain relation, and the standard deviation is set to be a proper fixed value, so that the bandwidth is influenced by the wavelength, and therefore, the influence of the standard deviation and the bandwidth on defect detection can be solved by controlling the wavelength, namely, the influence of the standard deviation parameter is ignored during actual defect detection, and only the influence of the wavelength is considered.
Furthermore, because the variable parameters only have two parameters of wavelength and direction, and for the regular products such as the mobile phone glass cover plate, the direction parameters only need to calculate the horizontal direction and the vertical direction, therefore, it can be understood that the influence of one parameter of wavelength is generally considered in the actual operation, that is, different wavelet kernels can be obtained only by adjusting the wavelength to deal with different background images.
The method is mainly applied to detecting appearance defects such as scratches, stabbing wounds, concave-convex pits, stamping, edge breakage, heterochromatic colors, ink shortage and the like on the surface of a product, and has strong algorithm pertinence, so that a proportionality coefficient between the wavelength and the wavelet kernel size can be set to be an empirical constant.
As a further technical solution, the size of the wavelet kernel is preferably 35 × 35. When defect detection is actually carried out, the size of a wavelet kernel is 35 x 35 by default, if the detection effect obtained by the value is not good, the size of the defect is analyzed, if the defect is large, the size is increased, and if the defect is small, the size is reduced.
As a further technical scheme, after a filtering image is obtained, the filtering image data is converted into a Byte format, and the gray scale is stretched to a range from 0 to 255. The purpose of this is to convert the real number type into the Byte type of 0-255 because the real number type is a real number type after the image convolution calculation is completed, and it is inconvenient to intuitively perform defect region extraction. In the stretching process, since the original data has positive and negative numbers, the zero point of the data is translated to 128 positions, the negative number interval [ min,0] is scaled to 0-127, and the positive number interval [0, max ] is scaled to 128-255.
As a further technical scheme, for irregular products, a product image is cut into a combination of a plurality of regular images, and the horizontal direction and the vertical direction of a wavelet kernel after wavelet transformation of the regular images are calculated. In actual detection, most products are regular in shape, and for direction parameters, only horizontal and vertical directions need to be calculated; for a few irregular products, the calculation can also be performed by cropping the image into a combination of regular images.
As a further technical solution, the step of extracting the defect area based on the filtered image by using a hysteresis threshold further includes: setting two thresholds C0 and C1, firstly utilizing the threshold C0 to binarize the image to obtain a defect region R0, then utilizing C1 to traverse the gray value of the adjacent pixel of R0, if the gray value is between [ C1 and C0], adding the pixel position into the R0 region, and repeating the steps until the gray value of the pixel around R0 is smaller than C1. The reason why the C1 partitioning is not directly adopted here is that: 1) the hysteresis threshold can filter the region of which the gray scale is less than C0 but greater than C1 in the whole region, and only extracts the region of which the gray scale is greater than C0, thereby reducing false detection; 2) and the hysteresis threshold divides the area with the gray scale larger than C0 without losing the surrounding area smaller than C1, thereby ensuring the integrity of the defect.
There is also provided, in accordance with an embodiment of the present invention, a memory having stored thereon program instructions, which when executed by a processor, implement the above-described wavelet transform-based product surface defect detection method.
According to an embodiment of the present invention, there is further provided a processor, configured to execute a program, where the program executes the method for detecting surface defects of a product based on wavelet transform.
Compared with the prior art, the invention has the beneficial effects that:
(1) firstly, reading an original image of a product, inputting the size and direction of a wavelet kernel, generating the wavelet kernel by utilizing wavelet transformation calculation, and performing convolution operation by utilizing the wavelet kernel and the original image of the product to obtain a filtered image, thereby realizing self-adaptive filtering of a complex image background and highlighting a defect area; for different types of defects, wavelet kernels with different sizes and wavelet directions can be input for defect detection, the purpose of detecting different types of defects by one method is achieved, image processing algorithms do not need to be developed for certain types or certain types of defects, and development cost is greatly reduced.
(2) In the detection process, a user only needs to know what result is obtained when the wavelet kernel becomes large or small or what result is obtained when the wavelet direction changes, the relation among all parameters of the wavelet does not need to be considered, the detection of different types of defects is realized by inputting different wavelet kernel sizes and wavelet directions, the detection method is simple, the parameter debugging process is intuitive, the method is suitable for actual operators on a production line, and the method has better application and popularization values.
(3) The method can be suitable for different defect types in different regions, can accurately extract the defect position by adjusting two parameters of the wavelet kernel size and the hysteresis threshold, does not need excessive detection parameters, is convenient to debug and improves the practicability.
Drawings
Fig. 1 is a flowchart of a method for detecting surface defects of a product based on wavelet transformation according to an embodiment of the present invention.
Fig. 2 is a diagram illustrating a wavelet image calculated under the condition that the standard deviation (σ) is changed, the wavelength, the direction, the phase shift and the aspect ratio are kept unchanged according to the embodiment of the present invention.
Fig. 3 is a schematic diagram of a wavelet image obtained by calculation under the condition of changing wavelength (λ) and keeping unchanged direction, phase shift, aspect ratio and standard deviation according to the embodiment of the invention.
Fig. 4 is a schematic diagram of a wavelet image obtained by calculation under the condition that the phase (Ψ) is changed and the wavelength, the direction, the aspect ratio and the standard deviation are unchanged according to the embodiment of the invention.
Fig. 5 is a schematic diagram of a wavelet image obtained by calculation under the condition that the aspect ratio (gamma) is changed, the wavelength, the direction, the phase shift and the standard deviation are unchanged according to the embodiment of the invention.
Fig. 6 is a schematic diagram of a wavelet image obtained by calculation under the condition that the direction (θ) is changed, and the wavelength, the phase shift, the standard deviation and the aspect ratio are unchanged according to the embodiment of the invention.
Fig. 7 is a schematic diagram of a filtered image obtained by convolving wavelet kernels with original images of the surface of a product in horizontal directions and at different wavelengths according to an embodiment of the invention.
Fig. 8 is a schematic diagram of a filtered image obtained by convolving wavelet kernels with original images of the surface of a product in different wavelengths in the vertical direction according to an embodiment of the present invention.
FIG. 9 is a diagram illustrating the defect detection effect of product surface stabbing according to an embodiment of the present invention.
FIG. 10 is a diagram illustrating the effect of defect detection on color spots of product edges according to an embodiment of the present invention.
FIG. 11 is a diagram illustrating the defect detection effect of edge chipping of a glass product according to an embodiment of the present invention.
FIG. 12 is a diagram of the defect detection effect of the slight scratch on the surface of the product according to the embodiment of the invention.
Detailed Description
The technical solutions of the embodiments of the present invention will be described clearly and completely with reference to the accompanying drawings, and it is to be understood that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the present invention without any inventive step, are within the scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
In accordance with one embodiment of the present invention, there is provided an embodiment of a method for detecting surface defects of a product based on wavelet transformation, wherein the steps shown in the flowchart of the figure can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown. The invention is based on Wavelet transform, and like Fourier Transform (FT), Wavelet Transform (WT) also belongs to the category of mathematical transform, and it uses a cluster of Wavelet function system to represent or approximate a certain signal, so that Wavelet function can be used to represent or approximate a certain signal
Figure 155797DEST_PATH_IMAGE001
And scale function
Figure 836178DEST_PATH_IMAGE002
To express the relationship between them, the specific relationship is as follows:
Figure 575463DEST_PATH_IMAGE003
wavelet transform has a unique spatial (time domain) and frequency domain "zoom" analysis capability compared to fourier transform.
According to an aspect of the present specification, there is provided a method for detecting surface defects of a product based on wavelet transform, comprising the steps of:
step 1, reading in an original image;
and 2, inputting wavelet kernel sizes and wavelet directions, wherein the range of the wavelet kernel sizes is 15-60, the range of the wavelet directions is 0-2 pi, performing wavelet transformation by adopting a Gabor wavelet function, and calculating wavelet kernels.
This step is to compute the wavelet convolution kernel to facilitate convolution with the original product surface image in step 3. The wavelet function adopted in the step is a Gabor wavelet function.
The Gabor function is as follows:
Figure 78645DEST_PATH_IMAGE004
Figure 827158DEST_PATH_IMAGE005
real part:
Figure 362044DEST_PATH_IMAGE006
imaginary part:
Figure 537811DEST_PATH_IMAGE007
wherein:
wavelength (λ): the wavelength parameter of the cosine function in the Gabor kernel function is represented. Its value is specified in units of pixels, and is usually equal to or greater than 2, but cannot be greater than one fifth of the input image size.
Direction (θ): representing the direction of the parallel strips in the Gabor filter kernel. The effective value is a real number from 0 to 360 degrees.
Phase shift (Ψ): representing the phase parameter of the cosine function in the Gabor kernel function. It takes on a value range of-180 degrees to 180 degrees. Wherein the equations corresponding to 0 degree and 180 degree are symmetrical with the origin, and the equations of-90 degree and 90 degree are respectively centrosymmetric with the origin.
Aspect ratio (γ): the spatial aspect ratio determines the ellipticity of the shape of the Gabor function. When γ =1, the shape is circular; when γ <1, the shape elongates with the parallel stripe direction. Typically this value is 0.5.
Bandwidth (b): the half-response spatial frequency bandwidth b of the Gabor filter is related to the ratio of σ/λ, where σ represents the standard deviation of the gaussian factor of the Gabor function. The relationship between the three is as follows:
Figure 259779DEST_PATH_IMAGE008
the bandwidth value must be positive and real, typically 1, and in this case, the standard deviation and wavelength have a relationship of σ =0.56 λ.
According to the above expression, the influence of each parameter cannot be intuitively sensed, so the Gabor function is calculated by utilizing OpenCV simulation to intuitively express the influence of each parameter on defect detection.
According to the above formula, the standard deviation σ and the bandwidth b have a variation relationship, in the Opencv simulation process, σ is used to express the bandwidth b, the wavelet kernel size (wavelet kernel image size) is set to 300 × 300 pixels (the size is selected to make the drawing clearer and is not used for limiting the parameter selection of the invention), then the wavelet image is calculated by using the real part function of Gabor and different parameters, and the result is shown in fig. 2 to 6 (in the drawing, the light and dark stripes are actually two-dimensional waveform diagrams, the light band represents the peak, and the dark band represents the trough).
Figure 2 depicts the computed wavelet image with the standard deviation (σ) changed, and with the wavelength, orientation, phase shift, and aspect ratio held constant. As can be seen from the figure, when the standard deviation (σ) is changed, the length of the stripes changes, and the number of stripes also changes.
Fig. 3 depicts the computed wavelet image with varying wavelength (λ), orientation, phase shift, aspect ratio, and standard deviation. As can be seen from the figure, when the wavelength (λ) is changed, the number and the pitch of the stripes are changed, and the length of the stripes is not changed.
Fig. 4 depicts the computed wavelet image with the phase (Ψ) changed and the wavelength, orientation, aspect ratio, and standard deviation unchanged. It can be seen from the figure that when the phase (Ψ) is changed, the number, the pitch, and the length of the stripes are all unchanged, and the light and shade sequence is changed.
Fig. 5 depicts the computed wavelet image with varying aspect ratio (γ), and unchanged wavelength, direction, phase shift, and standard deviation. As can be seen from the figure, when the aspect ratio (γ) is changed, the number, pitch, and light-dark order of the stripes are not changed, and the length of the stripes is changed.
Fig. 6 depicts the computed wavelet image with the orientation (θ) changed and the wavelength, phase shift, standard deviation, and aspect ratio unchanged. As can be seen from the figure, when the direction (θ) is changed, the number, the pitch, the light and shade order, and the length of the stripes are not changed, and the stripe direction is changed.
In view of the above results, the wavelength (λ) determines the stripe pitch and number, the direction (θ) determines the stripe direction, the phase shift (Ψ) determines the stripe shading order, the aspect ratio (γ) determines the stripe length, and the standard deviation (σ) changes both the stripe length and number. While the fringe shading order change has little effect on the results, so the effect of phase shift on defect detection can be ignored. The aspect ratio is usually a fixed value of 0.3, i.e. the stripe length ratio is fixed, and has little influence on the detection result in actual detection. In addition, the standard deviation, the bandwidth and the wavelength have the expression relationship, and the standard deviation is set to be 5 in actual operation, so that the bandwidth is only influenced by the wavelength, and therefore, the bandwidth can only be considered to change along with the wavelength, and the influence of the bandwidth on the detection result can be classified as the influence of the wavelength on the detection result. In summary, only the wavelength and the direction have a large influence on the final defect detection, and therefore, different wavelet images are obtained by mainly adjusting the two parameters.
And 3, performing convolution operation on the generated wavelet kernel and the original image to obtain a filtering image.
This step is a conventional image convolution calculation, and the convolution function is as follows:
Figure 280825DEST_PATH_IMAGE009
wherein the content of the first and second substances,
Figure 139059DEST_PATH_IMAGE010
: the function of the original image is selected,
Figure 220148DEST_PATH_IMAGE011
the function of the convolution kernel image is,
Figure 694991DEST_PATH_IMAGE012
a calculated image function for convolution.
In OpenCV, convolution operations are performed with the original image using different wavelet kernels, and the results are compared, as shown in fig. 7-8.
FIG. 7 depicts a filtered image after convolution of wavelet kernels of different wavelengths in the horizontal direction with the original image of the product surface. As can be seen from the figure, the horizontal wavelets can filter out the vertical texture of the product surface and retain the defect positions. But wavelets with proper wavelengths can better keep the original appearance of wavelets, wavelets with shorter stripes can keep defect detail characteristics more completely after convolution, but details are more fuzzy, and the convolution result does not influence the final detection rate.
Fig. 8 depicts the filtered image after convolution of wavelet kernels of different wavelengths in the vertical direction with the original image of the product surface. It can be known from the figure that the vertical wavelet highlights the vertical texture of the background, which weakens the defects and is not beneficial to detection, so that it is very important to select the correct direction. The product surface with vertical texture is preferably horizontal direction wavelet, the product surface with horizontal texture is preferably vertical direction wavelet, and similarly, the wavelet with inclined texture and 90-degree difference from the background is selected to have better effect.
As can be further explained from the above results, the most significant to the results are the wavelet direction and wavelength. Therefore, the standard deviation (σ), the phase (Ψ), and the aspect ratio (γ) in step 2 may all be set to fixed values, while the wavelength (λ) is set to the product of the wavelet size and the scaling factor when calculating the wavelet kernel. The method is mainly applied to detecting appearance defects such as scratches, stabbing wounds, concave-convex pits, stamping, edge breakage, heterochromatic colors, ink shortage and the like on the surface of a product, and has strong algorithm pertinence, so that the proportionality coefficient can be set to be an empirical constant.
When the size of the wavelet is changed, the wavelet fringe size is also changed, and the wavelength (λ) is also changed. Therefore, we can finally control the size and direction of the wavelet at the code level. Most products are regular in shape, and for irregular products, the images can be cut into a plurality of regular image combinations. Therefore, in most cases θ only needs to calculate two directions, i.e., the horizontal direction and the vertical direction.
When different types of defect detection is carried out, different wavelet cores can be obtained only by adjusting the size of the wavelet cores and selecting the wavelet direction, so that different background images and different defect sizes can be dealt with, and the purpose of self-adaption is further achieved.
And 4, converting the image data into a Byte format, and stretching the gray scale to a range from 0 to 255.
And after the image convolution calculation is finished, the result is a real number type. The main purpose of this step is to convert a real number type to a Byte type of 0-255. In the stretching process, since the original data has positive and negative numbers, the zero point of the data is translated to 128 positions, the negative number interval [ min,0] is scaled to 0-127, and the positive number interval [0, max ] is scaled to 128-255.
And 5, extracting the defect area by adopting a hysteresis threshold value mode.
The boundary of the actual defect on the image is not particularly obvious, so that the complete defect area cannot be obtained by directly adopting threshold segmentation. Therefore, this step employs a hysteresis threshold extraction method similar to the Canny algorithm. The hysteresis threshold needs to set two thresholds C0 and C1, the threshold C0 is firstly used for binarizing the image to obtain a defective region R0, then the C1 is used for traversing the gray value of the adjacent pixel of R0, if the gray value is between [ C1 and C0], the pixel position is added to the R0 region, and the iteration is carried out until the gray value of the pixel around R0 is smaller than C1.
According to an aspect of the present specification, there is also provided a memory having stored thereon program instructions that, when executed by a processor, implement the wavelet transform-based product surface defect detection method described above.
According to an aspect of the present specification, there is further provided a processor for executing a program, where the program executes the wavelet transform-based product surface defect detection method.
As shown in fig. 9 to 12, the present embodiment provides a method for detecting surface defects of a product based on wavelet transform, including:
step 1, reading an original image on the surface of a product, such as the product surface stabbing shown in fig. 9, the product edge abnormal color points shown in fig. 10, the glass product edge chipping shown in fig. 11, and the product surface slight scratching shown in fig. 12.
And 2, inputting the size of the wavelet kernel, selecting the wavelet direction, and performing wavelet transformation by combining the phase offset, the length-width ratio and the standard deviation parameters of the Gabor function to generate the wavelet kernel.
And 3, performing convolution operation on the wavelet kernel and the original image, and filtering out background stripes to obtain a filtered image.
And 4, performing gray scale stretching on the filtered image, namely converting the image data into a Byte format, and stretching the gray scale to a range of 0 to 255, such as the wavelet-processed image shown in fig. 9-12.
And step 5, extracting a defect area by adopting a hysteresis threshold mode according to a set threshold, and highlighting the defect area, wherein the defect area is extracted as shown in the figures 9-12.
In actual detection, under the condition that phase shift, an aspect ratio and a standard deviation are not changed, a plurality of groups of wavelength and direction parameter combinations are input to obtain a plurality of filter images, and defect extraction is performed on the plurality of filter images respectively to detect different types of defect regions. Specifically, for products such as mobile phone covers, the surface images of the products are usually regular, the directions only need to be calculated in the horizontal direction and the vertical direction, and the wavelength is set as the product of the wavelet kernel and the empirical coefficient, so when actual parameters are input, defect detection is usually performed by inputting different wavelet kernel sizes and wavelet directions. The wavelet kernel size is generally between 15 × 15 and 60 × 60, preferably 35 × 35.
In the description herein, references to the description of the terms "one embodiment," "certain embodiments," "an illustrative embodiment," "an example," "a specific example," or "some examples," etc., mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the invention. In this specification, schematic representations of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions deviate from the technical solutions of the embodiments of the present invention.

Claims (6)

1. The method for detecting the surface defects of the products based on the wavelet transform is characterized by comprising the following steps:
acquiring an original image;
inputting wavelet kernel size and wavelet direction, wherein the range of the wavelet kernel size is 15-60 x 60, the range of the wavelet direction is 0-2 pi, performing wavelet transformation by adopting a Gabor wavelet function, and calculating a wavelet kernel; the Gabor wavelet function comprises 5 input parameters, wherein the phase offset, the aspect ratio and the standard deviation are fixed parameters and are set before actual detection; the wavelength and the direction are variable parameters and can be adjusted within a preset range in the actual detection process; the wavelength is the product of the wavelet kernel size and a proportionality coefficient, and the proportionality coefficient is set as an empirical constant;
performing convolution operation on the generated wavelet kernel and the original image to obtain a filtering image;
and extracting the defect area by adopting a hysteresis threshold value mode based on the filtered image.
2. The wavelet transform-based product surface defect detection method of claim 1, wherein after obtaining the filtered image, converting the filtered image data to Byte format and stretching the gray scale to the interval of 0 to 255.
3. The wavelet transform-based product surface defect detection method of claim 1, wherein for irregular products, the product image is cropped into a combination of a plurality of regular images, and the horizontal direction and the vertical direction of the wavelet kernel after wavelet transform of the regular images are calculated.
4. The wavelet transform-based product surface defect detection method of claim 1, wherein the step of extracting the defect region by means of a hysteresis threshold based on the filtered image further comprises: setting two thresholds C0 and C1, firstly utilizing the threshold C0 to binarize the image to obtain a defect region R0, then utilizing C1 to traverse the gray value of the adjacent pixel of R0, if the gray value is between [ C1 and C0], adding the position of the pixel into the R0 region, and repeating the steps until the gray value of the pixel around R0 is smaller than C1.
5. Memory, on which program instructions are stored, which, when executed by a processor, implement the detection method according to any one of claims 1 to 4.
6. A processor, characterized in that the processor is configured to run a program, wherein the program when running performs the detection method of any one of claims 1-4.
CN202011559294.3A 2020-12-25 2020-12-25 Product surface defect detection method based on wavelet transformation, memory and processor Active CN112288745B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011559294.3A CN112288745B (en) 2020-12-25 2020-12-25 Product surface defect detection method based on wavelet transformation, memory and processor

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011559294.3A CN112288745B (en) 2020-12-25 2020-12-25 Product surface defect detection method based on wavelet transformation, memory and processor

Publications (2)

Publication Number Publication Date
CN112288745A CN112288745A (en) 2021-01-29
CN112288745B true CN112288745B (en) 2021-04-02

Family

ID=74426176

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011559294.3A Active CN112288745B (en) 2020-12-25 2020-12-25 Product surface defect detection method based on wavelet transformation, memory and processor

Country Status (1)

Country Link
CN (1) CN112288745B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9989479B1 (en) * 2013-03-15 2018-06-05 Kla-Tencor Corporation System and method to determine depth for optical wafer inspection
CN108171688A (en) * 2017-12-19 2018-06-15 浙江大学 A kind of wafer surface defects detection method based on Gabor characteristic Yu random dimensionality reduction
CN109035198A (en) * 2018-06-07 2018-12-18 华南理工大学 The LED detection method of outdoor visible light communication based on edge detection
CN109060838A (en) * 2018-07-23 2018-12-21 三固(厦门)科技有限公司 A kind of product surface scratch detection method based on machine vision
CN109472783A (en) * 2018-10-31 2019-03-15 湘潭大学 A kind of nickel foam surface defect is extracted and classification method
CN109489724A (en) * 2018-12-03 2019-03-19 大连维德轨道装备有限公司 A kind of tunnel safe train operation environment comprehensive detection device and detection method

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111709433A (en) * 2020-06-19 2020-09-25 汪礼君 Multi-feature fusion image recognition algorithm

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9989479B1 (en) * 2013-03-15 2018-06-05 Kla-Tencor Corporation System and method to determine depth for optical wafer inspection
CN108171688A (en) * 2017-12-19 2018-06-15 浙江大学 A kind of wafer surface defects detection method based on Gabor characteristic Yu random dimensionality reduction
CN109035198A (en) * 2018-06-07 2018-12-18 华南理工大学 The LED detection method of outdoor visible light communication based on edge detection
CN109060838A (en) * 2018-07-23 2018-12-21 三固(厦门)科技有限公司 A kind of product surface scratch detection method based on machine vision
CN109472783A (en) * 2018-10-31 2019-03-15 湘潭大学 A kind of nickel foam surface defect is extracted and classification method
CN109489724A (en) * 2018-12-03 2019-03-19 大连维德轨道装备有限公司 A kind of tunnel safe train operation environment comprehensive detection device and detection method

Also Published As

Publication number Publication date
CN112288745A (en) 2021-01-29

Similar Documents

Publication Publication Date Title
Jia et al. Fabric defect inspection based on lattice segmentation and Gabor filtering
CN102879401B (en) Method for automatically detecting and classifying textile flaws based on pattern recognition and image processing
CN108355981B (en) Battery connector quality detection method based on machine vision
CN111179225B (en) Test paper surface texture defect detection method based on gray gradient clustering
Mizushima et al. An image segmentation method for apple sorting and grading using support vector machine and Otsu’s method
Yiyang The design of glass crack detection system based on image preprocessing technology
CN110766689A (en) Method and device for detecting article image defects based on convolutional neural network
CN103530878B (en) A kind of edge extracting method based on convergence strategy
CN106846313B (en) Workpiece surface defect detection method and device
CN109919960B (en) Image continuous edge detection method based on multi-scale Gabor filter
CN103175844A (en) Detection method for scratches and defects on surfaces of metal components
Espinal et al. Wavelet-based fractal signature analysis for automatic target recognition
US20090245680A1 (en) System and method for illumination invariant image segmentation
Dixit et al. Image texture analysis-survey
CN113221881B (en) Multi-level smart phone screen defect detection method
WO2023231262A1 (en) Hoisting wire rope tension measurement method based on visual vibration frequency identification
Tripathy Detection of cotton leaf disease using image processing techniques
CN112288745B (en) Product surface defect detection method based on wavelet transformation, memory and processor
CN116309561B (en) Surface defect identification method based on anti-creeping insulating material
Haoran et al. Egg crack detection based on support vector machine
CN108765426A (en) automatic image segmentation method and device
Newson et al. Robust automatic line scratch detection in films
Hidayat et al. Real-time Texture Boundary Detection from Ridges in the Standard Deviation Space.
CN101719273A (en) On-line self-adaptation extraction method of metallurgy strip surface defect based on one-dimension information entropy
CN114119634A (en) Automatic building extraction method and system combining vegetation elimination and image feature consistency constraint

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20221209

Address after: No. A1002, Plant 3, Longgang Tian'an Digital Innovation Park, No. 449, Huangge North Road, Huanggekeng Community, Longcheng Street, Longgang District, Shenzhen, Guangdong 518,116

Patentee after: Shenzhen Huagong Measurement Engineering Technology Co.,Ltd.

Address before: 430223 laser Industrial Park, science and technology zone, Huazhong University of Science and Technology, East Lake Development Zone, Wuhan, Hubei

Patentee before: WUHAN HUAGONG LASER ENGINEERING Co.,Ltd.

TR01 Transfer of patent right