CN114332026A - Visual detection method and device for scratch defects on surface of nameplate - Google Patents

Visual detection method and device for scratch defects on surface of nameplate Download PDF

Info

Publication number
CN114332026A
CN114332026A CN202111650399.4A CN202111650399A CN114332026A CN 114332026 A CN114332026 A CN 114332026A CN 202111650399 A CN202111650399 A CN 202111650399A CN 114332026 A CN114332026 A CN 114332026A
Authority
CN
China
Prior art keywords
image
area
nameplate
scratch defect
scratch
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.)
Granted
Application number
CN202111650399.4A
Other languages
Chinese (zh)
Other versions
CN114332026B (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 Qianhai Yanxiang Asia Pacific Electronic Equipment Technology Co ltd
Original Assignee
Shenzhen Qianhai Yanxiang Asia Pacific Electronic Equipment Technology 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 Shenzhen Qianhai Yanxiang Asia Pacific Electronic Equipment Technology Co ltd filed Critical Shenzhen Qianhai Yanxiang Asia Pacific Electronic Equipment Technology Co ltd
Priority to CN202111650399.4A priority Critical patent/CN114332026B/en
Publication of CN114332026A publication Critical patent/CN114332026A/en
Application granted granted Critical
Publication of CN114332026B publication Critical patent/CN114332026B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Investigating Materials By The Use Of Optical Means Adapted For Particular Applications (AREA)
  • Image Analysis (AREA)

Abstract

The invention provides a visual inspection method and a device for the scratch defect on the surface of a nameplate, wherein the visual inspection method comprises the following steps: collecting an original image; carrying out logarithmic equilibrium transformation on the original image; carrying out binarization processing on the image after the number equalization transformation by adopting an automatic threshold segmentation algorithm; determining a connected domain Smax with the largest area in all connected domains of the image after binarization processing, and performing open operation on the connected domain Smax by using a circular structural element with a set radius to obtain a rectangular region; cutting out a nameplate surface image to be detected from the original image by adopting a rectangular area; preprocessing the surface image of the nameplate to be detected; and (4) segmenting the scratch defect area from the preprocessed image by adopting a dynamic threshold segmentation algorithm. The gray scale transformation curve can be well adjusted, the contrast within a specific range is highlighted, and the extraction of the nameplate image to be detected from the original image in the subsequent step is facilitated; the accuracy of identifying the scratch defect area can be improved; the method can be suitable for scenes with various inconsistent nameplates.

Description

Visual detection method and device for scratch defects on surface of nameplate
Technical Field
The invention relates to the technical field of industrial manufacturing, in particular to a visual detection method and device for the scratch defect of the surface of a nameplate.
Background
At present, a commonly used nameplate surface defect detection algorithm firstly needs to create a template for a sample, and then extracts defect information by combining a template matching method with background difference. However, the template matching method firstly needs to create templates of qualified samples, and is not suitable for scenes in which the content of nameplates changes continuously, because it is impossible to create one template for each nameplate in the industrial production process, which leads to detection efficiency that is not better than that of manual work. And the template matching method has higher requirement on precision, the nameplate to be detected needs to be completely aligned with the sample nameplate, but the scratch defect is usually in the shape of a plurality of lines, and if the matching precision is slightly poor, a large amount of false detection can be caused.
Disclosure of Invention
The invention provides a visual detection method and a visual detection device for the scratch defect on the surface of a nameplate, which do not need to manually set a large number of parameters based on prior knowledge, do not need to manually create a template in advance, do not have the requirement on consistency of contents in the nameplate, and reduce the workload and the difficulty in parameter adjustment.
In a first aspect, the present invention provides a visual inspection method for a scratch defect on a surface of a nameplate, the visual inspection method comprising: collecting an original image containing a surface image of a nameplate to be detected; carrying out logarithmic equilibrium transformation on the original image to obtain an image subjected to logarithmic equilibrium transformation; carrying out binarization processing on the image after the number equalization transformation by adopting an automatic threshold segmentation algorithm to obtain an image after the binarization processing; determining a connected domain Smax with the largest area in all connected domains of the image after binarization processing, and performing open operation on the connected domain Smax by using a circular structural element with a set radius to obtain a rectangular region; cutting out a nameplate surface image to be detected from the original image by adopting a rectangular area; preprocessing the surface image of the nameplate to be detected to obtain a preprocessed image; and (4) segmenting the scratch defect area from the preprocessed image by adopting a dynamic threshold segmentation algorithm.
In the scheme, the original image is processed by using a logarithm equilibrium transformation algorithm, so that a gray level transformation curve can be well adjusted, the contrast in a specific range is highlighted, and the extraction of the nameplate image to be detected from the original image in the subsequent steps is facilitated. And a dynamic threshold segmentation algorithm is used for segmenting the scratch defect region from the preprocessed image, so that the accuracy of identifying the scratch defect region can be improved. The visual detection method for the scratch defects on the surfaces of the nameplates has no consistency requirement on the contents in the nameplates, can be suitable for various inconsistent scenes of the nameplates, does not need to create templates in advance, does not need to manually set parameters based on priori knowledge, does not need manual intervention, can realize automatic detection on the scratch defects on the nameplates of the products, realizes mixed production of multiple products, and reduces the workload and the difficulty of parameter adjustment. Compared with the prior art, the visual detection method has the advantages of high identification accuracy, high detection speed and simplicity in operation, can effectively replace manpower, reduces the labor cost and improves the production efficiency.
In a specific embodiment, performing a logarithmic equalization transform on the original image to obtain a logarithmic equalization transformed image includes: carrying out logarithmic equilibrium transformation on the original image by adopting the following transformation equation to obtain an image after the logarithmic equilibrium transformation:
g(i,j)=a ln[f(i,j)+1]+b
wherein f (i, j) represents the pixel value of each pixel point in the original image; g (i, j) represents the pixel value of each pixel point in the image after logarithmic equilibrium transformation; a represents a weight coefficient; b represents an offset amount. In the logarithmic equilibrium transformation process, the weight coefficient a and the offset b are added, so that the gray level transformation defect can be better adjusted, the contrast within a specific range is highlighted, and the extraction of the surface image of the nameplate to be detected from the original image in the subsequent step is facilitated.
In a specific embodiment, the binarizing the image after the logarithmic balance transformation by using an automatic threshold segmentation algorithm to obtain the binarized image includes: step 1: taking the gray average value of the image after logarithmic equilibrium transformation as an initial threshold value t0(ii) a Step 2: using an initial threshold t0Dividing the image after logarithmic equalization transformation into a Q1 area and a Q2 area; wherein the pixel value of each pixel point in the Q1 area is less than the initial threshold t0And the pixel value of each pixel point in the Q2 area is not less than the initial threshold value t0(ii) a And step 3: the gray level average value t of the Q1 area1And gray average t of Q2 region2As the new threshold value td(ii) a And 4, step 4: judging an initial threshold t0And a new threshold value tdWhether they are equal; if equal, set the final threshold T ═ Td(ii) a If not, let the initial threshold t0=tdCircularly executing the steps 2-4 again until a final threshold value T is obtained; and 5: and (5) carrying out binarization processing on the image after the logarithmic balance transformation by using the final threshold value T to obtain an image after binarization processing. The data volume in the original image is greatly reduced, so that the outline of the surface image of the nameplate to be detected can be highlighted, and the surface image of the nameplate to be detected can be conveniently extracted from the original image in the subsequent step.
In a specific embodiment, the determining a connected domain Smax with the largest area among all connected domains of the binarized image, and performing an opening operation on the connected domain Smax by using a circular structural element with a set radius to obtain a rectangular region includes: performing connected domain analysis on the image after the binarization processing to obtain a connected domain set S ═ S1,S2,S3,…,Sn}; wherein S represents the whole area of the image after binarization processing, S1,S2,S3,…,SnRespectively represent a connected domain; from S1~SnSelecting a connected domain Smax with the largest area; and carrying out open operation on the connected domain Smax by using the circular structural element with the set radius to obtain a rectangular region. So as to remove background interference noise points in the image after the binarization processing, and is more beneficialAnd extracting the nameplate image to be detected from the original image in the subsequent step.
In a specific embodiment, the preprocessing the image of the surface of the nameplate to be detected to obtain the preprocessed image comprises: carrying out negation operation on the nameplate image of the surface to be detected to obtain an image subjected to negation operation; carrying out gray level opening operation on the image subjected to the negation operation to obtain an image subjected to the gray level opening operation so as to remove small bright details and relatively keep the whole gray level and a large bright area; performing median filtering on the image after the gray level opening operation to obtain an image after the median filtering, and removing salt and pepper noise in the image background; and performing gray level corrosion on the image subjected to the median filtering to obtain a preprocessed image, so that the preprocessed image tends to be darker than the image subjected to the median filtering, and the segmentation of the scratch defect area from the preprocessed image is facilitated.
In a specific embodiment, the inverting operation is performed on the nameplate image of the surface to be detected, and obtaining the inverted image includes: performing negation operation on the nameplate image of the surface to be detected by adopting the following formula to obtain an operation image after negation:
f″(i,j)=255-f′(i,j)
wherein f' (i, j) represents the pixel value of each pixel point in the surface nameplate image to be detected; f' (i, j) represents the pixel value of each pixel point in the operation image after inversion, and the inversion operation effect is improved.
In a specific embodiment, the segmenting the scratch defect region from the preprocessed image by using a dynamic threshold segmentation algorithm includes: constructing a rectangular filtering template with a set pixel value, and performing mean filtering on the preprocessed image to obtain a mean filtered image; carrying out smoothing filter processing on the image after the average filtering to obtain an image after the smoothing filter processing; setting an Offset; comparing the pixel value of each pixel point in the preprocessed image one by one, and whether the pixel value of the corresponding pixel point in the image processed by the smoothing filter meets the following conditions: f' (i, j) is less than or equal to m (i, j) -Offset; wherein f' (i, j) represents the pixel value of each pixel point in the preprocessed image, and m (i, j) represents the pixel value of each pixel point in the image processed by the smoothing filter; if not, defining the pixel point as a non-scratch pixel point; otherwise, defining the pixel point as a scratch pixel point; comparing one by one to obtain all scratch pixel points; and performing connected domain processing on all scratch pixel points to obtain at least one scratch defect area. The influence of the uneven distribution of the whole brightness of the image on the surface of the nameplate to be detected cut out from the original image caused by the uneven illumination in the process of acquiring the original image is eliminated, and meanwhile, the scratch defect area is preliminarily cut out from the preprocessed image.
In a specific embodiment, the segmenting the scratch defect region from the preprocessed image by using a dynamic threshold segmentation algorithm further comprises: obtaining a gray level co-occurrence matrix of each scratch defect area in at least one scratch defect area; calculating the contrast characteristic quantity C of each scratch defect area according to the gray level co-occurrence matrix of each scratch defect areae(ii) a Calculating average contrast characteristic quantity C of all scratch defect areassAnd contrast characteristic quantity standard deviation Cstd(ii) a Calculating the area A of each scratch defect regioneAverage area A of all scratch defect regionssAnd area standard deviation Astd(ii) a Judging whether the area and the contrast characteristic quantity of each scratch defect area meet the conditions:
Ae∈(As-vAstd,As+vAstd)∩Ce∈(Cs-vCstd,Cs+vCstd)
wherein v represents a defect verification coefficient;
if yes, verifying the scratch defect area as a true scratch defect area; if the scratch defect area is not met, the scratch defect area is verified to be a false scratch defect area, whether each preliminarily recognized scratch defect area is a true scratch defect area or not is further verified, and accuracy of recognizing the scratch defect area is improved.
In a specific embodiment, the visual inspection method further comprises: the following scratch defect severity level criteria are preset: when A ise∈(As,As+vAstd)∩Ce∈(Cs,Cs+vCstd) Defining a real scratch defect area as a type of defect; when A ise∈(As-vAstd,As)∩Ce∈(Cs,Cs+vCstd) Defining a real scratch defect area as a second type of defect; when A ise∈(As,As+vAstd)∩Ce∈(Cs-vCstd,Cs) Defining a real scratch defect area as three types of defects; when A ise∈(As-vAstd,As)∩Ce∈(Cs-vCstd,Cs) Defining four types of defects as a true scratch defect area; and classifying each real scratch defect area according to the scratch defect severity grade standard so as to guide different subsequent processing modes aiming at different scratch defect degrees.
In a second aspect, the present invention further provides a visual inspection apparatus for detecting a scratch defect on a surface of a nameplate, the visual inspection apparatus comprising: the device comprises an image acquisition module, a logarithm balance transformation module, a binarization processing module, a rectangular region acquisition module, a cutting module, a preprocessing module and a scratch defect region determination module. The image acquisition module is used for acquiring an original image containing a surface image of the nameplate to be detected. And the log equalization transformation module is used for carrying out log equalization transformation on the original image to obtain an image subjected to log equalization transformation. And the binarization processing module is used for carrying out binarization processing on the image after the logarithmic balance transformation by adopting an automatic threshold segmentation algorithm to obtain the image after the binarization processing. The rectangular region acquisition module is used for determining the connected domain Smax with the largest area in all the connected domains of the image after binarization processing, and performing open operation on the connected domain Smax by using a circular structural element with a set radius to obtain a rectangular region. The cutting module is used for cutting out the surface image of the nameplate to be detected from the original image by adopting the rectangular area. The preprocessing module is used for preprocessing the nameplate surface image to be detected to obtain a preprocessed image. And the scratch defect area determining module is used for segmenting the scratch defect area from the preprocessed image by adopting a dynamic threshold segmentation algorithm.
In the scheme, the original image is processed by using a logarithm equilibrium transformation algorithm, so that a gray level transformation curve can be well adjusted, the contrast in a specific range is highlighted, and the extraction of the nameplate image to be detected from the original image in the subsequent steps is facilitated. And a dynamic threshold segmentation algorithm is used for segmenting the scratch defect region from the preprocessed image, so that the accuracy of identifying the scratch defect region can be improved. The visual detection method for the scratch defects on the surfaces of the nameplates has no consistency requirement on the contents in the nameplates, can be suitable for various inconsistent scenes of the nameplates, does not need to create templates in advance, does not need to manually set parameters based on priori knowledge, does not need manual intervention, can realize automatic detection on the scratch defects on the nameplates of the products, realizes mixed production of multiple products, and reduces the workload and the difficulty of parameter adjustment. Compared with the prior art, the visual detection method has the advantages of high identification accuracy, high detection speed and simplicity in operation, can effectively replace manpower, reduces the labor cost and improves the production efficiency.
Drawings
FIG. 1 is a flowchart of a method for visually inspecting scratch defects on a nameplate according to an embodiment of the present invention;
fig. 2 is a flowchart of another visual inspection method for detecting scratch defects on a nameplate surface according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious 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 given herein without making any creative effort, shall fall within the protection scope of the present invention.
In order to facilitate understanding of the visual inspection method for the scratch defect on the surface of the nameplate provided by the embodiment of the invention, an application scenario of the visual inspection method provided by the embodiment of the invention is first described below, and the visual inspection method is applied to the inspection process of the scratch defect on the surface of the nameplate. The nameplate can be a nameplate adhered to the surface of a shell of a mobile phone, a computer and the like. The following describes the visual inspection method of the scratch defect on the nameplate surface in detail with reference to the accompanying drawings.
Referring to fig. 1, the method for visually inspecting scratch defects on the surface of a nameplate according to an embodiment of the present invention includes:
s10: collecting an original image containing a surface image of a nameplate to be detected;
s20: carrying out logarithmic equilibrium transformation on the original image to obtain an image subjected to logarithmic equilibrium transformation;
s30: carrying out binarization processing on the image after the number equalization transformation by adopting an automatic threshold segmentation algorithm to obtain an image after the binarization processing;
s40: determining a connected domain Smax with the largest area in all connected domains of the image after binarization processing, and performing open operation on the connected domain Smax by using a circular structural element with a set radius to obtain a rectangular region;
s50: cutting out a nameplate surface image to be detected from the original image by adopting a rectangular area;
s60: preprocessing the surface image of the nameplate to be detected to obtain a preprocessed image;
s70: and (4) segmenting the scratch defect area from the preprocessed image by adopting a dynamic threshold segmentation algorithm.
In the scheme, the original image is processed by using a logarithm equilibrium transformation algorithm, so that a gray level transformation curve can be well adjusted, the contrast in a specific range is highlighted, and the extraction of the nameplate image to be detected from the original image in the subsequent steps is facilitated. And a dynamic threshold segmentation algorithm is used for segmenting the scratch defect region from the preprocessed image, so that the accuracy of identifying the scratch defect region can be improved. The visual detection method for the scratch defects on the surfaces of the nameplates has no consistency requirement on the contents in the nameplates, can be suitable for various inconsistent scenes of the nameplates, does not need to create templates in advance, does not need to manually set parameters based on priori knowledge, does not need manual intervention, can realize automatic detection on the scratch defects on the nameplates of the products, realizes mixed production of multiple products, and reduces the workload and the difficulty of parameter adjustment. Compared with the prior art, the visual detection method has the advantages of high identification accuracy, high detection speed and simplicity in operation, can effectively replace manpower, reduces the labor cost and improves the production efficiency. Each of the above steps will be described in detail with reference to the accompanying drawings.
First, referring to fig. 1, an original image containing an image of the surface of the nameplate to be detected is collected. During specific collection, the surface image of the nameplate to be detected can be collected as an original image by a camera shooting mode from the surface of an electronic product such as a mobile phone, a notebook computer and the like stuck with the nameplate through a camera shooting device such as but not limited to an industrial camera.
Next, as shown in fig. 1 and fig. 2, the original image is subjected to logarithmic equilibrium transformation to obtain an image after the logarithmic equilibrium transformation, so that a gray level transformation curve can be well adjusted, the contrast within a specific range is highlighted, and the extraction of the nameplate image to be detected from the original image in the subsequent steps is facilitated. Specifically, when the log-balanced transformation is performed on the original image, the following transformation equation can be adopted to perform the log-balanced transformation on the original image, so as to obtain the image after the log-balanced transformation:
g(i,j)=a ln[f(i,j)+1]+b
wherein f (i, j) represents the pixel value of each pixel point in the original image. And g (i, j) represents the pixel value of each pixel point in the image after logarithmic equilibrium transformation. a represents a weight coefficient, and may be 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, or 4.5. b represents an offset, and may be specifically equal to-40, -45, -50, -55, -60, -65, -70, -75, or 80. In the logarithmic equilibrium transformation process, the weight coefficient a and the offset b are added, so that the gray level transformation defect can be better adjusted, the contrast within a specific range is highlighted, and the extraction of the surface image of the nameplate to be detected from the original image in the subsequent step is facilitated. Of course, the manner of the logarithmic equalization transformation is not limited to the above-described manner, and other manners may be adopted.
Next, referring to fig. 1 and 2, an image after the logarithmic balance transformation is subjected to binarization processing by using an automatic threshold segmentation algorithm, so as to obtain a binarized image. Specifically, when the automatic threshold segmentation algorithm is used to perform binarization processing on the image after the logarithmic balance transformation, the following method can be adopted:
step 1: taking the gray average value of the image after logarithmic equilibrium transformation as an initial threshold value t0(ii) a Specifically, the initial threshold t0The following formula can be used for calculation:
Figure BDA0003443032390000051
where xsize and ysize are the width and height of the original image, respectively, and x and y represent the variation in the width direction and the variation in the height direction of the original image, respectively.
Step 2: using an initial threshold t0The log-equalized image is divided into a Q1 region and a Q2 region. Wherein the pixel value of each pixel point in the Q1 area is less than the initial threshold t0And the pixel value of each pixel point in the Q2 area is not less than the initial threshold value t0. I.e. the pixel value is smaller than the initial threshold t0Is attributed to the Q1 region and is greater than the initial threshold t0The pixel points of (2) are attributed to the Q2 region.
And step 3: the gray level average value t of the Q1 area1And gray average t of Q2 region2As the new threshold value td
Specifically, first, the gray-scale average values t in the Q1 region and the Q2 region are calculated respectively1And t2The gray level average value t in the Q1 region and the Q2 region can be obtained by the following formula1And t2
Figure BDA0003443032390000052
Wherein t is the average value of gray scale, and can be t respectively1And t2;nQFor processing pixels in region QTotal number, Q may be Q1 and Q2, respectively; x is the number ofiAnd yiRespectively representing the x coordinate and the y coordinate of a pixel point i in the processing area Q; gQ(xi,yi) And expressing the pixel value of a pixel point i in the image after logarithmic equilibrium transformation.
Thereafter, the gray level average value t in the Q1 region and the Q2 region is calculated1And t2Calculating the gray level average value t of the Q1 area1And gray average t of Q2 region2Is used as the new threshold tdI.e. td=(t1+t2)/2。
And 4, step 4: judging an initial threshold t0And a new threshold value tdWhether they are equal;
if equal, set the final threshold T ═ Td
If not, let the initial threshold t0=tdCircularly executing the steps 2-4 again until a final threshold value T is obtained; continuously iterating until t for the image with obvious two peaks and deep valley bottom of the histogramdConverge thereby to let t0=td
And 5: and (5) carrying out binarization processing on the image after the logarithmic balance transformation by using the final threshold value T to obtain an image after binarization processing.
By the mode, the data volume in the original image can be greatly reduced, so that the outline of the nameplate surface image to be detected can be highlighted, and the nameplate surface image to be detected can be conveniently extracted from the original image in the subsequent step.
Next, referring to fig. 1 and 2, the connected domain Smax with the largest area among all the connected domains of the binarized image is determined, and the connected domain Smax is subjected to an opening operation with a circular structural element with a set radius to obtain a rectangular region. Specifically, the connected component analysis may be performed on the binarized image to obtain a connected component set S ═ S1,S2,S3,…,Sn}; wherein S is1,S2,S3,…,SnRespectively representing a connected domain, S representing the whole area of the image after binarization processing, and S representing twoThe area S of the whole region of the image after the quantization process can be expressed by the following formula:
Figure BDA0003443032390000061
wherein the size of the connected domain set is m multiplied by n, x is more than or equal to 0 and less than or equal to m-1, and y is more than or equal to 0 and less than or equal to n-1.
Then, from S1~SnAnd selecting the connected domain Smax with the largest area, wherein the connected domain Smax with the largest area is the indicated image area of the nameplate to be detected.
And then, carrying out open operation on the connected domain Smax by using the circular structural element with the set radius to obtain a rectangular area. Specifically, the set radius may be 10 pixels, 15 pixels, 20 pixels, 25 pixels, 30 pixels, or the like. So as to remove background interference noise points in the binarized image and be more beneficial to extracting the nameplate image to be detected from the original image in the subsequent steps.
Next, referring to fig. 1 and 2, the rectangular area is used to cut out the surface image of the nameplate to be detected from the original image, so as to facilitate the detection.
Next, as shown in fig. 1 and fig. 2, the surface image of the nameplate to be detected is preprocessed, so as to obtain a preprocessed image. When the surface image of the nameplate to be detected is preprocessed, the image of the nameplate to be detected can be subjected to negation operation to obtain an image subjected to negation operation; specifically when treating the surface data plate image of detecting and carrying out the operation of negating, adopt following formula, treat the surface data plate image of detecting and carry out the operation of negating, obtain the back operation image of negating:
f″(i,j)=255-f′(i,j)
wherein f' (i, j) represents the pixel value of each pixel point in the surface nameplate image to be detected; f' (i, j) represents the pixel value of each pixel point in the operation image after inversion, and the inversion operation effect is improved.
And then, carrying out gray level opening operation on the image after the inversion operation to obtain the image after the gray level opening operation so as to remove small bright details and relatively keep the whole gray level and a large bright area. Specifically, when the grayscale opening operation is performed on the image after the negation operation to obtain the image after the grayscale opening operation, a rectangular structural element with a preset size can be constructed, and then the grayscale opening operation is performed on the image after the negation operation by using the rectangular structural element to obtain the image after the grayscale opening operation. The rectangular structural element with the preset size may be a rectangular structural element with a pixel size of 5x5, 7x7, 9x9, 11x11, 13x13, and the like.
And performing median filtering on the image subjected to the gray-scale opening operation to obtain a median filtered image so as to remove salt and pepper noise in the image background. Specifically, a filtering template with pixel point sizes of 5x5, 7x7, 9x9, 11x11, 13x13 and the like can be constructed, and the image after gray-scale opening operation is subjected to median filtering to remove salt-pepper noise in the image background, so that the image after median filtering is obtained.
Then, gray scale corrosion can be carried out on the image after median filtering to obtain a preprocessed image, so that the preprocessed image tends to be darker than the image after median filtering, and the segmentation of the scratch defect area from the preprocessed image is facilitated. When gray scale corrosion is performed on the median filtered image, a rectangular structural element with the size of 3x3, 5x5, 7x7, 9x9, 11x11 and 13x13 can be constructed, and the median filtered image is collected and subjected to gray scale corrosion to obtain a preprocessed image.
Next, referring to fig. 1 and 2, a scratch defect area is segmented from the preprocessed image by using a dynamic threshold segmentation algorithm. Specifically, a rectangular filtering template with a set pixel value size may be constructed first, and the preprocessed image is subjected to mean filtering to obtain a mean filtered image. The set pixel value may be 3x3, 5x5, 7x7, 9x9, 11x11, 13x13, or the like.
Then, the image after the mean filtering can be subjected to smoothing filter processing to obtain an image after the smoothing filter processing;
then, an Offset may be set;
and then comparing the pixel value of each pixel point in the preprocessed image one by one, and whether the pixel value of the corresponding pixel point in the image processed by the smoothing filter meets the following conditions: f' (i, j) ≦ m (i, j) -Offset. Wherein f' (i, j) represents the pixel value of each pixel point in the pre-processed image, and m (i, j) represents the pixel value of each pixel point in the image after the smoothing filter processing. If not, defining the pixel point as a non-scratch pixel point; otherwise, defining the pixel point as a scratch pixel point. All scratch pixel points can be obtained through one-by-one comparison;
and then, performing connected domain processing on all scratch pixel points to obtain at least one scratch defect area. The influence of the uneven distribution of the whole brightness of the image on the surface of the nameplate to be detected cut out from the original image caused by the uneven illumination in the process of acquiring the original image is eliminated, and meanwhile, the scratch defect area is preliminarily cut out from the preprocessed image.
In addition, the step of segmenting the scratch defect area from the preprocessed image by adopting a dynamic threshold segmentation algorithm can further comprise the following steps:
first, a gray level co-occurrence matrix of each scratch defect area in at least one scratch defect area is obtained. Specifically, from a pixel point i of the preprocessed image, in the direction of the angle θ, the probability P that the gray value of a point whose displacement δ away from r is (r, θ) is j may beδ(i, j) (i, j ═ 0,1, …, n-1) as elements, and a co-occurrence matrix was obtained.
Then, according to the gray level co-occurrence matrix of each scratch defect area, calculating the contrast characteristic quantity C of each scratch defect arean. Specifically, the following formula can be adopted to obtain the contrast characteristic quantity C of each scratch defect areae
Figure BDA0003443032390000071
Where Contrast represents a Contrast feature quantity.
Thereafter, the average contrast characteristic quantity C of all the scratch defect regions is calculatedsAnd contrast characteristic quantity standard deviation Cstd
Then, each is calculatedArea A of scratch defect regioneAverage area A of all scratch defect regionssAnd area standard deviation Astd
And judging whether the area and the contrast characteristic quantity of each scratch defect region meet the conditions:
Ae∈(As-vAstd,As+vAstd)∩Ce∈(Cs-vCstd,Cs+vCstd)
wherein v represents a defect verification coefficient, and v can be specifically 0.5, 1.0, 1.5, 2.0, 2.5 and the like; e denotes each of the at least one scratch defect area.
If yes, verifying the scratch defect area as a true scratch defect area;
if not, the scratch defect area is verified as a false scratch defect area.
By further adding area and contrast characteristic quantity as constraint conditions, whether each scratch defect area preliminarily identified is a real scratch defect area is further checked, the preliminarily identified false scratch defect area possibly having partial noise interference is removed, and the accuracy of identifying the scratch defect area is improved.
Furthermore, after verifying the true scratch defect area, the visual inspection method may further include the steps of:
first, the following scratch defect severity level criteria are preset:
when A ise∈(As,As+vAstd)∩Ce∈(Cs,Cs+vCstd) Defining a real scratch defect area as a type of defect, which is the most serious scratch defect area;
when A ise∈(As-vAstd,As)∩Ce∈(Cs,Cs+vCstd) Defining a real scratch defect area as a second type of defect, which is a more serious scratch defect area;
when A ise∈(As,As+vAstd)∩Ce∈(Cs-vCstd,Cs) Defining a true scratch defect area as three types of defects, namely a moderate and severe scratch defect area;
when A ise∈(As-vAstd,As)∩Ce∈(Cs-vCstd,Cs) Defining four types of defects as a true scratch defect area, namely a moderate and light severe scratch defect area;
and then classifying each real scratch defect area according to the scratch defect severity grade standard so as to guide different subsequent processing modes aiming at different scratch defect degrees.
The original image is processed by using a logarithmic equilibrium transformation algorithm, so that a gray level transformation curve can be well adjusted, the contrast within a specific range is highlighted, and the extraction of the nameplate image to be detected from the original image in the subsequent steps is facilitated. And a dynamic threshold segmentation algorithm is used for segmenting the scratch defect region from the preprocessed image, so that the accuracy of identifying the scratch defect region can be improved. The visual detection method for the scratch defects on the surfaces of the nameplates has no consistency requirement on the contents in the nameplates, can be suitable for various inconsistent scenes of the nameplates, does not need to create templates in advance, does not need to manually set parameters based on priori knowledge, does not need manual intervention, can realize automatic detection on the scratch defects on the nameplates of the products, realizes mixed production of multiple products, and reduces the workload and the difficulty of parameter adjustment. Compared with the prior art, the visual detection method has the advantages of high identification accuracy, high detection speed and simplicity in operation, can effectively replace manpower, reduces the labor cost and improves the production efficiency.
In addition, the embodiment of the invention also provides a visual detection device for the scratch defect on the surface of the nameplate, which comprises: the device comprises an image acquisition module, a logarithm balance transformation module, a binarization processing module, a rectangular region acquisition module, a cutting module, a preprocessing module and a scratch defect region determination module. The image acquisition module is used for acquiring an original image containing a surface image of the nameplate to be detected. And the log equalization transformation module is used for carrying out log equalization transformation on the original image to obtain an image subjected to log equalization transformation. And the binarization processing module is used for carrying out binarization processing on the image after the logarithmic balance transformation by adopting an automatic threshold segmentation algorithm to obtain the image after the binarization processing. The rectangular region acquisition module is used for determining the connected domain Smax with the largest area in all the connected domains of the image after binarization processing, and performing open operation on the connected domain Smax by using a circular structural element with a set radius to obtain a rectangular region. The cutting module is used for cutting out the surface image of the nameplate to be detected from the original image by adopting the rectangular area. The preprocessing module is used for preprocessing the nameplate surface image to be detected to obtain a preprocessed image. And the scratch defect area determining module is used for segmenting the scratch defect area from the preprocessed image by adopting a dynamic threshold segmentation algorithm.
In the scheme, the original image is processed by using a logarithm equilibrium transformation algorithm, so that a gray level transformation curve can be well adjusted, the contrast in a specific range is highlighted, and the extraction of the nameplate image to be detected from the original image in the subsequent steps is facilitated. And a dynamic threshold segmentation algorithm is used for segmenting the scratch defect region from the preprocessed image, so that the accuracy of identifying the scratch defect region can be improved. The visual detection method for the scratch defects on the surfaces of the nameplates has no consistency requirement on the contents in the nameplates, can be suitable for various inconsistent scenes of the nameplates, does not need to create templates in advance, does not need to manually set parameters based on priori knowledge, does not need manual intervention, can realize automatic detection on the scratch defects on the nameplates of the products, realizes mixed production of multiple products, and reduces the workload and the difficulty of parameter adjustment. Compared with the prior art, the visual detection method has the advantages of high identification accuracy, high detection speed and simplicity in operation, can effectively replace manpower, reduces the labor cost and improves the production efficiency.
When the functional modules are provided, the functional modules may include an image pickup device, an arithmetic chip, a memory chip, and the like, which are formed by combining software and hardware that realize related functions.
The above description is only for the specific embodiment of the present invention, but the scope of the present invention is not limited thereto, and any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope of the present invention are included in the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (10)

