CN116468689A - Flaw identification method based on gray scale characteristics - Google Patents

Flaw identification method based on gray scale characteristics Download PDF

Info

Publication number
CN116468689A
CN116468689A CN202310402417.XA CN202310402417A CN116468689A CN 116468689 A CN116468689 A CN 116468689A CN 202310402417 A CN202310402417 A CN 202310402417A CN 116468689 A CN116468689 A CN 116468689A
Authority
CN
China
Prior art keywords
gray
value
pixel
area
gray value
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.)
Pending
Application number
CN202310402417.XA
Other languages
Chinese (zh)
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.)
Suzhou Hanwei Intelligent Technology Co ltd
Original Assignee
Suzhou Hanwei Intelligent 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 Suzhou Hanwei Intelligent Technology Co ltd filed Critical Suzhou Hanwei Intelligent Technology Co ltd
Priority to CN202310402417.XA priority Critical patent/CN116468689A/en
Publication of CN116468689A publication Critical patent/CN116468689A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G01MEASURING; TESTING
    • G01NINVESTIGATING OR ANALYSING MATERIALS BY DETERMINING THEIR CHEMICAL OR PHYSICAL PROPERTIES
    • G01N21/00Investigating or analysing materials by the use of optical means, i.e. using sub-millimetre waves, infrared, visible or ultraviolet light
    • G01N21/84Systems specially adapted for particular applications
    • G01N21/88Investigating the presence of flaws or contamination
    • GPHYSICS
    • G01MEASURING; TESTING
    • G01NINVESTIGATING OR ANALYSING MATERIALS BY DETERMINING THEIR CHEMICAL OR PHYSICAL PROPERTIES
    • G01N21/00Investigating or analysing materials by the use of optical means, i.e. using sub-millimetre waves, infrared, visible or ultraviolet light
    • G01N21/84Systems specially adapted for particular applications
    • G01N21/88Investigating the presence of flaws or contamination
    • G01N21/8851Scan or image signal processing specially adapted therefor, e.g. for scan signal adjustment, for detecting different kinds of defects, for compensating for structures, markings, edges
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/20Image enhancement or restoration by the use of local operators
    • G06T5/70
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/0002Inspection of images, e.g. flaw detection
    • G06T7/0004Industrial image inspection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/136Segmentation; Edge detection involving thresholding
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/187Segmentation; Edge detection involving region growing; involving region merging; involving connected component labelling
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/60Analysis of geometric attributes
    • G06T7/62Analysis of geometric attributes of area, perimeter, diameter or volume
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30108Industrial image inspection
    • G06T2207/30124Fabrics; Textile; Paper
    • 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

Abstract

The invention provides a flaw identification method based on gray features, which comprises the following steps: graying and filtering the target textile fabric image to obtain a graying image P; constructing a gray level histogram Z; acquiring an array set S= (S) according to Z 0 ,S 1 ,…,S i ,…S 255 ) The method comprises the steps of carrying out a first treatment on the surface of the Acquiring a pixel point number cavity area and a pixel point continuous area; obtaining ashThe maximum number of pixel points in the degree histogram Z corresponds to the gray value h; if g is less than h and g is less than |g-h|, then from S 0 To S h Traversing; if g > h, and |g-h| > |255-g|, then from S 255 To S h Traversing; otherwise, from S h Is directed to S 0 And S is 255 Traversing; obtaining a threshold dividing point Q of a gray value; performing threshold segmentation and noise filtering on the P to obtain a first target flaw area; the accuracy of flaw identification is improved.

Description

