CN111325728B - Product defect detection method, device, equipment and storage medium - Google Patents

Product defect detection method, device, equipment and storage medium Download PDF

Info

Publication number
CN111325728B
CN111325728B CN202010102720.4A CN202010102720A CN111325728B CN 111325728 B CN111325728 B CN 111325728B CN 202010102720 A CN202010102720 A CN 202010102720A CN 111325728 B CN111325728 B CN 111325728B
Authority
CN
China
Prior art keywords
image
product
segmentation result
algorithm
image segmentation
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
CN202010102720.4A
Other languages
Chinese (zh)
Other versions
CN111325728A (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.)
Southern University of Science and Technology
Original Assignee
Southern University of Science and Technology
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 Southern University of Science and Technology filed Critical Southern University of Science and Technology
Priority to CN202010102720.4A priority Critical patent/CN111325728B/en
Publication of CN111325728A publication Critical patent/CN111325728A/en
Application granted granted Critical
Publication of CN111325728B publication Critical patent/CN111325728B/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
    • G06T7/0006Industrial image inspection using a design-rule based approach
    • 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/13Edge detection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/155Segmentation; Edge detection involving morphological operators
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10004Still image; Photographic image
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/30Computing systems specially adapted for manufacturing

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Investigating Materials By The Use Of Optical Means Adapted For Particular Applications (AREA)
  • Image Analysis (AREA)
  • Image Processing (AREA)

Abstract

The invention discloses a product defect detection method, a device, equipment and a storage medium, and relates to the technical field of automatic detection, wherein the product defect detection method comprises the following steps: acquiring an image of a product to be detected; processing the image of the product to be detected by adopting a discipline algorithm to obtain a first image segmentation result; processing the product image to be detected by adopting a Gaussian mixture model algorithm to obtain a second image segmentation result; and processing the first image segmentation result and the second image segmentation result by adopting a post-processing algorithm to obtain a detection result. The invention can greatly improve the detection speed, is suitable for detecting surface defects of different types of products, can reduce the influence of external factors such as different light sources, the placing angles of detection pieces, shadow conditions and the like on the detection result, and realizes the accurate detection of the product defects of the production line.

Description