1. A visual inspection method for scratch defects on the surface of a nameplate is characterized by comprising the following steps:
collecting an original image containing a surface image of a nameplate to be detected;
carrying out logarithmic equilibrium transformation on the original image to obtain an image subjected to logarithmic equilibrium transformation;
performing binarization processing on the image after the logarithmic equalization transformation by adopting an automatic threshold segmentation algorithm to obtain an image after the binarization processing;
determining a connected domain Smax with the largest area in all connected domains of the image after binarization processing, and performing open operation on the connected domain Smax by using a circular structural element with a set radius to obtain a rectangular region;
cutting out the surface image of the nameplate to be detected from the original image by adopting the rectangular area;
preprocessing the surface image of the nameplate to be detected to obtain a preprocessed image;
and adopting a dynamic threshold segmentation algorithm to segment the scratch defect area from the preprocessed image.
2. The visual inspection method of claim 1, wherein said logarithmically equalizing the original image to obtain a logarithmically equalized image comprises:
carrying out logarithmic equilibrium transformation on the original image by adopting the following transformation equation to obtain the image after the logarithmic equilibrium transformation:
g(i,j)=aln[f(i,j)+1]+b
wherein f (i, j) represents the pixel value of each pixel point in the original image;
g (i, j) represents the pixel value of each pixel point in the image after the logarithmic equilibrium transformation;
a represents a weight coefficient;
b represents an offset amount.
3. The visual inspection method of claim 1, wherein said binarizing the log-equalized image using an automatic threshold segmentation algorithm to obtain a binarized image comprises:
step 1: taking the gray average value of the image after the logarithmic equilibrium transformation as an initial threshold value t0
Step 2: using said initial threshold t0Dividing the log-equalized image into a Q1 region and a Q2 region; wherein the pixel value of each pixel point in the Q1 area is less than the initial threshold t0The pixel value of each pixel point in the Q2 area is not less than the initial threshold t0
And step 3: the gray average value t of the Q1 area1And the gray average value t of the Q2 area2As the new threshold value td
And 4, step 4: judging the initial threshold value t0And the new threshold value tdWhether they are equal;
if equal, set the final threshold T ═ Td
If not, let the initial threshold t0=tdCircularly executing the steps 2-4 again until a final threshold value T is obtained;
and 5: and carrying out binarization processing on the image after the logarithm equilibrium transformation by using the final threshold value T to obtain the image after the binarization processing.
4. The visual inspection method of claim 1, wherein said determining a connected component Smax with a largest area among all connected components of the binarized image and performing an opening operation on the connected component Smax with a circular structural element having a set radius to obtain a rectangular region comprises:
performing connected domain analysis on the binarized image to obtain a connected domain set S ═ S1,S2,S3,...,Sn}; wherein S represents the whole area of the image after the binarization processing, S1,S2,S3,...,SnRespectively represent a connected domain;
from said S1~SnSelecting the connected domain Smax with the largest area;
and carrying out open operation on the connected domain Smax by using a circular structural element with a set radius to obtain the rectangular region.
5. The visual inspection method of claim 1, wherein said pre-processing the image of the surface of the nameplate to be inspected to obtain a pre-processed image comprises:
performing negation operation on the surface nameplate image to be detected to obtain a reversed image;
carrying out gray level opening operation on the image subjected to the negation operation to obtain an image subjected to gray level opening operation;
performing median filtering on the image subjected to the gray-scale opening operation to obtain a median-filtered image;
and carrying out gray scale corrosion on the image subjected to the median filtering to obtain the preprocessed image.
6. The visual inspection method of claim 5, wherein said inverting the image of the surface nameplate to be inspected to obtain an inverted image comprises:
performing negation operation on the surface nameplate image to be detected by adopting the following formula to obtain an operation image after negation:
f″(i,j)=255-f′(i,j)
wherein f' (i, j) represents the pixel value of each pixel point in the surface nameplate image to be detected;
f "(i, j) represents the pixel value of each pixel point in the inverted operation image.
7. The visual inspection method of claim 1, wherein said segmenting scratch defect regions from said pre-processed image using a dynamic threshold segmentation algorithm comprises:
constructing a rectangular filtering template with a set pixel value, and performing mean filtering on the preprocessed image to obtain a mean filtered image;
carrying out smoothing filter processing on the image after the average filtering to obtain an image after the smoothing filter processing;
setting an Offset;
comparing the pixel value of each pixel point in the preprocessed image one by one with the pixel value of the corresponding pixel point in the image processed by the smoothing filter to determine whether the pixel values meet the following conditions: f' (i, j) is less than or equal to m (i, j) -Offset; wherein f' (i, j) represents the pixel value of each pixel point in the pre-processed image, and m (i, j) represents the pixel value of each pixel point in the smoothing filter-processed image;
if not, defining the pixel point as a non-scratch pixel point;
otherwise, defining the pixel point as a scratch pixel point;
comparing one by one to obtain all scratch pixel points;
and performing connected domain processing on all scratch pixel points to obtain at least one scratch defect area.
8. The visual inspection method of claim 7, wherein said segmenting scratch defect regions from said pre-processed image using a dynamic threshold segmentation algorithm further comprises:
obtaining a gray level co-occurrence matrix of each scratch defect area in the at least one scratch defect area;
calculating the contrast characteristic quantity C of each scratch defect area according to the gray level co-occurrence matrix of each scratch defect areae
Calculating average contrast characteristic quantity C of all scratch defect areassTo therebyAnd standard deviation C of contrast characteristic quantitystd
Calculating the area A of each scratch defect regioneAverage area A of all scratch defect regionssAnd area standard deviation Astd
Judging whether the area and the contrast characteristic quantity of each scratch defect area meet the conditions:
Ae∈(As-vAstd,As+vAstd)∩Ce∈(Cs-vCstd,Cs+vCstd)
wherein v represents a defect verification coefficient;
if yes, verifying the scratch defect area as a true scratch defect area;
if not, the scratch defect area is verified as a false scratch defect area.
9. The visual inspection method of claim 8, further comprising:
the following scratch defect severity level criteria are preset:
when A ise∈(As,As+vAstd)∩Ce∈(Cs,Cs+vCstd) Defining the real scratch defect area as a type of defect;
when A ise∈(As-vAstd,As)∩Ce∈(Cs,Cs+vCstd) Defining the real scratch defect area as a second type of defect;
when A ise∈(As,As+vAstd)∩Ce∈(Cs-vCstd,Cs) Defining the real scratch defect area as three types of defects;
when A ise∈(As-vAstd,As)∩Ce∈(Cs-vCstd,Cs) Defining the real scratch defect area as four types of defects;
and classifying each real scratch defect area according to the scratch defect severity grade standard.
10. A visual inspection device of data plate surface mar defect which characterized in that includes:
the image acquisition module is used for acquiring an original image containing a surface image of the nameplate to be detected;
the log equalization transformation module is used for carrying out log equalization transformation on the original image to obtain an image subjected to log equalization transformation;
a binarization processing module for performing binarization processing on the image after the logarithmic equalization transformation by adopting an automatic threshold segmentation algorithm to obtain an image after the binarization processing;
the rectangular region acquisition module is used for determining a connected domain Smax with the largest area in all connected domains of the binarized image and performing open operation on the connected domain Smax by using a circular structural element with a set radius to obtain a rectangular region;
the cutting module is used for cutting the surface image of the nameplate to be detected from the original image by adopting the rectangular area;
the preprocessing module is used for preprocessing the surface image of the nameplate to be detected to obtain a preprocessed image;
and the scratch defect area determining module is used for adopting a dynamic threshold segmentation algorithm to segment the scratch defect area from the preprocessed image.
CN202111650399.4A 2021-12-29 2021-12-29 Visual detection method and device for scratch defects on surface of nameplate Active CN114332026B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111650399.4A CN114332026B (en) 2021-12-29 2021-12-29 Visual detection method and device for scratch defects on surface of nameplate

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111650399.4A CN114332026B (en) 2021-12-29 2021-12-29 Visual detection method and device for scratch defects on surface of nameplate