Flaw identification method based on gray scale characteristics
Technical Field
The invention relates to the technical field of image processing, in particular to a flaw identification method based on gray features.
Background
Industrially, flaw detection of raw materials such as wood, steel, textiles, and the like is often divided into two steps: "processing" and "identifying". The effect of directly performing "defect recognition" on the original image is extremely undesirable due to the grain of wood, the gloss of steel, the roughness of textiles, etc., so that a "treatment" operation is generally required, interference caused by the characteristics of these materials themselves is filtered out, and defect information is retained for performing the "recognition" operation.
For a computer, whether a point is a flaw or not is mainly seen as the difference in gray value from the surrounding background. However, in a larger real shot image, the background gray value is often uneven, so that the proper band-pass filtering is selected to perform processing operation, the background gray value is arranged to be more even, and meanwhile, the defects are highlighted. At this time, for smooth and unified materials such as steel and ceramics, a proper threshold is set, and defects can be found by directly using threshold segmentation. However, due to the characteristics of uneven fiber distribution, rough surface, uneven thickness and the like, the obtained image still has a plurality of noise points after being processed by band-pass filtering or other processing modes, and the gray values of the noise points are not different from the gray values of part of flaw points, so that the flaw identification process is greatly interfered, and the flaw identification result in the image is inaccurate.
Disclosure of Invention
Aiming at the technical problems, the invention adopts the following technical scheme:
a method for identifying flaws based on gray scale features, the method comprising the steps of:
step S100, obtaining a target textile image, and carrying out graying and filtering treatment on the target textile image to obtain a graying image P;
step S200, traversing all pixel points in P, obtaining the number of pixel points corresponding to each gray value in a gray value range of 0-255, and constructing a gray histogram Z according to each gray value and the number of pixel points corresponding to each gray value, wherein the X axis of Z is the gray value of a pixel, and the Y axis is the number of pixel points corresponding to the gray value;
step S300, obtaining an array set s= (S) 0 ,S 1 ,…,S i ,…S 255 ) The method comprises the steps of carrying out a first treatment on the surface of the Wherein S is i Is the number of gray values iGroup S i =[i,n i ],n i The number of the pixel points corresponding to the gray value i;
step S400, traversing the step S to obtain a pixel number hollow area and a pixel number continuous area; if j=k=1, the gray value at the junction of the pixel number hole area and the pixel number continuous area is recorded as g' 1 The method comprises the steps of carrying out a first treatment on the surface of the If j=k=2, the gray value at the junction of the hole area of the first pixel number and the continuous area of the first pixel number is denoted as g 1 The gray value at the junction of the hollow area with the second pixel number and the continuous area with the second pixel number is marked as g 2 J is the number of the obtained pixel number hole areas, K is the number of the obtained pixel number continuous areas, the gray value average value corresponding to the first pixel number hole area is smaller than the gray value average value corresponding to the second pixel number hole area, and the gray value average value corresponding to the first pixel number continuous area is smaller than the gray value average value corresponding to the second pixel number continuous area;
step S500, obtaining a gray value h corresponding to the number of the maximum pixel points in the gray histogram Z;
step S600, if g is less than h and g is less than |g-h|, then from S 0 To S h Traversing; if g > h, and |g-h| > |255-g|, then from S 255 To S h Traversing; otherwise, from S h Is directed to S 0 And S is 255 Traversing; according to the traversal procedure n i Obtaining a threshold dividing point Q of a gray value; if j=k=1, the value of g is g' 1 The method comprises the steps of carrying out a first treatment on the surface of the If j=k=2, the value of g is g 1 Or g 2
Step S700, taking the gray value corresponding to Q as the upper limit or the lower limit of threshold segmentation, and carrying out threshold segmentation on P to obtain a suspected flaw area; and performing noise filtering on the suspected flaw area to obtain a first target flaw area.
Optionally, traversing S to obtain a number of hole areas of the pixel points, including:
step S401, traversing S in the order of gray values 0-255, recording the number of the first pixel points as 0Is the gray value d of (2) 1
Step S402, go on traversing d 1 The number of pixels corresponding to the gray value obtained after the step is ignored, the gray value with the number of pixels being 0 is ignored, and d is recorded 1 Gray value d with number of first pixel points not being 0 and number of pixel points corresponding to 10 gray values not being 0 2
Step S403, d 1 To d 2 The area between the two areas is used as a hole area with the number of pixel points.
Optionally, traversing S to obtain a continuous area of the number of pixel points, including:
step S410, traversing S in the order of gray values 0-255, recording gray value d with the number of the first pixel points not being 0 3
Step S420, go on traversing d 3 The number of pixels corresponding to the gray value after the step, the gray value with the number of pixels not being 0 is ignored, and d is recorded 3 The number of the first pixel points is 0 and the gray value d with the number of the pixel points corresponding to the gray value being 0 exists in the 10 gray values 4
Step S430, d 3 To d 4 The area between them is used as the continuous area of the pixel number.
Optionally, the step S600 includes:
step S601, S 0 To S h Traversing, recording n in the traversing process i N is as follows i-1 Of the order of n i The magnitude of n and n i-1 The ratio of the magnitude of (2) is greater than a preset value, record n i The gray value of (a) is a;
step S602, continuing traversing the number of pixels corresponding to the ten gray values after the step A, and if the ratio of the magnitudes of the number of pixels with two adjacent gray values is larger than a preset value, recording the latter gray value in the two adjacent gray values as Q.
Optionally, the step S600 further includes:
step S611, from S 255 To S h Traversing, recording n in the traversing process i N is as follows i+1 Of the order of n i The magnitude of n and n i+1 Of the order of (2)The ratio of (2) is greater than a preset value, record n i The gray value of (a) is a;
step S612, continuing traversing the number of pixels corresponding to the ten gray values after the step A, and if the ratio of the magnitudes of the number of pixels with two adjacent gray values is larger than a preset value, recording the latter gray value in the two adjacent gray values as Q.
Optionally, the step S600 further includes:
step S621, from S h To S 0 Traversing, recording n in the traversing process i N is as follows i-1 Of the order of n i The magnitude of n and n i-1 The ratio of the magnitudes of (2) is greater than a preset value and n i The ratio of the magnitude of the number of pixel points with two adjacent gray values in the ten gray values is larger than a preset value, and n is recorded i The gray value of (2) is Q;
step S623, from S h To S 255 Traversing, recording n in the traversing process i N is as follows i+1 Of the order of n i The magnitude of n and n i+1 The ratio of the magnitudes of (2) is greater than a preset value and n i The ratio of the magnitude of the number of pixel points with two adjacent gray values in the ten gray values is larger than a preset value, and n is recorded i The gray value of (2) is Q.
Optionally, the step S700 includes:
step S710, performing threshold segmentation on P according to the upper limit or the lower limit of the threshold segmentation to obtain a plurality of flaw areas;
and step S720, traversing all the flaw areas, and deleting the flaw areas with the areas smaller than the preset area to obtain the first target flaw area.
Optionally, the method further comprises the steps of:
step S800, carrying out graying treatment on the target textile fabric image to obtain a graying image P1, and obtaining a gray variance DX1 of the P1;
step S900, filtering the P1 to obtain a graying image P2, and obtaining a gray variance DX2 of the P2;
step S1000, if DX1-DX2 > DX0, subtracting the gray value corresponding to the pixel in P2 from the gray value of each pixel in P1 to obtain the difference value of each pixel in P1 and P2; DX0 is a preset gray variance threshold.
Step S1100, marking each communication area formed by pixel points with the difference value larger than a preset difference value threshold value in P1 as a suspected second target flaw area;
step S1200, if the area of the suspected second target area is greater than j×U P1 Marking the suspected second target area as a second target area; wherein j is a preset proportionality coefficient, j is more than 0 and less than 1, U P1 Is the area of P1.
Optionally, the value of j ranges from 5% to 10%.
Optionally, the filtering process in step S100 includes the steps of:
step S110, difference is made between E1 and E2 to generate E3; wherein E1 and E2 are both preset Gaussian filter kernels, the difference between the scales of E1 and E2 is 1, and E3 is a filter kernel generated by E1 and E2;
in step S120, filtering is performed on the grayed-out image by E3 to obtain P.
The invention has at least the following beneficial effects:
according to the flaw identification method based on the gray features, a gray histogram is generated according to the gray value of the gray image P, and the optimal traversal path is determined according to the boundary between the pixel point hole area and the pixel point continuous area and the gray value with the maximum number of pixel points, so that the threshold segmentation points can be searched by the shortest traversal path, and the determination efficiency of the threshold segmentation points is greatly improved; meanwhile, the characteristic of abrupt change of the flaw gray value is utilized, the characteristic is characterized as the abrupt change of the magnitude of the pixel point corresponding to the gray value, the gray value corresponding to the specific threshold dividing point is determined according to the abrupt change of the magnitude, the interference of individual gray noise is avoided, and the accuracy of flaw identification is improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is apparent that the drawings in the following description are only some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flowchart of a flaw identification method based on gray features according to an embodiment of the present invention;
fig. 2 is a gray level histogram according to an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to fall within the scope of the invention.
In one embodiment, a method for identifying defects based on gray scale features as shown in fig. 1 is provided, which may include the steps of:
step S100, obtaining a target textile image, and carrying out graying and filtering treatment on the target textile image to obtain a graying image P.
In this embodiment, the object is a textile, and the gray-scale treatment of the textile image is performed in the prior art, which is not described herein again; the filtering of the image after the graying treatment is carried out in a Gaussian filtering mode, and the specific filtering process comprises the following steps:
step S110, difference is made between E1 and E2 to generate E3; wherein E1 and E2 are both preset Gaussian filter kernels, the difference between the scales of E1 and E2 is 1, and E3 is the Gaussian filter kernel generated by E1 and E2.
In this embodiment, two gaussian filter kernels E1 and E2 with a scale difference of 1 are subtracted to generate a filter kernel E3, where the filter kernel E3 has both a smoothing characteristic of gaussian filtering and a band-pass filtering frequency-selecting characteristic.
In step S120, filtering is performed on the grayed-out image by E3 to obtain P.
The filtering kernel E3 generated based on the method carries out filtering treatment on the gray-scale image, so that the shadow and illumination non-uniform interference in a specific scene can be solved; for example, shadow interference due to non-uniformity of textile fibers and uneven illumination interference due to non-parallel light of a photographing light source.
Step S200, traversing all pixel points in P, obtaining the number of pixel points corresponding to each gray value in a gray value range of 0-255, and constructing a gray histogram Z according to each gray value and the number of pixel points corresponding to each gray value, wherein the X axis of Z is the gray value of a pixel, and the Y axis is the number of pixel points corresponding to the gray value.
In this embodiment, the gray value of each pixel can be obtained by traversing all the pixels in the image P, the gray values of all the pixels are in the range of 0-255, 0-255 is used as the X-axis coordinate parameter of the gray histogram, and the number of pixels corresponding to each gray value is used as the Y-axis coordinate parameter, so as to obtain the gray histogram Z shown in fig. 2.
As an example, the gray histogram Z may be constructed by taking the sum of the areas of all the pixel points corresponding to a certain gray value as the Y-axis coordinate parameter.
Step S300, obtaining an array set s= (S) 0 ,S 1 ,…,S i ,…S 255 ) The method comprises the steps of carrying out a first treatment on the surface of the Wherein S is i Is an array with gray value of i, S i =[i,n i ],n i The number of pixels corresponding to the gray value i.
According to the gray histogram Z constructed in the above step S200, the X-axis coordinate parameter of Z is sequentially traversed, and the number of pixels corresponding to the X-axis coordinate parameter is recorded, so as to obtain a plurality of sets s= (S) 0 ,S 1 ,…,S i ,…S 255 ) The S comprises 256 groups, S i =[i,n i ]I represents gray scale value, i has a value range of 0-255, n i The number of the pixel points corresponding to the gray value i; for example, if the number of pixels corresponding to a gray value of 100 is 2000, S 100 =[100,2000]。
Step S400, traversing the step S to obtain a pixel number hollow area and a pixel number continuous area; if it isJ=k=1, the gray value at the junction of the hollow area of the pixel number and the continuous area of the pixel number is denoted as g' 1 The method comprises the steps of carrying out a first treatment on the surface of the If j=k=2, the gray value at the junction of the hole area of the first pixel number and the continuous area of the first pixel number is denoted as g 1 The gray value at the junction of the hollow area with the second pixel number and the continuous area with the second pixel number is marked as g 2 J is the number of the obtained pixel number hole areas, K is the number of the obtained pixel number continuous areas, the gray value average value corresponding to the first pixel number hole area is smaller than the gray value average value corresponding to the second pixel number hole area, and the gray value average value corresponding to the first pixel number continuous area is smaller than the gray value average value corresponding to the second pixel number continuous area.
It will be appreciated that imperfections refer to variations in the non-material itself, as they are not naturally occurring, so the grey values are strongly abrupt to the background; therefore, the gray histogram of the flaw is characterized by: the occupied area is small, and the gray value is obviously disjointed.
For the gray histogram Z, first, it is necessary to find a hole area with the number of pixels and a continuous area with the number of pixels, and find a hole area with the number of pixels, which includes the following steps:
step S401, traversing S in the order of gray values 0-255, recording the gray value d of 0 for the first pixel 1
Traversing the dataset S, taking the gray value as a variable, judging the number of pixels in each cycle from 0 to 255, and recording the gray value of the cycle as d1 if the number of encountered pixels is 0.
Step S402, go on traversing d 1 The number of pixels corresponding to the gray value obtained after the step is ignored, the gray value with the number of pixels being 0 is ignored, and d is recorded 1 Gray value d with number of first pixel points not being 0 and number of pixel points corresponding to 10 gray values not being 0 2
Continuing the traversal, when the number of pixel points is still 0, the gray value is ignored. When the number of pixels is a value, recording the gray value of the cycle as d 2 . Continuing the traversal, if d 2 After ten consecutive cycles, the number of pixels is not 0, and the hole area is considered to be left (at least ten gray value ranges are required because sporadic, isolated pixels are special cases may occur). D is then 1 -d 2 The region of the number of pixels is the hole region.
Step S403, d 1 To d 2 The area between the two areas is used as a hole area with the number of pixel points.
The method for finding the continuous areas with the number of the pixels comprises the following steps:
step S410, traversing S in the order of gray values 0-255, recording gray value d with the number of the first pixel points not being 0 3
Step S420, go on traversing d 3 The number of pixels corresponding to the gray value after the step, the gray value with the number of pixels not being 0 is ignored, and d is recorded 3 The number of the first pixel points is 0 and the gray value d with the number of the pixel points corresponding to the gray value being 0 exists in the 10 gray values 4
Step S430, d 3 To d 4 The area between them is used as the continuous area of the pixel number.
For a target textile image, a peak tends to appear on a gray level histogram, the peak is close to the middle position, and a cavity area exists on the left side of the peak and the right side of the peak; however, if the whole image is white, the gray histogram is offset to the right side, and the hollow area on the right side of the wave crest is covered completely; if the whole image is blacker, the gray level histogram can deviate to the left side, and the hollow area at the left side of the wave crest can be covered completely. Specifically, the number and position distribution of the hollow area with the number of pixel points and the continuous area with the number of pixel points are as follows:
first case: the number of the pixel number hollow areas and the number of the pixel number continuous areas are 1, and the pixel number hollow areas and the number of the pixel number continuous areas are distributed on the left side of the wave crest.
Second case: the number of the pixel number hollow areas and the number of the pixel number continuous areas are 1, and the pixel number hollow areas and the number of the pixel number continuous areas are distributed on the right side of the wave crest.
In the first case and the second case, the gray value at the junction of the hollow area with the number of pixels and the continuous area with the number of pixels is marked as g' 1
Third case: the number of the pixel number cavity areas and the number of the pixel number continuous areas are 2, a pixel number cavity area and a pixel number continuous area are distributed on the left side of the wave crest, and a pixel number cavity area and a pixel number continuous area are distributed on the right side of the wave crest; in this case, the gray value at the boundary between the left pixel number hollow region and the pixel number continuous region is denoted as g 1 The gray value at the junction of the hollow area with the number of pixels and the continuous area with the number of pixels on the right side is marked as g 2
Step S500, obtaining a gray value h corresponding to the maximum number of pixel points in the gray histogram Z.
In this embodiment, the array with the largest number of pixels can be found by traversing the number of pixels in each array in S, and the gray value in the array is h.
Step S600, if g is less than h and g is less than |g-h|, then from S 0 To S h Traversing; if g > h, and |g-h| > |255-g|, then from S 255 To S h Traversing; otherwise, from S h Is directed to S 0 And S is 255 Traversing; according to the traversal procedure n i Obtaining a threshold dividing point Q of a gray value; if j=k=1, the value of g is g' 1 The method comprises the steps of carrying out a first treatment on the surface of the If j=k=2, the value of g is g 1 Or g 2
In the present embodiment, S is obtained g Then, judging whether the gray value corresponding to the part is closer to 0/255 or the gray value corresponding to the peak value of the pixel point; if the peak is close, the threshold segmentation is approximated from the peak, and if the peak is closer to the edge, the threshold segmentation is approximated from 0/255, and the specific method is as follows:
judging the sizes of g and h, if g is smaller than h, indicating that the junction of the gray value hollow area and the gray value continuous area is positioned at the peak of the pixel pointThe left side of the gray value corresponding to the value is then judged, namely the point with the g closer to 0 and h is found out, if g < |g-h|, the gray value is judged from S 0 To S h Traversing; if g is larger than h, the junction of the gray value cavity region and the gray value continuous region is positioned on the right side of the gray value corresponding to the pixel point peak value, then the magnitudes of g and |g-h| are judged, namely the point with the g closer to 0 and h is found out, if |g-h| > |255-g|, then S is followed 255 To S h Traversing; otherwise, it means that g is closer to h, S h Is directed to S 0 And S is 255 Traversing; the traversal method can maximally reduce the operation amount, improve the traversal efficiency and save the traversal time.
After the target position is determined in the above steps, the two-dimensional array is traversed from "two sides to the middle (if 0/255 is the starting point)/from the middle to two sides (if the peak is the starting point)" from the determined starting point. Recording the magnitude of the number of pixel points, and if the magnitude is changed ten times, recording the gray value corresponding to the change point as a gray value A.
Then, if ten times or more of the magnitude change occurs again in the ten gray value ranges after the gray value a, the intersection of the "mountain slope" and the "mountain foot" is considered to be traversed, and the gray value of the point is recorded as the gray value B.
If it starts from 0/255, the gray value B is the point where "start up slope", and this point is taken as the threshold division point Q. If the peak starts, the gray value a is a point "down to the mountain foot", and the point is defined as a threshold dividing point Q.
The specific traversing method comprises the following steps:
step S601, S 0 To S h Traversing, recording n in the traversing process i N is as follows i-1 Of the order of n i The magnitude of n and n i-1 The ratio of the magnitude of (2) is greater than a preset value, record n i The gray value of (a) is a.
Step S602, continuing traversing the number of pixels corresponding to the ten gray values after the step A, and if the ratio of the magnitudes of the number of pixels with two adjacent gray values is larger than a preset value, recording the latter gray value in the two adjacent gray values as Q.
Step S611, from S 255 To S h Traversing, recording n in the traversing process i N is as follows i+1 Of the order of n i The magnitude of n and n i+1 The ratio of the magnitude of (2) is greater than a preset value, record n i The gray value of (a) is a.
Step S612, continuing traversing the number of pixels corresponding to the ten gray values after the step A, and if the ratio of the magnitudes of the number of pixels with two adjacent gray values is larger than a preset value, recording the latter gray value in the two adjacent gray values as Q.
Step S621, from S h To S 0 Traversing, recording n in the traversing process i N is as follows i-1 Of the order of n i The magnitude of n and n i-1 The ratio of the magnitudes of (2) is greater than a preset value and n i The ratio of the magnitude of the number of pixel points with two adjacent gray values in the ten gray values is larger than a preset value, and n is recorded i The gray value of (2) is Q.
Step S622, from S h To S 255 Traversing, recording n in the traversing process i N is as follows i+1 Of the order of n i The magnitude of n and n i+1 The ratio of the magnitudes of (2) is greater than a preset value and n i The ratio of the magnitude of the number of pixel points with two adjacent gray values in the ten gray values is larger than a preset value, and n is recorded i The gray value of (2) is Q.
Step S700, taking the gray value corresponding to Q as the upper limit or the lower limit of threshold segmentation, and carrying out threshold segmentation on P to obtain a suspected flaw area; and performing noise filtering on the suspected flaw area to obtain a first target flaw area.
After a threshold segmentation point Q is determined, threshold segmentation is carried out by taking the point Q as the upper limit/lower limit of threshold segmentation; specifically, if Q is found at the left side of the peak value in the above step, the pixel point corresponding to the gray value with the gray value smaller than Q is used as the suspected flaw pixel point; and if Q is found at the right side of the peak value in the step, taking the pixel point corresponding to the gray value with the gray value larger than Q as the suspected flaw pixel point.
The sub-threshold segmentation can segment all flaws and partial noise together, and the detection rate is close to 100%, but the accuracy is not high. In order to improve accuracy, it is necessary to shield noise effects, and the method of shielding noise effects includes the following steps:
and step S710, performing threshold segmentation on the P according to the upper limit or the lower limit of the threshold segmentation to obtain a plurality of flaw areas.
And step S720, traversing all the flaw areas, and deleting the flaw areas with the areas smaller than the preset area to obtain the first target flaw area.
Because noise is a side effect of gaussian filtering, which concentrates these noise points within very small pixels (1-4 pixels), flaws of such small magnitude are virtually nonexistent in nature. Therefore, the interference of noise can be filtered out by carrying out area screening on all the separated objects; finally, the resulting object is a flaw.
The defects caused by the material problem can be obtained by the method, and besides the conventional small defects of holes, mosquitoes and the like, the textile also has oversized defects of wrinkles and the like caused by unreasonable accumulation and storage; since the nature of such imperfections is also the material itself, the gray level histogram is not as "obtrusive" as conventional imperfections.
The definition of the type of flaws cannot be performed by using the gray histogram characteristics like the conventional flaws, and the definition needs to be judged according to gray variance; the gray variance is an index for describing the gray variation degree of an image, and the larger the gray variance is, the more severe the variation condition of the image is; the smaller the gray variance, the smoother the image change. Therefore, the gray variance of an image having an oversized flaw tends to be large. Therefore, by means of high-intensity mean filtering, the oversized flaw is "erased", and the gray variance of the obtained image is reduced greatly.
And the gray variance before and after the mean filtering of the image without oversized flaws does not differ too much. Therefore, the gray variance before and after the mean value filtering is subtracted, and if the difference is larger than the judgment value set by the user, the image is considered to have oversized flaws.
In this embodiment, the method further includes a method for detecting oversized flaws, where the method includes the following steps:
step S800, performing graying processing on the target textile fabric image to obtain a graying image P1, and obtaining a gray variance DX1 of P1.
In this embodiment, the graying processing of the target image is performed in the prior art, and will not be described herein.
Step S900, performing filtering processing on P1 to obtain a grayscale image P2, and obtaining a grayscale variance DX2 of P2.
In this embodiment, the graying image P1 is filtered by means of mean filtering, so as to obtain a graying image P2.
In step S1100, each connected region formed by the pixel points with the difference value greater than the preset difference threshold in P1 is marked as a suspected second target defect region.
Subtracting the gray value of each pixel point in P1 from the gray value of each pixel point in P2, which corresponds to the gray value of each pixel point in P1, to obtain the difference value of the gray values of each pixel point, finding out the pixel point with the difference value larger than the preset difference value threshold, wherein the preset difference value threshold can be selected as 10, and taking each connected region formed by the found pixel points as a suspected second target flaw region.
Step S1200, if the area of the suspected second target area is greater than j×U P1 Marking the suspected second target area as a second target area; wherein j is a preset proportionality coefficient, j is more than 0 and less than 1, U P1 Is the area of P1.
Step S1200, if the area of the suspected second target area is greater than j×U P1 Marking the suspected second target area as a second target area; wherein j is a preset proportionality coefficient, j is more than 0 and less than 1, U P1 Is the area of P1.
The above steps may be able to find large flaws, but also mark many shadow parts that are erased by filtering, and therefore, the shadow parts need to be filtered out. Specifically, j times of the area of the whole image of P1 is taken as a lower limit, area screening is carried out, and the screened object is the second target flaw area, namely the large flaw area; in this embodiment, the value range of j may be 5% -10%.
The flaw identification method based on gray features of the embodiment has the following characteristics:
(1) The gray level histogram is generated according to the gray level value of the gray level image, and the optimal traversing path is determined according to the boundary between the pixel point hole area and the pixel point continuous area and the gray level value with the maximum number of the pixel points.
(2) The characteristic of abrupt change of the flaw gray value is utilized, the characteristic is characterized as the abrupt change of the magnitude of the pixel point corresponding to the gray value, the gray value corresponding to the specific threshold dividing point is determined according to the abrupt change of the magnitude, the interference of individual gray noise is avoided, and the accuracy of flaw identification is improved.
(3) And taking the gray value of each pixel point of the gray image P1 before mean value filtering and the gray value of each pixel point of the gray image P2 after mean value filtering as a large flaw area, and further improving the flaw identification accuracy by taking the area with the difference value of the gray values larger than a preset value as a flaw identification structure to avoid the influence of unreal flaws.
Furthermore, although the steps of the methods in the present disclosure are depicted in a particular order in the drawings, this does not require or imply that the steps must be performed in that particular order or that all illustrated steps be performed in order to achieve desirable results. Additionally or alternatively, certain steps may be omitted, multiple steps combined into one step to perform, and/or one step decomposed into multiple steps to perform, etc.
The foregoing is merely specific embodiments of the present application, but the scope of the present application is not limited thereto, and any changes or substitutions easily conceivable by those skilled in the art within the technical scope of the present application should be covered in the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (10)