Product defect detection method, device, equipment and storage medium
Technical Field
The present invention relates to the field of automatic detection technologies, and in particular, to a method, an apparatus, a device, and a storage medium for detecting product defects.
Background
In the industrial production process, the appearance of the produced product is poor due to the external environments such as mechanical vibration, sound, light and the like and the complex production process, so that the produced product becomes a defective product, and the production efficiency is reduced. In order to ensure that the appearance of the product meets the corresponding production requirements, a series of detection needs to be carried out on the product in the industrial production process.
At present, the product surface defect detection method mainly comprises two kinds of manual detection and machine vision detection. The manual detection mode has the problems of low detection efficiency, high production cost of products and the like. The machine vision detection mode can realize automation of surface defect detection, but the surface defect detection model in the existing machine vision detection is only used for detecting a specific product surface or a specific type of defect. However, in an actual production process, one production line may produce a plurality of products, and the types of surface defects of different types of products may be different. At this time, when detecting surface defects for different products, different surface defect detection models need to be designed and developed, the whole process period is long, and the consumed time and labor cost are high.
Disclosure of Invention
The object of the present invention is to solve at least to some extent one of the technical problems existing in the prior art. Therefore, the invention provides a product defect detection method which can greatly improve the detection speed and is suitable for detecting surface defects of different types of products.
The invention also provides a device for detecting the product defects.
The invention also provides product defect detection equipment.
The invention also proposes a computer readable storage medium.
In a first aspect, an embodiment of the present invention provides a product defect detection method, including:
acquiring an image of a product to be detected;
processing the image of the product to be detected by adopting an law (Otsu) algorithm to obtain a first image segmentation result;
processing the product image to be detected by adopting a Gaussian mixture model algorithm to obtain a second image segmentation result;
and processing the first image segmentation result and the second image segmentation result by adopting a post-processing algorithm to obtain a detection result.
The product defect detection method provided by the embodiment of the invention has at least the following beneficial effects:
1. the detection speed can be greatly improved;
2. the method is suitable for detecting surface defects of different types of products;
3. the influence of external factors such as different light sources, the placement angles of the detection pieces, the shadow conditions and the like on the detection result can be reduced, and the accurate detection of the defects of the products of the production line is realized.
According to other embodiments of the present invention, a product defect detection method, which uses Otsu algorithm to process an image of a product to be detected, obtains a first image segmentation result, includes:
carrying out gray scale treatment on the image of the product to be detected to obtain a gray scale image;
gamma correction is carried out on the gray level map to obtain a gamma correction map;
otsu segmentation is carried out on the gamma correction graph, and Otsu segmentation results are obtained;
carrying out morphological treatment on the Otsu segmentation result to obtain a morphological correction result;
and carrying out median filtering on the morphological correction result to obtain a first image segmentation result.
The product defect detection method of the embodiment of the invention improves the traditional Otsu algorithm, wherein the traditional Otsu algorithm comprises gray scale processing and Otsu segmentation, and the improved Otsu algorithm also comprises gamma correction, morphological processing and median filtering. Compared with the traditional Otsu algorithm, the improved Otsu algorithm is simpler and more convenient to calculate, so that the product image can be rapidly and stably detected without consuming a large amount of calculation time, and the detection accuracy is improved.
According to another embodiment of the present invention, a method for detecting a product defect performs morphological processing on Otsu segmentation results to obtain morphological correction results, including:
and carrying out gray level smoothing and edge smoothing on the Otsu segmentation result by adopting a low-pass filtering method to obtain a morphological correction result.
According to other embodiments of the present invention, a product defect detection method, which uses a gaussian mixture model algorithm to process an image of a product to be detected, obtains a second image segmentation result, includes:
carrying out Hue Saturation Value (HSV) space color extraction on a product image to be detected to obtain an HSV color chart;
and carrying out Expected Maximum (EM) algorithm segmentation on the HSV color map to obtain a second image segmentation result.
According to the product defect detection method, the pixel value of the input product image to be detected is simulated through the Gaussian mixture model, and the type of each pixel point is determined through different single Gaussian models, so that the product image is detected, and a second image segmentation result is obtained.
According to a product defect detection method of other embodiments of the present invention, an EM algorithm segmentation is performed on an HSV color chart to obtain a second image segmentation result, including:
establishing a Gaussian mixture model;
processing the HSV color map by adopting a Gaussian mixture model to obtain the model number of the Gaussian mixture model;
obtaining an optimization model of the Gaussian mixture model according to the model number of the Gaussian mixture model;
and carrying out parameter estimation on the optimization model by adopting an EM algorithm to obtain a second image segmentation result.
According to another embodiment of the present invention, a product defect detection method uses a post-processing algorithm to process a first image segmentation result and a second image segmentation result to obtain a detection result, including:
processing the first image segmentation result and the second image segmentation result to obtain a third image segmentation result;
and performing leak edge detection and leak repair on the third image segmentation result by adopting a morphological reconstruction method to obtain a detection result.
According to the product defect detection method, through leak edge detection and leak repair, the problem that the EM algorithm is difficult to classify correctly due to illumination can be solved, and therefore the accuracy of the EM algorithm detection is improved.
In a second aspect, an embodiment of the present invention provides a product defect detecting apparatus, including:
the image acquisition module is used for acquiring an image of a product to be detected;
the first image segmentation module is used for processing the product image to be detected by adopting an Otsu algorithm to obtain a first image segmentation result;
the second image segmentation module is used for processing the product image to be detected by adopting a Gaussian mixture model algorithm to obtain a second image segmentation result;
and the post-processing module is used for processing the first image segmentation result and the second image segmentation result by adopting a post-processing algorithm to obtain a detection result.
The product defect detection device provided by the embodiment of the invention has at least the following beneficial effects:
1. the first image segmentation module has stable and rapid segmentation result, the second image segmentation module has accurate segmentation result and higher calculation speed, and a large number of training samples are not needed;
2. the post-processing module processes the first image segmentation result and the second image segmentation result, so that the product image can be reliably detected, and the detection speed can be greatly improved;
3. the method is suitable for detecting surface defects of different types of products;
4. the influence of external factors such as different light sources, the placement angles of the detection pieces, the shadow conditions and the like on the detection result can be reduced, and the accurate detection of the defects of the products of the production line is realized.
According to other embodiments of the present invention, a product defect detection apparatus includes a post-processing algorithm including hole edge detection and hole repair.
In a third aspect, an embodiment of the present invention provides a product defect detection apparatus, comprising:
at least one processor, and,
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform a product defect detection method of some embodiments of the present invention.
The product defect detection equipment provided by the embodiment of the invention has at least the following beneficial effects:
1. the detection speed can be greatly improved;
2. the method is suitable for detecting surface defects of different types of products;
3. the influence of external factors such as different light sources, the placement angles of the detection pieces, the shadow conditions and the like on the detection result can be reduced, and the accurate detection of the defects of the products of the production line is realized.
In a fourth aspect, one embodiment of the present invention provides a computer-readable storage medium storing computer-executable instructions for causing a computer to perform a product defect detection method of some embodiments of the present invention.
The computer readable storage medium of the embodiment of the invention has at least the following beneficial effects:
1. the detection speed can be greatly improved;
2. the method is suitable for detecting surface defects of different types of products;
3. the influence of external factors such as different light sources, the placement angles of the detection pieces, the shadow conditions and the like on the detection result can be reduced, and the accurate detection of the defects of the products of the production line is realized.
Drawings
FIG. 1 is a flow chart of a method for detecting defects of a product according to an embodiment of the invention;
FIG. 2 is a flow chart of another embodiment of a method for detecting product defects according to an embodiment of the present invention;
FIG. 3 is a flow chart of another embodiment of a method for detecting product defects according to an embodiment of the present invention;
FIG. 4 is a flow chart of another embodiment of a method for detecting product defects according to an embodiment of the present invention;
FIG. 5 is a block diagram of a product defect inspection apparatus according to an embodiment of the present invention.
Detailed Description
The conception and the technical effects produced by the present invention will be clearly and completely described in conjunction with the embodiments below to fully understand the objects, features and effects of the present invention. It is apparent that the described embodiments are only some embodiments of the present invention, but not all embodiments, and that other embodiments obtained by those skilled in the art without inventive effort are within the scope of the present invention based on the embodiments of the present invention.
In the description of the present invention, if a feature is referred to as being "disposed", "fixed", "connected" or "mounted" on another feature, it can be directly disposed, fixed or connected to the other feature or be indirectly disposed, fixed or connected or mounted on the other feature.
In the description of the embodiments of the present invention, if "plurality" is referred to, it means two or more, if "greater than", "less than", "exceeding" is referred to, it should be understood that the number is not included, and if "above", "below", "within" is referred to, it should be understood that the number is included. If reference is made to "first", "second" it is to be understood as being used for distinguishing technical features and not as indicating or implying relative importance or implicitly indicating the number of technical features indicated or implicitly indicating the precedence of the technical features indicated.
Example 1
Referring to fig. 1, a flow chart of a specific embodiment of a method for detecting product defects according to an embodiment of the invention is shown. As shown in fig. 1, a product defect detection method according to an embodiment of the present invention includes the following specific steps:
s1000, acquiring an image of a product to be detected.
And acquiring an image of the product to be detected, and scanning the product to be detected by using product scanning imaging equipment to acquire an image sample of the product to be detected.
S1100, processing the image of the product to be detected by adopting an law (Otsu) algorithm to obtain a first image segmentation result.
The Otsu algorithm is to divide an image into two parts, namely a background and a target according to the gray scale characteristics of the image. The larger the inter-class variance between the background and the object, the larger the difference between the two parts constituting the image, which results in a smaller difference between the two parts when a part of the object is divided into the background by mistake, or a part of the background is divided into the object by mistake. Thus, a segmentation that maximizes the inter-class variance means that the probability of misclassification is minimal.
In other embodiments of the present invention, referring to fig. 2, a schematic flow chart of another embodiment of a method for detecting a product defect in an embodiment of the present invention is shown. As shown in fig. 2, in the product defect detection method according to the embodiment of the present invention, an Otsu algorithm is adopted to process an image of a product to be detected, so as to obtain a first image segmentation result, and the specific steps include:
s1110, carrying out gray scale processing on the image of the product to be detected to obtain a gray scale image.
The color value of each pixel on a gray scale image, also referred to as gray scale, refers to the color depth at the midpoint of a black and white image, typically ranging from 0 to 255, with white being 255 and black being 0. The gradation value is the degree of shading of a color. In this embodiment, gray scale processing is performed on the product image to be detected, and any one of the following four modes may be adopted:
(1) The component method takes the brightness of three components in the RGB color image as the gray value of three gray images, and can select one gray image according to the application requirement.
(2) The maximum value method uses the maximum brightness value of three components in an RGB color image as the gray value of a gray scale map.
(3) The average method uses the average value of the brightness of three components in the RGB color image as the gray value of the gray map.
(4) The weighted average method is to weight-average three components in an RGB color image with different weights according to importance and other indexes.
S1120, gamma correction is carried out on the gray level image, and a gamma correction image is obtained.
Gamma correction can eliminate the effect of unbalance of illumination on imaging effect during picture acquisition. The gamma correction is performed on the gray scale map by performing a nonlinear operation on the gray scale values of the image so that the gray scale values of the output image and the gray scale values of the input image are exponentially related.
S1130, otsu segmentation is carried out on the gamma correction chart, and an Otsu segmentation result is obtained.
Otsu segmentation is carried out on the gamma correction chart, the threshold value is traversed from 0 to 255 in sequence, the optimal threshold value is searched, the optimal threshold value is taken to divide the gamma correction chart into a foreground color and a background color, and the larger the inter-class variance of the two parts is, the larger the difference of the two parts is, so that the image can be effectively segmented.
S1140, performing morphological processing on the Otsu segmentation result to obtain a morphological correction result.
Morphological processing is carried out on the Otsu segmentation result, so that edge burrs appearing in the Otsu segmentation result can be eliminated.
In other embodiments of the present invention, morphology processing is performed on the Otsu segmentation result to obtain a morphology correction result, including performing gray level smoothing and edge smoothing on the Otsu segmentation result by using a low-pass filtering method to obtain a morphology correction result.
The low-pass filtering method can flatten the pixel value in the gray level image, keep the points with little change (corresponding to the dividing areas), and filter the points with severe change of the pixel value in the image (corresponding to the edge burrs). The low-pass filtering method specifically comprises the following steps:
s1141, determining the size of the kernel function.
The linear inseparable mode of the low-dimensional space is mapped to the high-dimensional characteristic space through nonlinearity, so that the linear inseparable mode can be realized, but if the technology is directly adopted to classify or regress in the high-dimensional space, the problems of determining the form and the parameters of a nonlinear mapping function, the dimension of the characteristic space and the like exist, and the biggest obstacle is the dimension disaster existing in the operation of the high-dimensional characteristic space. Such problems can be effectively solved using kernel function techniques.
The kernel function can convert the inner product operation of the high-dimensional space into the kernel function calculation of the low-dimensional input space, thereby skillfully solving the problems of dimension disaster and the like calculated in the high-dimensional characteristic space. The size of the kernel function may be determined according to practical situations.
S1142, determining anchor point positions.
And selecting an anchor point position from the original image, wherein the anchor point position can be determined according to actual conditions.
S1143, determining the pixel value of the anchor point according to the kernel function and the anchor point position.
And determining the pixel value of the anchor point by calculating the pixel value of the area around the anchor point, and convolving the pixel value of the area around the anchor point with the weight of the kernel function to obtain the pixel value of the anchor point. By the kernel function, the pixel values of the smoothed region will not change, while the burr region will be re-smoothed due to the distribution of the number of surrounding pixels.
S1150, median filtering is carried out on the morphological correction result, and a first image segmentation result is obtained.
The method of median filtering is similar to the low-pass filtering method, except that the kernel function is selected differently. In the low-pass filtering, the pixel value of the anchor point is determined according to the weight of the kernel function and the pixel value of the area around the anchor point. Whereas in median filtering, the pixel value of the anchor point is the median of the kernel coverage area. Median filtering can eliminate minor defect areas that are not practical in Otsu segmentation.
The product defect detection method of the embodiment of the invention improves the traditional Otsu algorithm, wherein the traditional Otsu algorithm comprises gray scale processing and Otsu segmentation, and the improved Otsu algorithm also comprises gamma correction, morphological processing and median filtering. Compared with the traditional Otsu algorithm, the improved Otsu algorithm is simpler and more convenient to calculate, so that the product image can be rapidly and stably detected without consuming a large amount of calculation time, and the detection accuracy is improved.
S1200, processing the image of the product to be detected by adopting a Gaussian mixture model algorithm to obtain a second image segmentation result.
The gaussian mixture model precisely quantizes things by using a gaussian probability density function, and decomposes one thing into a plurality of models formed based on the gaussian probability density function. Principle and process of establishing gaussian model for image background: the image gray level histogram reflects the frequency of occurrence of a certain gray level value in the image and can also be regarded as an estimate of the probability density of the image gray level. If the image contains a target area and a background area which have a relatively large difference in gray scale, the gray scale histogram of the image assumes a double peak-valley shape, wherein one peak corresponds to the target and the other peak corresponds to the center gray scale of the background. For complex images, especially industrial product images, it is generally multimodal. By considering the multi-modal nature of the histogram as a superposition of multiple gaussian distributions, the problem of segmentation of the image can be solved.
In other embodiments of the present invention, referring to fig. 3, a schematic flow chart of another embodiment of a method for detecting a product defect in the embodiment of the present invention is shown. As shown in fig. 3, in the product defect detection method according to the embodiment of the present invention, a gaussian mixture model algorithm is used to process an image of a product to be detected, so as to obtain a second image segmentation result, and the specific steps include:
s1210, carrying out Hue Saturation Value (HSV) space color extraction on the image of the product to be detected to obtain an HSV color map.
S1220, carrying out Expected Maximum (EM) algorithm segmentation on the HSV color map to obtain a second image segmentation result.
In other embodiments of the present invention, the EM algorithm segmentation is performed on the HSV color map to obtain a second image segmentation result, which specifically includes the steps of:
s1221, establishing a Gaussian mixture model.
The mathematical expression form of the Gaussian mixture model of the embodiment of the invention is shown as a formula (1):
Figure BDA0002387409430000081
where x represents a pixel point, and p (x) represents a probability that the pixel point appears in the picture. k represents the type of pixel (defective or non-defective), and p (k) represents the probability of different pixel types in the picture. p (x/k) represents the probability of a pixel occurring in a picture given the pixel type. Pi k Like p (k), the probability of different pixel types in a picture is represented. Because the probability distribution of pixel types belongs to a discrete model, it can be represented by a number less than 1, and it should be noted that it must be satisfied
Figure BDA0002387409430000082
Is a condition of (2). N (x/mu) kk ) Represents a gaussian distribution, wherein μ k and Σk Mean and variance of the gaussian distribution are shown, respectively.
The nature of the gaussian mixture model is to blend several single gaussian models, making the model more complex, thus producing more complex samples. Theoretically, if the number of single Gaussian models fused by a certain Gaussian mixture model is enough, the weights between the single Gaussian models are set to be reasonable enough, and the mixture model can fit samples with arbitrary distribution.
S1222, processing the HSV color map by adopting a Gaussian mixture model to obtain the model number of the Gaussian mixture model.
The model number of the Gaussian mixture model in the embodiment of the invention is determined according to the formula (2):
Figure BDA0002387409430000091
wherein Y represents an input picture,
Figure BDA0002387409430000092
and θ represents a parameter of gaussian distribution, corresponding to μ in formula (1) kk
Figure BDA0002387409430000093
Representing the coding length of the input picture, pi k Representing the probability of different pixel types in the picture, P represents the parameter number of Gaussian distribution, K represents the model number, N represents the pixel number of each picture, and +.>
Figure BDA0002387409430000094
Representing a penalty term for the number of parameters.
The HSV color map is input into the gaussian mixture model, and the optimal model number can be calculated by the formula (2).
S1223, obtaining an optimization model of the Gaussian mixture model according to the model number of the Gaussian mixture model.
And determining the optimal model number, so that the Gaussian mixture model can be further optimized to obtain an optimized model.
S1224, carrying out parameter estimation on the optimization model by adopting an EM algorithm to obtain a second image segmentation result.
The EM algorithm is an iterative algorithm of parameter estimation, and the EM algorithm of the embodiment of the invention specifically comprises the following steps:
(1) E step
The first step is accomplished by estimating the Q equation, which is expressed mathematically as shown in equation (3):
Q(μ,∑,π,μ 222 )=E γ [In p(y,γ/μ,Σ,π)/Y,μ 222 ] (3)
wherein Y represents an input picture, mu and sigma represent the mean and variance of Gaussian distribution respectively, pi represents the probability of different pixel types in the picture,
Figure BDA0002387409430000101
in the iterative algorithm, the first update of the Q equation requires automatic setting of the iteration initial value. The iteration value of the Q equation after the first time is calculated from the result obtained by the M step.
(2) M step
The M step is a parameter estimation step, and the mathematical expression of the compact form of the three parameter estimation formulas is shown as the formula (4):
μ i+1i+1i+1 =arg max Q(μ,∑,π,μ iii ) (4)
wherein μ and Σ represent the mean and variance of gaussian distribution, respectively, pi represents the probability of different pixel point types in the picture, and the upper corner mark i represents the result of the ith iteration.
The specific expressions of the three parameter estimation formulas in the formula (4) are related to the specific form of modeling, and the mathematical expressions of the three parameter estimation formulas are shown in the formulas (5) to (7):
Figure BDA0002387409430000102
Figure BDA0002387409430000103
Figure BDA0002387409430000104
wherein ,μk and Σk Respectively mean and variance of Gaussian distribution, pi k The probability of different pixel point types in the picture is represented, and the upper corner mark i represents the result of the ith iteration. T represents the number of pixels, N ()'s represents Gaussian distribution, y represents the number of pixels, K represents the number of models,
Figure BDA0002387409430000105
the step E and the step M are main steps of an EM algorithm, the EM algorithm iterates between the step (1) and the step (2), and a judgment formula of iteration stopping is shown as a formula (8):
Figure BDA0002387409430000106
wherein ,μk and Σk Respectively representing the mean and variance of the gaussian distribution, N (-) represents the gaussian distribution, x represents the pixel point, pi k And (5) representing the probability of different pixel types in the picture, wherein K represents the model number. Stopping the iterative process when p (x/pi, mu, sigma) reaches a certain value.
According to the product defect detection method, the pixel value of the input product image to be detected is simulated through the Gaussian mixture model, and the type of each pixel point is determined through different single Gaussian models, so that the product image is detected, and a second image segmentation result is obtained.
S1300, processing the first image segmentation result and the second image segmentation result by adopting a post-processing algorithm to obtain a detection result.
In other embodiments of the present invention, referring to fig. 4, a schematic flow chart of another embodiment of a method for detecting a product defect in the embodiment of the present invention is shown. As shown in fig. 4, in the product defect detection method of the embodiment of the present invention, a post-processing algorithm is used to process a first image segmentation result and a second image segmentation result to obtain a detection result, and the specific steps include:
s1310, processing the first image segmentation result and the second image segmentation result to obtain a third image segmentation result.
The first image segmentation result and the second image segmentation result are processed, and first, the first image segmentation result is converted into a first matrix, and the second image segmentation result is converted into a second matrix. Then, corresponding elements of the first matrix and the second matrix are convolved to obtain a third matrix. And finally, carrying out inverse conversion on the third matrix according to the previous matrix conversion rule, and obtaining a third image segmentation result. The third image segmentation result is essentially the intersection of the first image segmentation result and the second image segmentation result.
In the matrix conversion rule of the embodiment of the invention, the pixel value of the defect segmentation area is 1, and the pixel value of the normal area is 0. By convolving the corresponding elements of the first matrix and the second matrix, the defective area divided by the first image division result and the second image division result will be set to 1, and the defective area and the non-defective area divided by one of the two will be set to 0.
S1320, performing leak edge detection and leak repair on the third image segmentation result by adopting a morphological reconstruction method to obtain a detection result.
The reason for the vulnerability is that the illumination when the image is acquired causes the EM algorithm to fail to classify correctly. And performing leak edge detection and leak repair on the third image segmentation result by adopting a morphological reconstruction method, wherein the purpose is to eliminate the factor of algorithm misjudgment caused by illumination influence.
The morphological reconstruction method of the embodiment of the invention specifically comprises the following two steps:
(1) Vulnerability edge detection step
After the matrix conversion is performed on the image segmentation result, if two different pixel values exist in 4 surrounding pixel points, the pixel point is indicated to belong to an edge, and the position of the pixel point is stored. And defining the origin (1, 1) of coordinates as a pixel point at the upper left corner of the image, traversing all pixel points with pixel values of 1 in the image by using an edge detection algorithm, and obtaining all existing edge points in the whole image.
(2) Bug repairing step
The feature that the edge areas of the loopholes are connected together to form a closed envelope is utilized, firstly, a point is randomly selected on an image, the abscissa of the point is recorded, and the point which is the same as the abscissa of the point is searched in the set of the edge points. Then, the lateral direction is selected, and all pixel points in the middle of the two edge points belong to a loophole, which can be regarded as search of a loophole area. And setting the pixel value of the middle loophole pixel point from 0 to 1, thereby completing the repair of a part of loopholes. And then, reselecting an edge point to repeat the repairing step until the bug repairing is completed.
According to the product defect detection method, through leak edge detection and leak repair, the problem that the EM algorithm is difficult to classify correctly due to illumination can be solved, and therefore the accuracy of the EM algorithm detection is improved.
Example 2
Referring to FIG. 5, a block diagram of one embodiment of a product defect inspection apparatus in accordance with an embodiment of the present invention is shown. As shown in fig. 5, a product defect detection device according to an embodiment of the present invention includes an image acquisition module, configured to acquire an image of a product to be detected; the first image segmentation module is used for processing the product image to be detected by adopting an Otsu algorithm to obtain a first image segmentation result; the second image segmentation module is used for processing the product image to be detected by adopting a Gaussian mixture model algorithm to obtain a second image segmentation result; and the post-processing module is used for processing the first image segmentation result and the second image segmentation result by adopting a post-processing algorithm to obtain a detection result.
According to the product defect detection device provided by the embodiment of the invention, the first image segmentation module has a stable and rapid segmentation result, the second image segmentation module has a precise segmentation result and a high calculation speed, a large number of training samples are not needed, and the post-processing module processes the first image segmentation result and the second image segmentation result, so that the product image can be reliably detected, and the detection speed can be greatly improved.
In other embodiments of the present invention, post-processing algorithms include vulnerability edge detection and vulnerability patching. Through the detection of the edge of the loophole and the repair of the loophole, the problem that the EM algorithm is difficult to classify correctly due to illumination can be solved, and therefore the detection accuracy of the EM algorithm is improved.
The product defect detection device of the embodiment of the invention can be operated in computing equipment such as a desktop computer, a notebook computer, a palm computer, a cloud server and the like. A product defect detection device, operable device may include, but is not limited to, a processor, a memory. It will be appreciated by those skilled in the art that the example is merely an example of a product defect detection apparatus, and is not limiting of a product defect detection apparatus, and may include more or fewer components than examples, or may combine certain components, or different components, e.g., a product defect detection apparatus may further include input and output devices, network access devices, buses, etc.
Example 3
The embodiment of the invention provides a product defect detection device, which is based on embodiment 1, and comprises at least one processor and a memory in communication connection with the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform a product defect detection method of some embodiments of the present invention.
The product defect detection equipment provided by the embodiment of the invention can greatly improve the detection speed, is suitable for detecting the surface defects of different types of products, can reduce the influence of external factors such as different light sources, the placement angles of detection pieces, the shadow conditions and the like on the detection result, and realizes the accurate detection of the product defects of the production line.
A product defect detection apparatus of embodiments of the present invention may include a processor, which may be a central processing unit (Central Processing Unit, CPU), other general purpose processor, digital signal processor (Digital Signal Processor, DSP), application specific integrated circuit (Application Specific Integrated Circuit, ASIC), off-the-shelf programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, or the like. The general purpose processor may be a microprocessor or the processor may be any conventional processor or the like, and the processor is a control center of an operable device of a product defect detection method, and various interfaces and lines are used to connect various parts of the operable device of the whole product defect detection method.
The memory may be used to store computer programs and/or modules and the processor implements the various functions of the operable means of a product defect detection method by running or executing the computer programs and/or modules stored in the memory and invoking data stored in the memory. The memory may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program (such as a sound playing function, an image playing function, etc.) required for at least one function, and the like; the storage data area may store data (such as audio data, phonebook, etc.) created according to the use of the handset, etc. In addition, the memory may include high speed random access memory, and may also include non-volatile memory, such as a hard disk, memory, plug-in hard disk, smart Media Card (SMC), secure digital (SecureDigital, SD) Card, flash Card (Flash Card), at least one disk storage device, flash memory device, or other volatile solid state memory device.
Example 4
Embodiments of the present invention provide a computer-readable storage medium, based on embodiment 1, storing computer-executable instructions for causing a computer to perform a product defect detection method of some embodiments of the present invention.
The computer readable storage medium of the embodiment of the invention can greatly improve the detection speed, is suitable for detecting surface defects of different types of products, can reduce the influence of external factors such as different light sources, the arrangement angles of detection members, shadow conditions and the like on the detection result, and realizes accurate detection of the product defects of the production line.
The embodiments of the present invention have been described in detail with reference to the accompanying drawings, but the present invention is not limited to the above embodiments, and various changes can be made within the knowledge of one of ordinary skill in the art without departing from the spirit of the present invention. Furthermore, embodiments of the invention and features of the embodiments may be combined with each other without conflict.