Publications (2)

Publication Number Publication Date
CN114332026A true CN114332026A (en) 2022-04-12
CN114332026B CN114332026B (en) 2024-08-02

Family

ID=81018910

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111650399.4A Active CN114332026B (en) 2021-12-29 2021-12-29 Visual detection method and device for scratch defects on surface of nameplate

Country Status (1)

Country Link
CN (1) CN114332026B (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115690105A (en) * 2022-12-30 2023-02-03 无锡康贝电子设备有限公司 Milling cutter scratch detection method based on computer vision
CN115689994A (en) * 2022-09-14 2023-02-03 优层智能科技(上海)有限公司 Data plate and bar code defect detection method, equipment and storage medium
CN115965572A (en) * 2022-04-29 2023-04-14 哈尔滨智兀科技有限公司 Three-stage tube appearance defect detection method based on template comparison
CN116309583A (en) * 2023-05-19 2023-06-23 中导光电设备股份有限公司 Method and system for detecting display screen dent defect
CN116563289A (en) * 2023-07-11 2023-08-08 凯德技术长沙股份有限公司 Labeling quality detection method and system based on machine vision
CN118334028A (en) * 2024-06-13 2024-07-12 江苏新长江无缝钢管制造有限公司 Seamless steel tube quality detection method based on image processing

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20140120716A (en) * 2013-04-04 2014-10-14 한국기술교육대학교 산학협력단 Defect detection method in heterogeneously textured surface
WO2021000524A1 (en) * 2019-07-03 2021-01-07 研祥智能科技股份有限公司 Hole protection cap detection method and apparatus, computer device and storage medium
CN113781402A (en) * 2021-08-19 2021-12-10 中国电子产品可靠性与环境试验研究所((工业和信息化部电子第五研究所)(中国赛宝实验室)) Method and device for detecting chip surface scratch defects and computer equipment

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20140120716A (en) * 2013-04-04 2014-10-14 한국기술교육대학교 산학협력단 Defect detection method in heterogeneously textured surface
WO2021000524A1 (en) * 2019-07-03 2021-01-07 研祥智能科技股份有限公司 Hole protection cap detection method and apparatus, computer device and storage medium
CN113781402A (en) * 2021-08-19 2021-12-10 中国电子产品可靠性与环境试验研究所((工业和信息化部电子第五研究所)(中国赛宝实验室)) Method and device for detecting chip surface scratch defects and computer equipment

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
徐伟锋;刘山;: "基于机器视觉的接头组件表面缺陷检测系统研究", 机床与液压, no. 16, 28 August 2020 (2020-08-28), pages 77 - 82 *
王银立;闫斌;: "基于视觉的绝缘子"掉串"缺陷的检测与定位", 计算机工程与设计, no. 02, 16 February 2014 (2014-02-16), pages 231 - 235 *

Cited By (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115965572A (en) * 2022-04-29 2023-04-14 哈尔滨智兀科技有限公司 Three-stage tube appearance defect detection method based on template comparison
CN115965572B (en) * 2022-04-29 2023-07-21 哈尔滨智兀科技有限公司 Tertiary pipe appearance defect detection method based on template comparison
CN115689994A (en) * 2022-09-14 2023-02-03 优层智能科技(上海)有限公司 Data plate and bar code defect detection method, equipment and storage medium
CN115689994B (en) * 2022-09-14 2023-08-04 优层智能科技(上海)有限公司 Nameplate and bar code defect detection method, equipment and storage medium
CN115690105A (en) * 2022-12-30 2023-02-03 无锡康贝电子设备有限公司 Milling cutter scratch detection method based on computer vision
CN115690105B (en) * 2022-12-30 2023-03-21 无锡康贝电子设备有限公司 Milling cutter scratch detection method based on computer vision
CN116309583A (en) * 2023-05-19 2023-06-23 中导光电设备股份有限公司 Method and system for detecting display screen dent defect
CN116309583B (en) * 2023-05-19 2023-10-13 中导光电设备股份有限公司 Method and system for detecting display screen dent defect
CN116563289A (en) * 2023-07-11 2023-08-08 凯德技术长沙股份有限公司 Labeling quality detection method and system based on machine vision
CN116563289B (en) * 2023-07-11 2023-09-29 凯德技术长沙股份有限公司 Labeling quality detection method and system based on machine vision
CN118334028A (en) * 2024-06-13 2024-07-12 江苏新长江无缝钢管制造有限公司 Seamless steel tube quality detection method based on image processing
CN118334028B (en) * 2024-06-13 2024-10-11 江苏新长江无缝钢管制造有限公司 Seamless steel tube quality detection method based on image processing

Also Published As

Publication number Publication date
CN114332026B (en) 2024-08-02

Similar Documents

Publication Publication Date Title
CN114332026B (en) Visual detection method and device for scratch defects on surface of nameplate
CN116168026B (en) Water quality detection method and system based on computer vision
CN111179243A (en) Small-size chip crack detection method and system based on computer vision
CN105447512B (en) A kind of detection method and device for the beauty defect that essence slightly combines
CN109444169B (en) Bearing defect detection method and system
CN110189290A (en) Metal surface fine defects detection method and device based on deep learning
CN113298769B (en) FPC flexible flat cable appearance defect detection method, system and medium
WO2004012148A1 (en) Image processing method for appearance inspection
CN113947598B (en) Plastic lunch box defect detection method, device and system based on image processing
CN115205223B (en) Visual inspection method and device for transparent object, computer equipment and medium
CN116152242B (en) Visual detection system of natural leather defect for basketball
CN117689655B (en) Metal button surface defect detection method based on computer vision
CN110728692A (en) Image edge detection method based on Scharr operator improvement
CN116128849A (en) Method, device, equipment and storage medium for detecting underwater cracks of concrete dam
CN116485779A (en) Adaptive wafer defect detection method and device, electronic equipment and storage medium
CN109507193A (en) A kind of fabric defects detection method based on local contrast enhancing and binary pattern
CN118275449A (en) Copper strip surface defect detection method, device and equipment
CN118014933A (en) Defect detection and identification method and device based on image detection
CN117635615B (en) Defect detection method and system for realizing punching die based on deep learning
CN112950594A (en) Method and device for detecting surface defects of product and storage medium
CN116363097A (en) Defect detection method and system for photovoltaic panel
CN109934817A (en) The external contouring deformity detection method of one seed pod
CN115841632A (en) Power transmission line extraction method and device and binocular ranging method
CN114187269A (en) Method for rapidly detecting surface defect edge of small-sized device
CN113674180A (en) Frosted plane low-contrast defect detection method, device, equipment and storage 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