1. A method for identifying flaws based on gray scale features, the method comprising the steps of:
step S100, obtaining a target textile image, and carrying out graying and filtering treatment on the target textile image to obtain a graying image P;
step S200, traversing all pixel points in P, obtaining the number of pixel points corresponding to each gray value in a gray value range of 0-255, and constructing a gray histogram Z according to each gray value and the number of pixel points corresponding to each gray value, wherein the X axis of Z is the gray value of a pixel, and the Y axis is the number of pixel points corresponding to the gray value;
step S300, obtaining an array set s= (S) 0 ,S 1 ,…,S i ,…S 255 ) The method comprises the steps of carrying out a first treatment on the surface of the Wherein S is i Is an array with gray value of i, S i =[i,n i ],n i The number of the pixel points corresponding to the gray value i;
step S400, traversing the step S to obtain a pixel number hollow area and a pixel number continuous area; if j=k=1, the gray value at the junction of the pixel number hole area and the pixel number continuous area is recorded as g' 1 The method comprises the steps of carrying out a first treatment on the surface of the If j=k=2, the gray value at the junction of the hole area of the first pixel number and the continuous area of the first pixel number is denoted as g 1 The gray value at the junction of the hollow area with the second pixel number and the continuous area with the second pixel number is marked as g 2 J is the number of the obtained pixel number hole areas, K is the number of the obtained pixel number continuous areas, the gray value average value corresponding to the first pixel number hole area is smaller than the gray value average value corresponding to the second pixel number hole area, and the gray value average value corresponding to the first pixel number continuous area is smaller than the gray value average value corresponding to the second pixel number continuous area;
step S500, obtaining a gray value h corresponding to the number of the maximum pixel points in the gray histogram Z;
step S600, if g is less than h and g is less than |g-h|, then from S 0 To S h Traversing; if g > h, and |g-h| > |255-g|, then from S 255 To S h Traversing; otherwise, from S h Is directed to S 0 And S is 255 Traversing; according to the traversal procedure n i Obtaining a threshold dividing point Q of a gray value; if j=k=1, the value of g is g' 1 The method comprises the steps of carrying out a first treatment on the surface of the If j=k=2, the value of g is g 1 Or g 2
Step S700, taking the gray value corresponding to Q as the upper limit or the lower limit of threshold segmentation, and carrying out threshold segmentation on P to obtain a suspected flaw area; and performing noise filtering on the suspected flaw area to obtain a first target flaw area.
2. The method of claim 1, wherein traversing S to obtain a number of void areas of pixel points comprises:
step S401, traversing S in the order of gray values 0-255, recording the gray value d of 0 for the first pixel 1
Step S402, go on traversing d 1 The number of pixels corresponding to the gray value obtained after the step is ignored, the gray value with the number of pixels being 0 is ignored, and d is recorded 1 Gray value d with number of first pixel points not being 0 and number of pixel points corresponding to 10 gray values not being 0 2
Step S403, d 1 To d 2 The area between the two areas is used as a hole area with the number of pixel points.
3. The method of claim 1, wherein traversing S to obtain a continuous region of pixel count comprises:
step S410, traversing S in the order of gray values 0-255, recording gray value d with the number of the first pixel points not being 0 3
Step S420, go on traversing d 3 The number of pixels corresponding to the gray value after the step, the gray value with the number of pixels not being 0 is ignored, and d is recorded 3 The number of the first pixel points is 0 and gray with the number of the pixel points corresponding to the gray value being 0 exists in the 10 gray valuesDegree value d 4
Step S430, d 3 To d 4 The area between them is used as the continuous area of the pixel number.
4. The defect identifying method according to claim 1, wherein the step S600 includes:
step S601, S 0 To S h Traversing, recording n in the traversing process i N is as follows i-1 Of the order of n i The magnitude of n and n i-1 The ratio of the magnitude of (2) is greater than a preset value, record n i The gray value of (a) is a;
step S602, continuing traversing the number of pixels corresponding to the ten gray values after the step A, and if the ratio of the magnitudes of the number of pixels with two adjacent gray values is larger than a preset value, recording the latter gray value in the two adjacent gray values as Q.
5. The defect identifying method according to claim 1, wherein the step S600 further comprises:
step S611, from S 255 To S h Traversing, recording n in the traversing process i N is as follows i+1 Of the order of n i The magnitude of n and n i+1 The ratio of the magnitude of (2) is greater than a preset value, record n i The gray value of (a) is a;
step S612, continuing traversing the number of pixels corresponding to the ten gray values after the step A, and if the ratio of the magnitudes of the number of pixels with two adjacent gray values is larger than a preset value, recording the latter gray value in the two adjacent gray values as Q.
6. The defect identifying method according to claim 1, wherein the step S600 further comprises:
step S621, from S h To S 0 Traversing, recording n in the traversing process i N is as follows i-1 Of the order of n i The magnitude of n and n i-1 The ratio of the magnitudes of (2) is greater than a preset value and n i Adjacent ones exist in the last ten gray valuesThe ratio of the magnitude of the pixel point numbers of the two gray values is larger than a preset value, and n is recorded i The gray value of (2) is Q;
step S622, from S h To S 255 Traversing, recording n in the traversing process i N is as follows i+1 Of the order of n i The magnitude of n and n i+1 The ratio of the magnitudes of (2) is greater than a preset value and n i The ratio of the magnitude of the number of pixel points with two adjacent gray values in the ten gray values is larger than a preset value, and n is recorded i The gray value of (2) is Q.
7. The defect identifying method according to claim 1, wherein the step S700 includes:
step S710, performing threshold segmentation on P according to the upper limit or the lower limit of the threshold segmentation to obtain a plurality of flaw areas;
and step S720, traversing all the flaw areas, and deleting the flaw areas with the areas smaller than the preset area to obtain the first target flaw area.
8. The method of defect identification of claim 1, further comprising the steps of:
step S800, carrying out graying treatment on the target textile fabric image to obtain a graying image P1, and obtaining a gray variance DX1 of the P1;
step S900, filtering the P1 to obtain a graying image P2, and obtaining a gray variance DX2 of the P2;
step S1000, if DX1-DX2 > DX0, subtracting the gray value corresponding to the pixel in P2 from the gray value of each pixel in P1 to obtain the difference value of each pixel in P1 and P2; DX0 is a preset gray variance threshold.
Step S1100, marking each communication area formed by pixel points with the difference value larger than a preset difference value threshold value in P1 as a suspected second target flaw area;
step S1200, if the area of the suspected second target area is greater than j×U P1 Marking the suspected second target area as a second target area; wherein j is presetRatio coefficient of 0 < j < 1, U P1 Is the area of P1.
9. The method of claim 8, wherein j has a value in the range of 5% to 10%.
10. The flaw identification method according to claim 1, characterized in that the filtering process in step S100 includes the steps of:
step S110, difference is made between E1 and E2 to generate E3; wherein E1 and E2 are both preset Gaussian filter kernels, the difference between the scales of E1 and E2 is 1, and E3 is a filter kernel generated by E1 and E2;
in step S120, filtering is performed on the grayed-out image by E3 to obtain P.
CN202310402417.XA 2023-04-14 2023-04-14 Flaw identification method based on gray scale characteristics Pending CN116468689A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310402417.XA CN116468689A (en) 2023-04-14 2023-04-14 Flaw identification method based on gray scale characteristics

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310402417.XA CN116468689A (en) 2023-04-14 2023-04-14 Flaw identification method based on gray scale characteristics