Claims (9)

1. A method for detecting product defects, comprising:
acquiring an image of a product to be detected;
processing the image of the product to be detected by adopting an Otsu algorithm to obtain a first image segmentation result;
processing the product image to be detected by adopting a Gaussian mixture model algorithm to obtain a second image segmentation result;
processing the first image segmentation result and the second image segmentation result by adopting a post-processing algorithm to obtain a detection result;
the method for processing the product image to be detected by adopting the Gaussian mixture model algorithm to obtain a second image segmentation result comprises the following steps:
carrying out HSV space color extraction on the product image to be detected to obtain an HSV color chart;
performing EM algorithm segmentation on the HSV color map to obtain a second image segmentation result;
the E step in the EM algorithm is as follows: iterating a Q equation, wherein the mathematical expression of the Q equation is as follows:
Figure QLYQS_1
Figure QLYQS_2
wherein ,
Figure QLYQS_4
representing the picture entered->
Figure QLYQS_10
Pixels representing the picture, < >>
Figure QLYQS_12
and />
Figure QLYQS_6
Mean and variance of the gaussian distribution, +.>
Figure QLYQS_9
Representing the probability of different pixel types in said picture,/for each pixel type>
Figure QLYQS_11
Representing a gaussian distribution->
Figure QLYQS_14
Represents the number of models in the Gaussian mixture model, +.>
Figure QLYQS_3
Representing the probability of different pixel types in the picture calculated by the kth model,/for>
Figure QLYQS_7
and />
Figure QLYQS_13
Mean and variance of gaussian distribution in kth model, respectively, +.>
Figure QLYQS_15
Representing different pixel point types in the picture calculated by the jth modelProbability (S)>
Figure QLYQS_5
and />
Figure QLYQS_8
Respectively representing the mean and the variance of the Gaussian distribution in the jth model;
in the iterative algorithm, when the iteration is performed for the first time, the updating of the Q equation is completed by automatically setting an iteration initial value, and after the iteration is performed for the first time, the iteration value of the Q equation is obtained by calculating the result obtained in the step M;
the M step is a parameter estimation step, wherein the mathematical expression of three parameter estimation formulas is as follows:
Figure QLYQS_16
wherein, upper corner mark
Figure QLYQS_17
Represents->
Figure QLYQS_18
Results of the second iteration;
specifically, the mathematical expression of the three parameter estimation formulas is:
Figure QLYQS_19
Figure QLYQS_20
Figure QLYQS_21
/>
Figure QLYQS_22
wherein ,
Figure QLYQS_23
representing the number of pixel points;
the EM algorithm iterates between the step E and the step M, and a judgment formula of iteration stopping is as follows:
Figure QLYQS_24
when (when)
Figure QLYQS_25
Stopping the iterative process after reaching a predetermined value.
2. The method for detecting a product defect according to claim 1, wherein the processing the image of the product to be detected by using the Otsu algorithm to obtain a first image segmentation result includes:
carrying out gray scale processing on the product image to be detected to obtain a gray scale image;
gamma correction is carried out on the gray level map to obtain a gamma correction map;
otsu segmentation is carried out on the gamma correction graph, and Otsu segmentation results are obtained;
performing morphological processing on the Otsu segmentation result to obtain a morphological correction result;
and carrying out median filtering on the morphological correction result to obtain the first image segmentation result.
3. The method for detecting product defects according to claim 2, wherein the performing morphological processing on the Otsu segmentation result to obtain a morphological correction result includes:
and carrying out gray level smoothing and edge smoothing on the Otsu segmentation result by adopting a low-pass filtering method to obtain the morphological correction result.
4. The method for detecting product defects according to claim 1, wherein the performing EM algorithm segmentation on the HSV color map to obtain the second image segmentation result includes:
establishing a Gaussian mixture model;
processing the HSV color map by adopting the Gaussian mixture model to obtain the model number of the Gaussian mixture model;
obtaining an optimization model of the Gaussian mixture model according to the model number of the Gaussian mixture model;
and carrying out parameter estimation on the optimization model by adopting an EM algorithm to obtain the second image segmentation result.
5. The method of claim 1, wherein the processing the first image segmentation result and the second image segmentation result by using a post-processing algorithm to obtain a detection result comprises:
processing the first image segmentation result and the second image segmentation result to obtain a third image segmentation result;
and performing leak edge detection and leak repair on the third image segmentation result by adopting a morphological reconstruction method to obtain the detection result.
6. A product defect detection apparatus, comprising:
the image acquisition module is used for acquiring an image of a product to be detected;
the first image segmentation module is used for processing the image of the product to be detected by adopting an Otsu algorithm to obtain a first image segmentation result;
the second image segmentation module is used for processing the product image to be detected by adopting a Gaussian mixture model algorithm to obtain a second image segmentation result;
the post-processing module is used for processing the first image segmentation result and the second image segmentation result by adopting a post-processing algorithm to obtain a detection result;
the method for processing the product image to be detected by adopting the Gaussian mixture model algorithm to obtain a second image segmentation result comprises the following steps:
carrying out HSV space color extraction on the product image to be detected to obtain an HSV color chart;
performing EM algorithm segmentation on the HSV color map to obtain a second image segmentation result;
the E step in the EM algorithm is as follows: iterating a Q equation, wherein the mathematical expression of the Q equation is as follows:
Figure QLYQS_26
Figure QLYQS_27
wherein ,
Figure QLYQS_30
representing the picture entered->
Figure QLYQS_32
Pixels representing the picture, < >>
Figure QLYQS_37
and />
Figure QLYQS_31
Mean and variance of the gaussian distribution, +.>
Figure QLYQS_33
Representing the probability of different pixel types in said picture,/for each pixel type>
Figure QLYQS_36
Representing a gaussian distribution->
Figure QLYQS_40
Represents the number of models in the Gaussian mixture model, +.>
Figure QLYQS_28
Representing the probability of different pixel types in the picture calculated by the kth model,/for>
Figure QLYQS_35
and />
Figure QLYQS_38
Mean and variance of gaussian distribution in kth model, respectively, +.>
Figure QLYQS_39
Representing the probability of different pixel point types in the picture calculated by the jth model,/for the different pixel point types in the picture>
Figure QLYQS_29
and />
Figure QLYQS_34
Respectively representing the mean and the variance of the Gaussian distribution in the jth model;
in the iterative algorithm, when the iteration is performed for the first time, the updating of the Q equation is completed by automatically setting an iteration initial value, and after the iteration is performed for the first time, the iteration value of the Q equation is obtained by calculating the result obtained in the step M;
the M step is a parameter estimation step, wherein the mathematical expression of three parameter estimation formulas is as follows:
Figure QLYQS_41
wherein, upper corner mark
Figure QLYQS_42
Represents->
Figure QLYQS_43
Results of the second iteration;
specifically, the mathematical expression of the three parameter estimation formulas is:
Figure QLYQS_44
Figure QLYQS_45
Figure QLYQS_46
Figure QLYQS_47
wherein ,
Figure QLYQS_48
representing the number of pixel points;
the EM algorithm iterates between the step E and the step M, and a judgment formula of iteration stopping is as follows:
Figure QLYQS_49
when (when)
Figure QLYQS_50
Stopping the iterative process after reaching a predetermined value.
7. The product defect detection device of claim 6, wherein the post-processing algorithm comprises vulnerability edge detection and vulnerability repair.
8. A product defect detection apparatus, comprising:
at least one processor, and,
a memory communicatively coupled to at least one of the processors; wherein,
the memory stores instructions executable by at least one of the processors to enable the at least one of the processors to perform the product defect detection method of any one of claims 1 to 5.
9. A computer-readable storage medium storing computer-executable instructions for causing a computer to perform the product defect detection method according to any one of claims 1 to 5.
CN202010102720.4A 2020-02-19 2020-02-19 Product defect detection method, device, equipment and storage medium Active CN111325728B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010102720.4A CN111325728B (en) 2020-02-19 2020-02-19 Product defect detection method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010102720.4A CN111325728B (en) 2020-02-19 2020-02-19 Product defect detection method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN111325728A CN111325728A (en) 2020-06-23
CN111325728B true CN111325728B (en) 2023-05-30