Publications (1)

Publication Number Publication Date
CN116468689A true CN116468689A (en) 2023-07-21

Family

ID=87183776

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310402417.XA Pending CN116468689A (en) 2023-04-14 2023-04-14 Flaw identification method based on gray scale characteristics

Country Status (1)

Country Link
CN (1) CN116468689A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117237646A (en) * 2023-11-15 2023-12-15 深圳市润海电子有限公司 PET high-temperature flame-retardant adhesive tape flaw extraction method and system based on image segmentation

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117237646A (en) * 2023-11-15 2023-12-15 深圳市润海电子有限公司 PET high-temperature flame-retardant adhesive tape flaw extraction method and system based on image segmentation
CN117237646B (en) * 2023-11-15 2024-01-30 深圳市润海电子有限公司 PET high-temperature flame-retardant adhesive tape flaw extraction method and system based on image segmentation

Similar Documents

Publication Publication Date Title
CN114723701B (en) Gear defect detection method and system based on computer vision
CN115222741B (en) Cable surface defect detection method
CN108629775B (en) Thermal state high-speed wire rod surface image processing method
Oberholzer et al. Methods in quantitative image analysis
CN111179243A (en) Small-size chip crack detection method and system based on computer vision
CN115375676A (en) Stainless steel product quality detection method based on image recognition
CN115294158A (en) Hot continuous rolling strip steel image segmentation method based on machine vision
CN109242853A (en) A kind of PCB defect intelligent detecting method based on image procossing
CN116843688B (en) Visual detection method for quality of textile
CN109540925B (en) Complex ceramic tile surface defect detection method based on difference method and local variance measurement operator
CN116468689A (en) Flaw identification method based on gray scale characteristics
CN116912256B (en) Corrugated paper rib defect degree assessment method based on image processing
JP4060558B2 (en) Defect inspection method and apparatus
CN116580024B (en) Coke quality detection method based on image processing
CN112308854A (en) Automatic detection method and system for chip surface flaws and electronic equipment
CN115861320A (en) Intelligent detection method for automobile part machining information
JP2006292593A (en) Flaw detector, flaw detecting method, computer program and recording medium
CN117197140A (en) Irregular metal buckle forming detection method based on machine vision
CN115272305A (en) Button hole defect detection method
CN116894840B (en) Spinning proofing machine product quality detection method and system
CN114166849B (en) Method for detecting defects of printed carbon lines and moisture-sensitive film of humidity sensor
JPH0627715B2 (en) Quality evaluation device for slab section
CN115690011A (en) Synthetic adhesive non-woven fabric stain detection method based on optical information
Liao et al. Defect detection and classification of machined surfaces under multiple illuminant directions
JP2023529512A (en) Method and apparatus for identifying trading card characteristics

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