Family

ID=71167337

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010102720.4A Active CN111325728B (en) 2020-02-19 2020-02-19 Product defect detection method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111325728B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113516619B (en) * 2021-04-09 2023-03-17 重庆大学 Product surface flaw identification method based on image processing technology
CN113592787A (en) * 2021-07-13 2021-11-02 苏州汇川控制技术有限公司 Light emitting component detection method, light emitting component detection device, terminal equipment and storage medium
CN114494210B (en) * 2022-01-28 2023-03-24 江苏豪尚新材料科技有限公司 Plastic film production defect detection method and system based on image processing

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2017092431A1 (en) * 2015-12-01 2017-06-08 乐视控股(北京)有限公司 Human hand detection method and device based on skin colour
CN110751623A (en) * 2019-09-06 2020-02-04 深圳新视智科技术有限公司 Joint feature-based defect detection method, device, equipment and storage medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105678813A (en) * 2015-11-26 2016-06-15 乐视致新电子科技(天津)有限公司 Skin color detection method and device

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2017092431A1 (en) * 2015-12-01 2017-06-08 乐视控股(北京)有限公司 Human hand detection method and device based on skin colour
CN110751623A (en) * 2019-09-06 2020-02-04 深圳新视智科技术有限公司 Joint feature-based defect detection method, device, equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
徐海燕 ; 郭京 ; .基于HMT模型的带钢表面缺陷检测研究.计算机应用与软件.2015,(03),第331-336页. *

Also Published As

Publication number Publication date
CN111325728A (en) 2020-06-23

Similar Documents

Publication Publication Date Title
CN113781402B (en) Method and device for detecting scratch defects on chip surface and computer equipment
CN111325728B (en) Product defect detection method, device, equipment and storage medium
CN111833306B (en) Defect detection method and model training method for defect detection
CN109272016B (en) Target detection method, device, terminal equipment and computer readable storage medium
US7702157B2 (en) Pattern evaluation method, pattern matching method and computer readable medium
CN109191424B (en) Breast mass detection and classification system and computer-readable storage medium
CN110930390B (en) Chip pin missing detection method based on semi-supervised deep learning
CN107358586A (en) A kind of image enchancing method, device and equipment
CN110751620B (en) Method for estimating volume and weight, electronic device, and computer-readable storage medium
CN110969046B (en) Face recognition method, face recognition device and computer-readable storage medium
CN110675334A (en) Image enhancement method and device
CN110570442A (en) Contour detection method under complex background, terminal device and storage medium
CN113609984A (en) Pointer instrument reading identification method and device and electronic equipment
CN115984662B (en) Multi-mode data pre-training and identifying method, device, equipment and medium
CN111242957A (en) Data processing method and device, computer storage medium and electronic equipment
CN113971669A (en) Three-dimensional detection system applied to pipeline damage identification
CN114596440B (en) Semantic segmentation model generation method and device, electronic equipment and storage medium
CN114298985B (en) Defect detection method, device, equipment and storage medium
CN112966757A (en) Method and device for expanding training sample, storage medium and equipment
CN117372415A (en) Laryngoscope image recognition method, device, computer equipment and storage medium
CN112381177A (en) Dial digital character recognition method and system based on deep learning
CN117333518A (en) Laser scanning image matching method, system and computer equipment
CN112434581A (en) Outdoor target color identification method and system, electronic device and storage medium
CN111062341A (en) Video image area classification method, device, equipment and storage medium
CN115908409A (en) Method and device for detecting defects of photovoltaic sheet, computer equipment and medium

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