[go: up one dir, main page]

CN118570213B - A method for detecting defects in optical wafers - Google Patents

A method for detecting defects in optical wafers Download PDF

Info

Publication number
CN118570213B
CN118570213B CN202411060113.0A CN202411060113A CN118570213B CN 118570213 B CN118570213 B CN 118570213B CN 202411060113 A CN202411060113 A CN 202411060113A CN 118570213 B CN118570213 B CN 118570213B
Authority
CN
China
Prior art keywords
contour
coordinates
area
mask
coordinate
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202411060113.0A
Other languages
Chinese (zh)
Other versions
CN118570213A (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.)
Yantai University
Original Assignee
Yantai University
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 Yantai University filed Critical Yantai University
Priority to CN202411060113.0A priority Critical patent/CN118570213B/en
Publication of CN118570213A publication Critical patent/CN118570213A/en
Application granted granted Critical
Publication of CN118570213B publication Critical patent/CN118570213B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/0002Inspection of images, e.g. flaw detection
    • G06T7/0004Industrial image inspection
    • GPHYSICS
    • G01MEASURING; TESTING
    • G01NINVESTIGATING OR ANALYSING MATERIALS BY DETERMINING THEIR CHEMICAL OR PHYSICAL PROPERTIES
    • G01N21/00Investigating or analysing materials by the use of optical means, i.e. using sub-millimetre waves, infrared, visible or ultraviolet light
    • G01N21/84Systems specially adapted for particular applications
    • G01N21/88Investigating the presence of flaws or contamination
    • G01N21/8851Scan or image signal processing specially adapted therefor, e.g. for scan signal adjustment, for detecting different kinds of defects, for compensating for structures, markings, edges
    • GPHYSICS
    • 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/95Investigating the presence of flaws or contamination characterised by the material or shape of the object to be examined
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/70Denoising; Smoothing
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/13Edge detection
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/136Segmentation; Edge detection involving thresholding
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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 OR CALCULATING; 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 OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/70Determining position or orientation of objects or cameras
    • G06T7/73Determining position or orientation of objects or cameras using feature-based methods
    • GPHYSICS
    • G01MEASURING; TESTING
    • G01NINVESTIGATING OR ANALYSING MATERIALS BY DETERMINING THEIR CHEMICAL OR PHYSICAL PROPERTIES
    • G01N21/00Investigating or analysing materials by the use of optical means, i.e. using sub-millimetre waves, infrared, visible or ultraviolet light
    • G01N21/84Systems specially adapted for particular applications
    • G01N21/88Investigating the presence of flaws or contamination
    • G01N21/8851Scan or image signal processing specially adapted therefor, e.g. for scan signal adjustment, for detecting different kinds of defects, for compensating for structures, markings, edges
    • G01N2021/8854Grading and classifying of flaws
    • G01N2021/8874Taking dimensions of defect into account
    • GPHYSICS
    • G01MEASURING; TESTING
    • G01NINVESTIGATING OR ANALYSING MATERIALS BY DETERMINING THEIR CHEMICAL OR PHYSICAL PROPERTIES
    • G01N21/00Investigating or analysing materials by the use of optical means, i.e. using sub-millimetre waves, infrared, visible or ultraviolet light
    • G01N21/84Systems specially adapted for particular applications
    • G01N21/88Investigating the presence of flaws or contamination
    • G01N21/8851Scan or image signal processing specially adapted therefor, e.g. for scan signal adjustment, for detecting different kinds of defects, for compensating for structures, markings, edges
    • G01N2021/8887Scan or image signal processing specially adapted therefor, e.g. for scan signal adjustment, for detecting different kinds of defects, for compensating for structures, markings, edges based on image processing techniques
    • GPHYSICS
    • 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/95Investigating the presence of flaws or contamination characterised by the material or shape of the object to be examined
    • G01N2021/9511Optical elements other than lenses, e.g. mirrors
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Immunology (AREA)
  • General Health & Medical Sciences (AREA)
  • Biochemistry (AREA)
  • Analytical Chemistry (AREA)
  • Pathology (AREA)
  • Chemical & Material Sciences (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Signal Processing (AREA)
  • Geometry (AREA)
  • Quality & Reliability (AREA)
  • Image Analysis (AREA)

Abstract

本发明公开了一种光通片缺陷检测方法,包括以下步骤:步骤一:将原始图像转化为灰度图进行预处理获得二值化图像;步骤二:通过轮廓检测获取二值化图像中的光通片顶点坐标即轮廓检测坐标以及光通片尺寸、光通片倾斜角度、光通片中心坐标;步骤三:使用Blob检测获取灰度图中光通片中心坐标;步骤四:将轮廓检测坐标与Blob检测坐标融合后的坐标进行顶点内缩去除二值化图像中的光通片毛边对最终检测结果的影响并制作掩膜图;步骤五:对二值化图像的外接矩形区域进行缺陷检测,随后在原始图像中对缺陷进行标记。本发明使用Blob中心坐标与轮廓中心坐标对比,并将Blob中心坐标与轮廓信息结合,补充轮廓顶点坐标,防止出现漏检,获取的坐标更加准确。

The present invention discloses a method for detecting defects of a light pass sheet, comprising the following steps: step 1: converting an original image into a grayscale image for preprocessing to obtain a binary image; step 2: obtaining the vertex coordinates of the light pass sheet in the binary image, namely, the contour detection coordinates, as well as the size of the light pass sheet, the inclination angle of the light pass sheet, and the center coordinates of the light pass sheet through contour detection; step 3: using Blob detection to obtain the center coordinates of the light pass sheet in the grayscale image; step 4: performing vertex indentation on the coordinates after the contour detection coordinates and the Blob detection coordinates are fused to remove the influence of the burrs of the light pass sheet in the binary image on the final detection result and to prepare a mask map; step 5: performing defect detection on the circumscribed rectangular area of the binary image, and then marking the defects in the original image. The present invention compares the Blob center coordinates with the contour center coordinates, combines the Blob center coordinates with the contour information, supplements the contour vertex coordinates, prevents missed detection, and obtains more accurate coordinates.

Description

一种光通片缺陷检测方法A method for detecting defects in optical wafers

技术领域Technical Field

本发明涉及一种检测方法,特别涉及一种光通片缺陷检测方法。The invention relates to a detection method, in particular to a method for detecting defects in optical pass sheets.

背景技术Background Art

光通片又称为光学薄膜片,其生产过程复杂而精密,在许多高科技应用中扮演着重要的角色,如激光器、太阳能电池、光纤通信等。在光通片的生产、转运过程中,很容易造成表面划伤、崩边、点伤等难以发现的微小缺陷,这些缺陷可能导致产品性能下降,甚至使产品无法使用。Optical film, also known as optical thin film, has a complex and precise production process and plays an important role in many high-tech applications, such as lasers, solar cells, and fiber-optic communications. During the production and transportation of optical film, it is easy to cause surface scratches, edge collapse, pitting and other small defects that are difficult to find. These defects may cause product performance degradation or even make the product unusable.

由于光通片模组包含多个光通片单元,每个光通片单元长度和宽度均在1.4-2.5毫米之间,对于这种微小的表面缺陷,人工检测时,常使用高倍目镜观察,并通过手动小幅度调整光通片位置,观察每个光通片单元的缺陷情况,这种检测方式不仅检测效率低,工作量大,长时间工作对检测人员也会造成视觉伤害,而且检测人员的检测水平参差不齐,容易出现漏检错检现象,对产品质量影响较大。Since the optical sheet module contains multiple optical sheet units, the length and width of each optical sheet unit are between 1.4-2.5 mm. For such tiny surface defects, high-power eyepieces are often used for observation during manual inspection, and the position of the optical sheet is manually adjusted in small increments to observe the defects of each optical sheet unit. This inspection method not only has low inspection efficiency and large workload, but also causes visual damage to inspectors during long working hours. In addition, the inspection levels of inspectors are uneven, which is prone to missed inspections and wrong inspections, which has a great impact on product quality.

综上所述需要引入具有高精度检测效果的光通片自动化缺陷检测方法,能够有效识别各种缺陷,代替人工检测在生产线上快速执行,提高检测效率。In summary, it is necessary to introduce an automated defect detection method for optical wafers with high-precision detection effects, which can effectively identify various defects, replace manual detection and quickly execute it on the production line to improve detection efficiency.

发明内容Summary of the invention

针对现有技术中存在的技术问题,本发明的目的是:提供一种光通片缺陷检测方法。In view of the technical problems existing in the prior art, the purpose of the present invention is to provide a method for detecting defects in optical pass sheets.

本发明的目的通过下述技术方案实现:一种光通片缺陷检测方法,包括以下步骤:The object of the present invention is achieved by the following technical solution: A method for detecting defects in a light-transmitting sheet comprises the following steps:

步骤一:通过图像采集装置获取带有光通片的原始图,将原始图复制为灰度图;Step 1: Obtain the original image with the optical pass film through an image acquisition device, and copy the original image into a grayscale image;

步骤二:对灰度图进行预处理,通过轮廓检测和夹角余弦值筛选,获取轮廓顶点坐标,并计算轮廓中心坐标、轮廓宽度、轮廓高度以及轮廓倾斜角度;Step 2: Preprocess the grayscale image, obtain the coordinates of the contour vertices through contour detection and angle cosine value screening, and calculate the contour center coordinates, contour width, contour height and contour inclination angle;

步骤三:使用Blob检测获取灰度图中Blob中心坐标,通过Blob中心坐标与轮廓中心坐标对比,将Blob中心坐标与轮廓信息结合,补充轮廓顶点坐标,获得补充坐标,并对补充坐标使用内缩算法获得内缩坐标;Step 3: Use Blob detection to obtain the center coordinates of the Blob in the grayscale image, compare the center coordinates of the Blob with the center coordinates of the contour, combine the center coordinates of the Blob with the contour information, supplement the coordinates of the contour vertices, obtain the supplementary coordinates, and use the indentation algorithm on the supplementary coordinates to obtain the indentation coordinates;

步骤四:创建与灰度图分辨率一致的黑色图像,对黑色图像的内缩坐标使用多边形外接矩形算法获取内缩坐标的外接矩形区域即黑色图像掩膜区域,对与黑色图像掩膜区域坐标相同的灰度图掩膜区域进行积分二值化及预处理,生成掩膜边缘图;Step 4: Create a black image with the same resolution as the grayscale image, use the polygonal circumscribed rectangle algorithm for the indented coordinates of the black image to obtain the circumscribed rectangular area of the indented coordinates, i.e., the black image mask area, perform integral binarization and preprocessing on the grayscale image mask area with the same coordinates as the black image mask area, and generate a mask edge map;

步骤五:对掩膜边缘图进行缺陷检测获取缺陷信息,随后在原始图中进行缺陷标记。Step 5: Perform defect detection on the mask edge image to obtain defect information, and then mark the defects in the original image.

优选的,获取原始图:通过带有高清相机的图像采集装置获取带有光通片的原始图,将原始图复制为灰度图;Preferably, obtaining the original image: obtaining the original image with the optical pass film by an image acquisition device with a high-definition camera, and copying the original image into a grayscale image;

获取轮廓信息:对灰度图使用高斯模糊处理,降低灰度图噪声使灰度图变得平滑,为提取特征做准备;使用Sobel算子计算灰度图的总梯度并生成灰度图的总梯度图,使灰度图仅显示像素强度变化率,进而对灰度图的总梯度图使用参数阈值法进行二值化,将灰度图的总梯度图分为前景和背景,即获得参数轮廓图;再使用OpenCV自适应阈值法对参数轮廓图进行二值化,将参数轮廓图分为边缘区域和非边缘区域,使参数轮廓图中的轮廓变为单像素显示,即获取边缘轮廓图;计算边缘轮廓图中检测到的连通域面积并对比第一设定面积,删除边缘轮廓图中连通域面积小于第一设定面积的区域;使用Sobel算子计算边缘轮廓图的总梯度并通过参数阈值法进行二值化获取参数边缘轮廓图;使用边缘查找算法获取参数边缘轮廓图中的连通区域的边缘,对连通区域的边缘进行多边形逼近,获取连通区域轮廓;去除连通区域轮廓中除凸四边形轮廓以外的连通区域轮廓,通过凸四边形轮廓顶点坐标互相计算夹角余弦值,选取凸四边形轮廓顶点坐标形成的夹角余弦值的最大值与第二设定值比较,小于第二设定值判断凸四边形的形状接近矩形,筛选出形状接近矩形的凸四边形轮廓,并使用外接倾斜矩形算法计算凸四边形轮廓的外接倾斜矩形,即轮廓顶点坐标;通过轮廓顶点坐标计算轮廓中心坐标,将轮廓顶点坐标与轮廓中心坐标对比,按照顺时针重新排列;根据轮廓顶点坐标排序的前两个点与X坐标轴的夹角进行反三角函数计算获得轮廓倾斜角度,并计算轮廓宽度和轮廓高度;Obtain contour information: Use Gaussian blur processing on the grayscale image to reduce the noise of the grayscale image and make the grayscale image smooth in preparation for feature extraction; Use the Sobel operator to calculate the total gradient of the grayscale image and generate the total gradient map of the grayscale image, so that the grayscale image only displays the pixel intensity change rate, and then use the parameter threshold method to binarize the total gradient map of the grayscale image, and divide the total gradient map of the grayscale image into foreground and background, that is, obtain the parameter contour map; then use the OpenCV adaptive threshold method to binarize the parameter contour map, divide the parameter contour map into edge areas and non-edge areas, so that the contour in the parameter contour map becomes a single pixel display, that is, obtain the edge contour map; calculate the area of the connected domain detected in the edge contour map and compare it with the first set area, and delete the area in the edge contour map where the connected domain area is smaller than the first set area; Use the Sobel operator to calculate the total gradient of the edge contour map and binarize it by the parameter threshold method to obtain the parameter edge contour Figure; use the edge search algorithm to obtain the edge of the connected area in the parameter edge contour map, perform polygonal approximation on the edge of the connected area, and obtain the contour of the connected area; remove the connected area contours except the convex quadrilateral contour in the connected area contour, calculate the cosine value of the angle between the vertex coordinates of the convex quadrilateral contour, select the maximum value of the cosine value of the angle formed by the vertex coordinates of the convex quadrilateral contour and compare it with the second set value, and if it is less than the second set value, it is judged that the shape of the convex quadrilateral is close to a rectangle, and the convex quadrilateral contour with a shape close to a rectangle is screened out, and the circumscribed inclined rectangle algorithm is used to calculate the circumscribed inclined rectangle of the convex quadrilateral contour, that is, the contour vertex coordinates; calculate the contour center coordinates through the contour vertex coordinates, compare the contour vertex coordinates with the contour center coordinates, and rearrange them clockwise; perform inverse trigonometric function calculation on the angle between the first two points sorted by the contour vertex coordinates and the X-coordinate axis to obtain the contour inclination angle, and calculate the contour width and contour height;

获取Blob中心坐标并补充轮廓顶点坐标:Blob检测器对检测样式进行设定,使Blob检测器仅检测四边形样式斑块;Blob检测器对检测面积进行设定,使Blob检测器筛除在第三设定面积范围外的斑块;使用配置完成的Blob检测器直接检测灰度图,获得Blob中心坐标;通过欧几里得距离公式计算Blob中心坐标与轮廓中心坐标之间的距离dis,当dis小于或等于第四设定值时,则Blob中心坐标与轮廓中心坐标为同一个光通片的中心点,则无须补充;当dis大于第四设定值时,则认为Blob中心坐标与轮廓中心坐标不一致,此时需要将Blob检测获得的光通片补充到轮廓检测获得的光通片中,获得补充坐标;为防止图像边缘的光通片被误检,去除超出灰度图边缘的补充坐标;并将在灰度图边缘内的补充坐标进行多边形内缩获取内缩坐标;Obtain the Blob center coordinates and supplement the contour vertex coordinates: the Blob detector sets the detection style so that the Blob detector only detects quadrilateral style patches; the Blob detector sets the detection area so that the Blob detector screens out patches outside the third set area range; the configured Blob detector is used to directly detect the grayscale image to obtain the Blob center coordinates; the distance dis between the Blob center coordinates and the contour center coordinates is calculated using the Euclidean distance formula. When dis is less than or equal to the fourth set value, the Blob center coordinates and the contour center coordinates are the center points of the same optical pass sheet and no supplement is required; when dis is greater than the fourth set value, the Blob center coordinates are considered inconsistent with the contour center coordinates. At this time, the optical pass sheet obtained by the Blob detection needs to be supplemented to the optical pass sheet obtained by the contour detection to obtain supplementary coordinates; in order to prevent the optical pass sheet at the edge of the image from being misdetected, the supplementary coordinates that exceed the edge of the grayscale image are removed; and the supplementary coordinates within the edge of the grayscale image are polygonally indented to obtain the indented coordinates;

获取掩膜区域并处理:创建与灰度图相同分辨率的黑色图像,在黑色图像上以内缩坐标为顶点绘制模拟光通片,将黑色图像内缩坐标区域内填充为白色;对内缩坐标使用多边形外接矩形算法获得内缩坐标的外接矩形四个顶点,四个顶点围成的外接矩形区域即为黑色图像掩膜区域,遍历黑色图像掩膜区域内的像素,若黑色图像掩膜区域的黑色像素和与总像素和的比值小于第五设定值,则判断该黑色图像掩膜区域为合格;对与黑色图像掩膜区域坐标相同的灰度图掩膜区域通过使用经计算的积分图和平方积分图,计算出所有位置的像素和、平方像素和、像素均值和像素方差,在一次计算中获取多个像素的信息,并使用累积的像素值进行计算,完成积分二值化得到掩膜积分二值图;对掩膜积分二值图使用连通域算法获取各连通域面积,连通域面积小于第一设定面积的为极小连通域并对极小连通域去除,即去除杂质;将掩膜积分二值图中除内缩坐标区域以外的像素置0,即去除干扰因素;使用Sobel算子获取掩膜积分二值图的总梯度并生成掩膜梯度图,使掩膜积分二值图仅显示像素强度变化率;对掩膜梯度图使用参数阈值法进行二值化,将掩膜梯度图分为前景和背景,即获得掩膜参数轮廓图;使用自适应阈值法对掩膜参数轮廓图进行二值化,将掩膜参数轮廓图分为边缘区域和非边缘区域,获取掩膜边缘轮廓图;对掩膜边缘轮廓图再一次使用Sobel算子计算总梯度并通过参数阈值法进行二值化获取掩膜边缘图;Obtain the mask area and process it: create a black image with the same resolution as the grayscale image, draw a simulated light pass film on the black image with the indented coordinates as vertices, and fill the indented coordinate area of the black image with white; use the polygonal circumscribed rectangle algorithm for the indented coordinates to obtain the four vertices of the circumscribed rectangle of the indented coordinates, and the circumscribed rectangular area surrounded by the four vertices is the black image mask area, traverse the pixels in the black image mask area, and if the ratio of the sum of black pixels in the black image mask area to the total sum of pixels is less than the fifth set value, the black image mask area is judged to be qualified; for the grayscale image mask area with the same coordinates as the black image mask area, use the calculated integral map and square integral map to calculate the pixel sum, square pixel sum, pixel mean and pixel variance of all positions, obtain information of multiple pixels in one calculation, and use the accumulated pixel values for calculation to complete the integral binarization to obtain Mask integral binary image; using a connected domain algorithm to obtain the area of each connected domain on the mask integral binary image, and the connected domain area smaller than the first set area is a minimal connected domain and the minimal connected domain is removed, that is, impurities are removed; setting the pixels in the mask integral binary image except the indented coordinate area to 0, that is, removing interference factors; using the Sobel operator to obtain the total gradient of the mask integral binary image and generate a mask gradient image, so that the mask integral binary image only displays the pixel intensity change rate; using the parameter threshold method to binarize the mask gradient image, the mask gradient image is divided into the foreground and the background, that is, the mask parameter contour image is obtained; using the adaptive threshold method to binarize the mask parameter contour image, the mask parameter contour image is divided into the edge area and the non-edge area, and the mask edge contour image is obtained; using the Sobel operator to calculate the total gradient of the mask edge contour image again and binarize it by the parameter threshold method to obtain the mask edge image;

获取缺陷信息并标记:对掩膜边缘图使用连通域算法获取掩膜边缘图内部连通域信息,若连通域信息超出对应的设定参数,则判断掩膜边缘图存在缺陷,并记录存在缺陷的掩膜边缘图坐标,即缺陷坐标,根据缺陷坐标在原始图中标记。Obtain defect information and mark it: Use the connected domain algorithm to obtain the internal connected domain information of the mask edge map. If the connected domain information exceeds the corresponding set parameters, it is determined that there is a defect in the mask edge map, and the coordinates of the defective mask edge map, that is, the defect coordinates, are recorded, and marked in the original map according to the defect coordinates.

优选的,步骤二还包括以下步骤:Preferably, step 2 further comprises the following steps:

根据逼近算法对连通域的边缘进行多边形逼近获取连通域轮廓,并去除连通域轮廓中除凸四边形轮廓外的连通域轮廓,计算包围凸四边形轮廓的四个顶点坐标,即获得凸四边形的四个轮廓顶点坐标;According to the approximation algorithm, polygonal approximation is performed on the edge of the connected domain to obtain the connected domain contour, and the connected domain contour except the convex quadrilateral contour is removed from the connected domain contour, and the coordinates of the four vertices surrounding the convex quadrilateral contour are calculated, that is, the coordinates of the four contour vertices of the convex quadrilateral are obtained;

根据凸四边形轮廓顶点坐标互相计算夹角余弦值,通过计算相邻三个点形成的两个向量之间的夹角余弦值并选择最大值来判断凸四边形的形状是否接近矩形,具体如下式:The cosine values of the angles between the vertices of the convex quadrilateral outline are calculated, and the cosine values of the angles between the two vectors formed by three adjacent points are calculated and the maximum value is selected to determine whether the shape of the convex quadrilateral is close to a rectangle. The specific formula is as follows:

式中为凸四边形第i个顶点坐标,为凸四边形第i个顶点的x坐标,为凸四边形第i个顶点的y坐标;为凸四边形第i+1个顶点坐标,为凸四边形第i+1个顶点的x坐标,为凸四边形第i+1个顶点的y坐标;,为凸四边形第i+2个顶点坐标,为凸四边形第i+2个顶点的x坐标,为凸四边形第i+2个顶点的y坐标;向量为点指向点的向量,向量为点指向点的向量,为向量和向量两向量的夹角,为计算得到的最大余弦值,点与点为同一个点;In the formula is the coordinate of the ith vertex of the convex quadrilateral, is the x- coordinate of the ith vertex of the convex quadrilateral, is the y coordinate of the i- th vertex of the convex quadrilateral; are the coordinates of the i +1th vertex of the convex quadrilateral, is the x- coordinate of the i +1th vertex of the convex quadrilateral, is the y coordinate of the i +1th vertex of the convex quadrilateral; , are the coordinates of the i +2th vertex of the convex quadrilateral, is the x- coordinate of the i +2th vertex of the convex quadrilateral, is the y coordinate of the i +2th vertex of the convex quadrilateral; vector For point Pointing Point vector, vector For point Pointing Point The vector of For vector and vector The angle between two vectors, is the maximum cosine value calculated, point With point for the same point;

的值小于第二设定值,则认为该凸四边形的形状接近矩形,该凸四边形轮廓是光通片轮廓,符合要求。like If the value of is less than the second set value, it is considered that the shape of the convex quadrilateral is close to a rectangle, and the contour of the convex quadrilateral is the contour of the light pass sheet, which meets the requirements.

优选的,根据轮廓顶点坐标计算轮廓倾斜角度,具体如下式:Preferably, the contour inclination angle is calculated according to the contour vertex coordinates, specifically as follows:

式中,为轮廓倾斜角度,为轮廓数量,为第i个轮廓第1个点的坐标,为第i个轮廓第1个点的x坐标,为第i个轮廓第1个点的y坐标;为第i个轮廓第2个点的坐标,为第i个轮廓第2个点的x坐标,为第i个轮廓第2个点的y坐标;In the formula, is the profile inclination angle, is the number of contours, is the coordinate of the first point of the i -th contour, is the x- coordinate of the first point of the i -th contour, is the y coordinate of the first point of the i -th contour; is the coordinate of the second point of the i -th contour, is the x- coordinate of the second point of the i - th contour, is the y coordinate of the second point of the i - th contour;

根据轮廓顶点坐标通过欧几里德距离公式计算轮廓宽度和轮廓高度,如下式:The contour width and height are calculated according to the contour vertex coordinates using the Euclidean distance formula, as shown below:

式中,为轮廓宽度,为轮廓高度,为轮廓数量,为第i个光通片轮廓第1个点的坐标,为第i个轮廓第1个点的x坐标,为第i个轮廓第1个点的y坐标;为第i个光通片轮廓第2个点的坐标,为第i个轮廓第2个点的x坐标,为第i个轮廓第2个点的y坐标;为第i个光通片轮廓第3个点的坐标,为第i个轮廓第3个点的x坐标,为第i个轮廓第3个点的y坐标。In the formula, is the outline width, is the profile height, is the number of contours, is the coordinate of the first point of the i -th light channel contour, is the x- coordinate of the first point of the i -th contour, is the y coordinate of the first point of the i -th contour; is the coordinate of the second point of the i - th light channel contour, is the x- coordinate of the second point of the i - th contour, is the y coordinate of the second point of the i - th contour; is the coordinate of the third point of the i - th light channel contour, is the x- coordinate of the third point of the i - th contour, is the y coordinate of the third point of the i - th contour.

优选的,步骤二中获取四个轮廓顶点坐标包括以下步骤:Preferably, obtaining the coordinates of four contour vertices in step 2 includes the following steps:

使用检测到的凸四边形轮廓顶点的相邻三个点计算夹角余弦值,通过凸四边形轮廓三或四个角最大余弦值与第二设定值相比,若凸四边形轮廓最大余弦值小于第二设定值判断该凸四边形的形状接近矩形;通过使用各凸四边形轮廓的左上角顶点和右上角顶点两点的反三角函数计算出各凸四边形轮廓的倾斜角度,计算出所有凸四边形轮廓的倾斜角度之和后计算平均值。The cosine value of the angle is calculated using three adjacent points of the detected vertices of the convex quadrilateral outline, and the maximum cosine value of the three or four corners of the convex quadrilateral outline is compared with the second set value. If the maximum cosine value of the convex quadrilateral outline is less than the second set value, it is judged that the shape of the convex quadrilateral is close to a rectangle; the inclination angle of each convex quadrilateral outline is calculated by using the inverse trigonometric function of the upper left corner vertex and the upper right corner vertex of each convex quadrilateral outline, the sum of the inclination angles of all convex quadrilateral outlines is calculated, and then the average value is calculated.

优选的,步骤三中所述将Blob检测获得的光通片补充到轮廓检测获得的光通片中,具体为:以Blob中心坐标为矩形中心,以轮廓倾斜角度为矩形倾斜角度、以轮廓宽度为矩形宽度、以轮廓高度为矩形高度绘制Blob矩形,得到Blob矩形顶点坐标;Preferably, in step 3, the light flux sheet obtained by Blob detection is added to the light flux sheet obtained by contour detection, specifically: the center coordinates of the Blob are used as the center of the rectangle, and the contour inclination angle is used as the center of the rectangle. The tilt angle of the rectangle and the width of the outline is the rectangle width, and the outline height Draw a Blob rectangle for the rectangle height and get the coordinates of the Blob rectangle vertices;

将Blob矩形顶点坐标进行顺时针排序,将排序后的Blob矩形顶点坐标补充到轮廓顶点坐标点中,获得补充坐标;Sort the Blob rectangle vertex coordinates clockwise, and add the sorted Blob rectangle vertex coordinates to the contour vertex coordinate points to obtain the supplementary coordinates;

将灰度图边缘内的补充坐标进行内缩获取内缩坐标,具体如下式:The supplementary coordinates within the edge of the grayscale image are indented to obtain the indented coordinates, as shown in the following formula:

其中in

式中为补充坐标,为内缩坐标,L为内缩距离,为某一补充坐标与相邻的两个补充坐标组成的向量,向量的模,向量的模,为补充坐标的两条边的夹角,表示向量x方向的分量,表示向量y方向的分量,表示向量x方向的分量、表示向量y方向的分量。In the formula are supplementary coordinates, is the indentation coordinate, L is the indentation distance, , is a vector consisting of a supplementary coordinate and two adjacent supplementary coordinates. for The modulus of a vector, for The magnitude of a vector, is the angle between the two sides of the supplementary coordinates, Representation vector The component in the x direction, Representation vector The component in the y direction, Representation vector The component in the x direction, Representation vector Component in the y direction.

优选的,对黑色图像内缩坐标使用多边形外接矩形算法获得内缩坐标的外接矩形四个顶点,如下式:Preferably, the polygonal circumscribed rectangle algorithm is used to obtain the four vertices of the circumscribed rectangle of the indented coordinates of the black image, as shown in the following formula:

式中left为外接矩形左边界,right为外接矩形右边界,top为外接矩形上边界bottom为外接矩形下边界,为内缩坐标区域里所有坐标中最小的x坐标值,为内缩坐标区域里所有坐标中最小的y坐标值,为内缩坐标区域里所有坐标中最大的x坐标值,为内缩坐标区域里所有坐标中最大的y坐标值;Where left is the left boundary of the bounding rectangle, right is the right boundary of the bounding rectangle, top is the upper boundary of the bounding rectangle, and bottom is the lower boundary of the bounding rectangle. is the minimum x- coordinate value of all coordinates in the indented coordinate area. is the minimum y coordinate value of all coordinates in the indented coordinate area. is the maximum x- coordinate value of all coordinates in the indented coordinate area. The maximum y coordinate value among all coordinates in the indented coordinate area;

所述黑色图像掩膜区域为无倾斜角度黑色图像掩膜区域,遍历黑色图像掩膜区域内的像素,累计遍历到的黑色像素,获取黑色图像掩膜区域内的黑色像素和与总像素和的比值,若比值小于第五设定值时,则判断该掩膜区域合格;The black image mask area is a black image mask area without an inclination angle, pixels in the black image mask area are traversed, the traversed black pixels are accumulated, and a ratio of the sum of black pixels in the black image mask area to the sum of total pixels is obtained. If the ratio is less than a fifth set value, the mask area is judged to be qualified;

灰度图掩膜区域图像处理采用积分阈值算法,对灰度图掩膜区域进行高斯模糊处理,设定高斯模糊标准差值sigma,使用边界延展算法复制灰度图掩膜区域边界;The grayscale image mask area image processing uses an integral threshold algorithm to perform Gaussian blur processing on the grayscale image mask area, sets the Gaussian blur standard deviation value sigma, and uses the boundary extension algorithm to copy the grayscale image mask area boundary;

计算积分图内积分核的像素和:使用反边界模式拓展灰度图掩膜区域边界,sum表示边界拓展后图像的积分区域,sqsum表示边界拓展后图像的积分平方区域,获取积分区域的四个顶点与背景图坐标原点所围成区域内的像素的累加和,如下式:Calculate the pixel sum of the integral kernel in the integral image: Use the anti-boundary mode to expand the grayscale mask area boundary. sum represents the integral area of the image after boundary expansion. sqsum represents the integral square area of the image after boundary expansion. Get the cumulative sum of the pixels in the area enclosed by the four vertices of the integral area and the origin of the background image coordinates, as shown in the following formula:

式中,都表示积分区域左上角坐标与坐标原点围成的区域内的像素总和、都表示积分区域右上角坐标与坐标原点围成的区域内的像素总和、都表示积分区域左下角坐标与坐标原点围成的区域内的像素总和、都表示积分区域右下角坐标与坐标原点围成的区域内的像素总和,i为积分区域的X方向上前i个像素的和,j为积分区域的Y方向上前j个像素的和,ker为积分核大小,为像素和;In the formula, and Both represent the sum of the pixels in the area enclosed by the coordinates of the upper left corner of the integral area and the origin of the coordinates. and Both represent the sum of the pixels in the area enclosed by the coordinates of the upper right corner of the integral area and the origin of the coordinates. and Both represent the sum of the pixels in the area enclosed by the coordinates of the lower left corner of the integration area and the coordinate origin. and All represent the sum of pixels in the area enclosed by the coordinates of the lower right corner of the integration area and the coordinate origin, i is the sum of the first i pixels in the X direction of the integration area, j is the sum of the first j pixels in the Y direction of the integration area, ker is the size of the integration kernel, is the pixel sum;

同理计算积分平方区域的四个顶点与背景图坐标原点所围成区域内的像素累加和,如下式:Similarly, calculate the cumulative sum of pixels in the area enclosed by the four vertices of the integral square area and the origin of the background coordinate system, as follows:

式中,都表示积分平方区域的左上角坐标与坐标原点围成的区域内的像素总和、都表示积分平方区域的右上角坐标与坐标原点围成的区域内的像素总和、都表示积分平方区域的左下角坐标与坐标原点围成的区域内的像素总和、都表示积分平方区域的右下角坐标与坐标原点围成的区域内的像素总和,i为积分平方区域的X方向上前i个像素的和,j为积分平方区域的Y方向上前j个像素的和,ker为积分核大小,为平方像素和;In the formula, and Both represent the sum of the pixels in the area enclosed by the coordinates of the upper left corner of the integral square area and the coordinate origin. and Both represent the sum of the pixels in the area enclosed by the coordinates of the upper right corner of the integral square area and the origin of the coordinate system. and Both represent the sum of the pixels in the area enclosed by the coordinates of the lower left corner of the integral square area and the origin of the coordinate system. and All represent the sum of pixels in the area enclosed by the coordinates of the lower right corner of the integral square area and the coordinate origin, i is the sum of the first i pixels in the X direction of the integral square area, j is the sum of the first j pixels in the Y direction of the integral square area, ker is the integral kernel size, is the sum of square pixels;

通过积分区域内像素和获取像素均值,如下式:By integrating the pixels in the area and obtaining the pixel mean , as follows:

并获取像素方差var,如下式:And get the pixel variance var as follows:

计算积分二值化阈值th,如下式:Calculate the integral binarization threshold th as follows:

通过积分二值化阈值将灰度图掩膜区域逐像素进行二值化处理,获取掩膜积分二值图,如下式:The grayscale image mask area is binarized pixel by pixel through the integral binarization threshold to obtain the mask integral binary image, as shown in the following formula:

其中,为灰度图掩膜区域中坐标点的像素值,为对应像素值计算的积分二值化阈值,为二值化后的像素值;in, is the grayscale mask area The pixel value of the coordinate point, is the integral binarization threshold calculated for the corresponding pixel value, is the pixel value after binarization;

所述将连通域面积小于第一设定面积的极小连通域进行去除为将面积小于第一设定面积的极小连通域中的像素置为0。The removing of the extremely small connected domain whose area is smaller than the first set area is to set the pixels in the extremely small connected domain whose area is smaller than the first set area to 0.

优选的,所述黑色图像的分辨率与灰度图的分辨率相同,即灰度图掩膜区域与黑色图像掩膜区域坐标相同,对与所述无倾斜角度黑色图像掩膜区域坐标相同的无倾斜角度灰度图掩膜区域进行积分二值化阈值计算,计算像素方差时,取像素方差大于0的值,若像素方差小于0,则像素方差取0,二值化时使用计算得到的积分二值化阈值逐像素对灰度图掩膜区域进行二值化处理。Preferably, the resolution of the black image is the same as that of the grayscale image, that is, the coordinates of the grayscale image mask area and the black image mask area are the same, and an integral binarization threshold calculation is performed on the grayscale image mask area with no tilt angle having the same coordinates as the black image mask area with no tilt angle. When calculating the pixel variance, a value greater than 0 is taken. If the pixel variance is less than 0, the pixel variance is taken as 0. During binarization, the calculated integral binarization threshold is used to binarize the grayscale image mask area pixel by pixel.

优选的,对掩膜边缘图进行缺陷检测,随后在原始图中对缺陷进行标记包括以下步骤:Preferably, performing defect detection on the mask edge image and then marking the defects in the original image comprises the following steps:

5.1、对掩膜边缘图使用连通域算法获取掩膜边缘图内部连通域信息,所述掩膜边缘图内部连通域信息包括掩膜边缘图内部连通域面积、连通域数量、宽度和高度;5.1. Using a connected domain algorithm to obtain the connected domain information inside the mask edge map, the connected domain information inside the mask edge map includes the area, number, width and height of the connected domain inside the mask edge map;

5.2、点伤缺陷检测,根据掩膜边缘图检测获得的连通域面积与第六设定直径计算出的面积对比,当连通域面积大于第六设定直径计算出的面积时,则认为该掩膜边缘图存在点伤缺陷;5.2. Point defect detection: compare the area of the connected domain obtained by the mask edge map detection with the area calculated by the sixth set diameter. When the area of the connected domain is larger than the area calculated by the sixth set diameter, it is considered that there is a point defect in the mask edge map;

5.3、麻点缺陷检测,根据掩膜边缘图检测到的连通域数量与设定的数量对比,若连通域数量大于第七设定数量麻点则认为该掩膜边缘图存在麻点缺陷;5.3. Pockmark defect detection: compare the number of connected domains detected by the mask edge map with the set number. If the number of connected domains is greater than the seventh set number of pockmarks, it is considered that the mask edge map has a pockmark defect;

5.4、细长缺陷检测,第一步:根据掩膜边缘图连通域宽度与高度的比值是否大于第八设定值或小于第九设定值,其中,第八设定值大于第九设定值,若掩膜边缘图连通域宽度与高度的比值大于第八设定值或小于第九设定值则为细长连通域,第二步:根据连通域最大边缘值与第十设定值对比,当连通域最大边缘值大于第十设定值时,则认为该掩膜边缘图存在细长缺陷;连通域的宽度和高度相比,较大值即为所述连通域最大边缘值;5.4. Slender defect detection, step 1: whether the ratio of the width to the height of the connected domain of the mask edge map is greater than the eighth set value or less than the ninth set value, wherein the eighth set value is greater than the ninth set value, if the ratio of the width to the height of the connected domain of the mask edge map is greater than the eighth set value or less than the ninth set value, it is a slender connected domain, step 2: according to the comparison between the maximum edge value of the connected domain and the tenth set value, when the maximum edge value of the connected domain is greater than the tenth set value, it is considered that the mask edge map has a slender defect; the larger value of the width and height of the connected domain is the maximum edge value of the connected domain;

5.5、检测后储存所有判定为缺陷的掩膜边缘图的中心坐标,并对原始图中对应的坐标点进行打点标记。5.5. After detection, store the center coordinates of all mask edge images that are judged to be defects, and mark the corresponding coordinate points in the original image.

优选的,定义高斯模糊的内核为1、3、5或7,高斯模糊标准差值为0.5-15,更优选的,定义高斯模糊的内核为3,高斯模糊标准差值为15。Preferably, the kernel for defining Gaussian blur is 1, 3, 5 or 7, and the standard deviation value of Gaussian blur is 0.5-15. More preferably, the kernel for defining Gaussian blur is 3, and the standard deviation value of Gaussian blur is 15.

本发明相对于现有技术具有如下的优点及效果:Compared with the prior art, the present invention has the following advantages and effects:

1、本发明使用计算夹角余弦值筛选凸四边形轮廓顶点坐标,防止出现误检;使用Blob中心坐标与轮廓中心坐标对比,并将Blob中心坐标与轮廓信息结合,补充轮廓顶点坐标,防止出现漏检,获取的坐标更加准确。1. The present invention uses the calculated angle cosine value to screen the vertex coordinates of the convex quadrilateral contour to prevent false detection; uses the Blob center coordinates to compare with the contour center coordinates, and combines the Blob center coordinates with the contour information to supplement the contour vertex coordinates to prevent missed detection, and the acquired coordinates are more accurate.

2、本发明使用多边形内缩算法获取内缩坐标,去除光通片毛边对缺陷检测的影响。2. The present invention uses a polygon shrinking algorithm to obtain shrinking coordinates and remove the influence of the burrs of the optical pass sheet on defect detection.

3、本发明使用多边形外接矩形算法获取内缩坐标的外接矩形即掩膜区域,后续仅对掩膜区域进行处理,减少积分阈值算法的计算范围,提高检测效率。3. The present invention uses a polygon circumscribed rectangle algorithm to obtain the circumscribed rectangle of the indented coordinates, namely the mask area, and subsequently only processes the mask area, thereby reducing the calculation range of the integral threshold algorithm and improving the detection efficiency.

4、本发明将带有倾斜角度的内缩坐标通过多边形外接矩形算法,拓展为无倾斜角度的掩膜区域,可以更加简单的对无倾斜角度的灰度图掩膜区域进行积分阈值计算,加快计算速度。4. The present invention expands the inward coordinates with tilt angles into a mask area without tilt angles through a polygon circumscribed rectangle algorithm, which can more simply perform integral threshold calculation on the grayscale mask area without tilt angles, thereby accelerating the calculation speed.

5、本发明灰度图掩膜区域积分阈值二值化处理模块使用积分图和平方积分图,预先计算灰度图掩膜区域图像,加速了局部统计信息的计算,提高性能,避免重复计算,修正方差,避免数值不稳定性,增强准确性。5. The grayscale image mask area integral threshold binarization processing module of the present invention uses an integral image and a square integral image to pre-calculate the grayscale image mask area image, which accelerates the calculation of local statistical information, improves performance, avoids repeated calculations, corrects variance, avoids numerical instability, and enhances accuracy.

6、本发明对掩膜积分二值图的内缩坐标区域以外的像素置0,排除灰度图的内缩坐标区域以外因素对图像处理的影响,判断图像缺陷时更加准确。6. The present invention sets pixels outside the indented coordinate region of the mask integral binary image to 0, thereby eliminating the influence of factors outside the indented coordinate region of the grayscale image on image processing, and making image defects more accurately judged.

7、本发明在缺陷判断时,使用缺陷面积、缺陷数量、缺陷宽高比多种因素共同判断,可以更准确的判断多种缺陷。7. When judging defects, the present invention uses multiple factors such as defect area, defect quantity, and defect aspect ratio to make a joint judgment, which can more accurately judge multiple defects.

附图说明BRIEF DESCRIPTION OF THE DRAWINGS

图1为本发明的光通片缺陷检测方法的流程示意图;FIG1 is a schematic flow chart of a method for detecting defects in a light-transmitting sheet according to the present invention;

图2为本发明进行检测的原始图;Fig. 2 is the original image detected by the present invention;

图3为本发明使用Sobel算子计算的灰度图的总梯度图;FIG3 is a total gradient diagram of a grayscale image calculated using a Sobel operator according to the present invention;

图4为本发明轮廓检测获得的轮廓顶点图;FIG4 is a contour vertex graph obtained by contour detection of the present invention;

图5为本发明Blob检测获得的Blob中心坐标图;FIG5 is a Blob center coordinate diagram obtained by Blob detection according to the present invention;

图6为本发明对比补充的Blob矩形顶点坐标图;FIG6 is a Blob rectangle vertex coordinate diagram for comparison and supplementation of the present invention;

图7为本发明获得的补充坐标图;FIG7 is a supplementary coordinate diagram obtained by the present invention;

图8为本发明补充坐标与内缩坐标的示意图;FIG8 is a schematic diagram of supplementary coordinates and indented coordinates of the present invention;

图9为本发明通过多边形外接矩形算法获取的黑色图像掩膜区域图;FIG9 is a diagram of a black image mask region obtained by a polygon circumscribed rectangle algorithm of the present invention;

图10为本发明获取的灰度图掩膜区域图;FIG10 is a grayscale image mask region diagram obtained by the present invention;

图11为本发明获取掩膜边缘图的过程图;FIG11 is a process diagram of obtaining a mask edge image according to the present invention;

图12为本发明清除连通域原理图;FIG12 is a schematic diagram showing the principle of clearing a connected domain according to the present invention;

图13为本发明计算夹角余弦值原理图;FIG13 is a schematic diagram showing the principle of calculating the cosine value of an angle according to the present invention;

图14为本发明轮廓顶点坐标重新排序原理图;FIG14 is a schematic diagram showing the principle of reordering contour vertex coordinates according to the present invention;

图15为本发明轮廓顶点坐标计算轮廓信息图;FIG15 is a contour information diagram of contour vertex coordinate calculation according to the present invention;

图16为本发明计算内缩坐标原理图;FIG16 is a schematic diagram showing the principle of calculating the indentation coordinates of the present invention;

图17为本发明计算外接矩形原理图;FIG17 is a schematic diagram showing the principle of calculating a circumscribed rectangle according to the present invention;

图18为本发明计算积分核内像素和的原理图。FIG. 18 is a schematic diagram showing the principle of calculating the sum of pixels within an integral kernel according to the present invention.

具体实施方式DETAILED DESCRIPTION

下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

本发明是针对现在少有光通片弱特征检测技术且现有技术中存在的光通片弱特征缺陷检测精度不高的问题,提供一种光通片缺陷检测方法,可以有效识别光通片表面微小缺陷(如轻微划伤、点伤、麻点等),代替人工检测提高检测效率,在生产线上快速执行,并提供高度准确的检测结果。The present invention aims to solve the problem that there are few weak feature detection technologies for optical wafers and the detection accuracy of weak feature defects of optical wafers in the prior art is not high. The present invention provides a method for detecting defects of optical wafers, which can effectively identify tiny defects on the surface of optical wafers (such as slight scratches, punctures, pitting, etc.), replace manual detection to improve detection efficiency, be quickly executed on the production line, and provide highly accurate detection results.

一种光通片缺陷检测方法,包括以下步骤:A method for detecting defects in a light-transmitting sheet comprises the following steps:

步骤一:通过图像采集装置获取带有多个光通片的原始图,将原始图复制为灰度图;Step 1: Obtain an original image with multiple optical pass sheets through an image acquisition device, and copy the original image into a grayscale image;

步骤二:对灰度图进行预处理,通过轮廓检测和夹角余弦值筛选,获取轮廓顶点坐标,并计算轮廓中心坐标、轮廓宽度、轮廓高度、轮廓倾斜角度;Step 2: Preprocess the grayscale image, obtain the coordinates of the contour vertices through contour detection and angle cosine value screening, and calculate the contour center coordinates, contour width, contour height, and contour inclination angle;

步骤三:使用Blob检测获取灰度图中Blob中心坐标,通过Blob中心坐标与轮廓中心坐标对比,将Blob中心坐标与轮廓信息结合,补充轮廓顶点坐标,获得补充坐标,并对补充坐标使用内缩算法获得内缩坐标;Step 3: Use Blob detection to obtain the center coordinates of the Blob in the grayscale image, compare the center coordinates of the Blob with the center coordinates of the contour, combine the center coordinates of the Blob with the contour information, supplement the coordinates of the contour vertices, obtain the supplementary coordinates, and use the indentation algorithm on the supplementary coordinates to obtain the indentation coordinates;

步骤四:创建与灰度图分辨率一致的黑色图像,对黑色图像的内缩坐标使用多边形外接矩形算法获取内缩坐标的外接矩形区域即黑色图像掩膜区域,对与黑色图像掩膜区域坐标相同的灰度图掩膜区域进行积分二值化及预处理,生成掩膜边缘图;Step 4: Create a black image with the same resolution as the grayscale image, use the polygonal circumscribed rectangle algorithm for the indented coordinates of the black image to obtain the circumscribed rectangular area of the indented coordinates, i.e., the black image mask area, perform integral binarization and preprocessing on the grayscale image mask area with the same coordinates as the black image mask area, and generate a mask edge map;

步骤五:对掩膜边缘图进行缺陷检测获取缺陷信息,随后在原始图中进行缺陷标记。Step 5: Perform defect detection on the mask edge image to obtain defect information, and then mark the defects in the original image.

具体的,获取原始图:通过带有高清相机的图像采集装置获取带有多个光通片的原始图,将原始图复制为灰度图;Specifically, obtaining the original image: obtaining the original image with multiple optical pass sheets through an image acquisition device with a high-definition camera, and copying the original image into a grayscale image;

获取轮廓信息:对灰度图使用高斯模糊处理,降低灰度图噪声使灰度图变得平滑,为提取特征做准备;使用Sobel算子计算灰度图的总梯度并生成灰度图的总梯度图,使灰度图仅显示像素强度变化率,进而对灰度图的总梯度图使用参数阈值法(OpenCV中自带的算法)进行二值化,将灰度图的总梯度图分为前景和背景,即获得参数轮廓图;再使用OpenCV自适应阈值法对参数轮廓图进行二值化,将参数轮廓图分为边缘区域和非边缘区域,使参数轮廓图中的轮廓变为单像素显示,即获取边缘轮廓图;计算边缘轮廓图中检测到的连通域面积并对比第一设定面积,删除边缘轮廓图中面积小于第一设定面积的区域,具体为将面积小于第一设定面积的区域内的像素均置为黑色;使用Sobel算子计算边缘轮廓图的总梯度并通过参数阈值法进行二值化获取参数边缘轮廓图(即:灰度图预处理);使用边缘查找算法(Opencv自带的算法)获取参数边缘轮廓图中的连通区域的边缘,对连通区域的边缘进行多边形逼近,获取连通区域轮廓(即:轮廓检测获取凸四边形轮廓顶点坐标);去除连通区域轮廓中除凸四边形轮廓以外的连通区域轮廓,通过凸四边形轮廓顶点坐标互相计算夹角余弦值,选取凸四边形轮廓顶点坐标形成的夹角余弦值的最大值判断凸四边形的形状是否接近矩形,具体的,选取凸四边形轮廓顶点坐标形成的夹角余弦值的最大值与第二设定值比较,若小于第二设定值判断凸四边形的形状接近矩形,筛选出形状接近矩形的凸四边形轮廓,并使用外接倾斜矩形算法(外接倾斜矩形算法为Opencv自带的算法)计算凸四边形轮廓的外接倾斜矩形,即,夹角余弦值筛选获取轮廓顶点坐标;通过轮廓顶点坐标计算轮廓中心坐标,将轮廓顶点坐标相对于轮廓中心坐标对比,按照顺时针重新排列;根据轮廓顶点坐标排序的前两个点与X坐标轴的夹角进行反三角函数计算获得轮廓倾斜角度,并计算轮廓宽度和轮廓高度(即:获取轮廓中心坐标、轮廓宽度、轮廓高度和轮廓倾斜角度);Get contour information: Use Gaussian blur processing on the grayscale image to reduce the noise of the grayscale image and make it smooth in preparation for feature extraction; use the Sobel operator to calculate the total gradient of the grayscale image and generate the total gradient map of the grayscale image, so that the grayscale image only displays the pixel intensity change rate, and then use the parameter threshold method (the algorithm provided in OpenCV) to binarize the total gradient map of the grayscale image, and divide the total gradient map of the grayscale image into foreground and background, that is, obtain the parameter contour map; then use the OpenCV adaptive threshold method to binarize the parameter contour map, and divide the parameter contour map into edge area and non-edge area. The contour in the parameter contour map is changed to a single pixel display, that is, the edge contour map is obtained; the area of the connected domain detected in the edge contour map is calculated and compared with the first set area, and the area in the edge contour map with an area smaller than the first set area is deleted, specifically, all pixels in the area smaller than the first set area are set to black; the total gradient of the edge contour map is calculated using the Sobel operator and binarized using the parameter threshold method to obtain the parameter edge contour map (i.e.: grayscale image preprocessing); the edge search algorithm (the algorithm provided by Opencv) is used to obtain the edge of the connected area in the parameter edge contour map, and the connected area is The edge of the domain is polygonally approximated to obtain the contour of the connected area (that is, contour detection obtains the coordinates of the vertices of the convex quadrilateral contour); the contours of the connected area other than the convex quadrilateral contour are removed from the contour of the connected area, the cosine values of the angles are calculated by the vertex coordinates of the convex quadrilateral contour, and the maximum value of the cosine value of the angle formed by the vertex coordinates of the convex quadrilateral contour is selected to determine whether the shape of the convex quadrilateral is close to a rectangle. Specifically, the maximum value of the cosine value of the angle formed by the vertex coordinates of the convex quadrilateral contour is selected and compared with a second set value. If it is less than the second set value, it is determined that the shape of the convex quadrilateral is close to a rectangle, and the convex quadrilaterals with a shape close to a rectangle are screened out. The convex quadrilateral contour is obtained by using the circumscribed tilted rectangle algorithm (the circumscribed tilted rectangle algorithm is an algorithm built into Opencv), that is, the circumscribed tilted rectangle of the convex quadrilateral contour is calculated, that is, the cosine value of the angle is filtered to obtain the contour vertex coordinates; the contour center coordinates are calculated by the contour vertex coordinates, the contour vertex coordinates are compared with the contour center coordinates, and rearranged in a clockwise direction; the contour tilt angle is obtained by performing inverse trigonometric calculations based on the angle between the first two points of the contour vertex coordinates and the X-coordinate axis, and the contour width and contour height are calculated (that is, the contour center coordinates, contour width, contour height, and contour tilt angle are obtained);

获取Blob中心坐标并补充轮廓顶点坐标:Blob检测器对检测样式进行设定(即:设定Blob检测器),使Blob检测器仅检测四边形样式斑块;Blob检测器对检测面积进行设定,使Blob检测器筛除在第三设定面积范围外的斑块;使用配置完成的Blob检测器直接检测灰度图,获得Blob中心坐标;通过欧几里得距离公式计算Blob中心坐标与轮廓中心坐标之间的距离dis,当dis小于或等于第四设定值时,则Blob中心坐标与轮廓中心坐标为同一个光通片的中心点,则无须补充;当dis大于第四设定值时,则认为Blob中心坐标与轮廓中心坐标不一致,此时需要将Blob检测获得的光通片补充到轮廓检测获得的光通片中,获得补充坐标(即:Blob检测中心坐标与轮廓检测中心坐标对比获取补充坐标);为防止图像边缘的光通片被误检,去除超出灰度图边缘的补充坐标;并将在灰度图边缘内的补充坐标进行多边形内缩获取内缩坐标(即:补充坐标内缩获取内缩坐标);Get the Blob center coordinates and supplement the contour vertex coordinates: the Blob detector sets the detection style (i.e., sets the Blob detector) so that the Blob detector only detects quadrilateral style patches; the Blob detector sets the detection area so that the Blob detector screens out patches outside the third set area range; the configured Blob detector is used to directly detect the grayscale image to obtain the Blob center coordinates; the distance dis between the Blob center coordinates and the contour center coordinates is calculated using the Euclidean distance formula. When dis is less than or equal to the fourth set value, the Blob center coordinates If the center point of the light pass sheet is the same as the center coordinate of the contour, no supplement is required; when dis is greater than the fourth set value, it is considered that the center coordinate of the Blob is inconsistent with the center coordinate of the contour. At this time, the light pass sheet obtained by the Blob detection needs to be supplemented to the light pass sheet obtained by the contour detection to obtain supplementary coordinates (i.e., the center coordinates of the Blob detection are compared with the center coordinates of the contour detection to obtain supplementary coordinates); to prevent the light pass sheet at the edge of the image from being misdetected, the supplementary coordinates that exceed the edge of the grayscale image are removed; and the supplementary coordinates within the edge of the grayscale image are polygonally indented to obtain the indented coordinates (i.e., the supplementary coordinates are indented to obtain the indented coordinates);

获取掩膜区域并处理:创建与灰度图相同分辨率的黑色图像,在黑色图像上以内缩坐标为顶点绘制模拟光通片,将黑色图像内缩坐标区域内填充为白色;对内缩坐标使用多边形外接矩形算法获得内缩坐标的外接矩形四个顶点,四个顶点围成的外接矩形区域即为黑色图像掩膜区域(即:根据内缩坐标的外接矩形获取黑色图像的掩膜区域),遍历黑色图像掩膜区域内的像素,获取黑色图像掩膜区域的黑色像素和与总像素和的比值,若黑色像素和与总像素和的比值小于第五设定值,则判断该黑色图像掩膜区域为合格;对与黑色图像掩膜区域坐标相同的灰度图掩膜区域通过使用预先计算的积分图和平方积分图,计算出任意位置的像素和、平方像素和、像素均值和像素方差,在一次计算中获取多个像素的信息,并使用累积的像素值进行计算,完成积分二值化得到掩膜积分二值图(即:灰度图掩膜区域积分二值化);对掩膜积分二值图使用连通域算法(Opencv自带的算法)获取各连通域面积,将连通域面积小于第一设定面积的极小特征(即:极小连通域)进行去除,即去除杂质;将掩膜积分二值图中除内缩坐标区域以外的像素置0,即去除干扰因素;使用Sobel算子获取掩膜积分二值图的总梯度并生成掩膜梯度图,使掩膜积分二值图仅显示像素强度变化率;对掩膜梯度图使用参数阈值法进行二值化,将掩膜梯度图分为前景和背景,即获得掩膜参数轮廓图;使用自适应阈值法对掩膜参数轮廓图进行二值化,将掩膜参数轮廓图分为边缘区域和非边缘区域,获取掩膜边缘轮廓图;对掩膜边缘轮廓图再一次使用Sobel算子计算总梯度并通过参数阈值法进行二值化获取掩膜边缘图(即:掩膜积分二值图预处理);Obtain the mask area and process it: create a black image with the same resolution as the grayscale image, draw a simulated light pass film on the black image with the indented coordinates as vertices, and fill the indented coordinate area of the black image with white; use the polygonal circumscribed rectangle algorithm for the indented coordinates to obtain the four vertices of the circumscribed rectangle of the indented coordinates, and the circumscribed rectangular area surrounded by the four vertices is the black image mask area (that is, obtain the mask area of the black image according to the circumscribed rectangle of the indented coordinates), traverse the pixels in the black image mask area, and obtain the ratio of the black pixel sum to the total pixel sum of the black image mask area. If the ratio of the black pixel sum to the total pixel sum is less than the fifth set value, the black image mask area is judged to be qualified; for the grayscale image mask area with the same coordinates as the black image mask area, use the pre-calculated integral map and square integral map to calculate the pixel sum, square pixel sum, pixel mean and pixel variance at any position, obtain information of multiple pixels in one calculation, and use the accumulated pixel values for calculation to complete the integral binarization to obtain the mask. Integral binary image (i.e., grayscale image mask area integral binarization); use the connected domain algorithm (Opencv's own algorithm) to obtain the area of each connected domain on the mask integral binary image, and remove the extremely small features (i.e., extremely small connected domains) whose connected domain area is smaller than the first set area, i.e., remove impurities; set the pixels in the mask integral binary image except the indented coordinate area to 0, i.e., remove interference factors; use the Sobel operator to obtain the total gradient of the mask integral binary image and generate a mask gradient image, so that the mask integral binary image only displays the pixel intensity change rate; use the parameter threshold method to binarize the mask gradient image, divide the mask gradient image into foreground and background, and obtain the mask parameter contour image; use the adaptive threshold method to binarize the mask parameter contour image, divide the mask parameter contour image into edge area and non-edge area, and obtain the mask edge contour image; use the Sobel operator to calculate the total gradient of the mask edge contour image again and binarize it by the parameter threshold method to obtain the mask edge image (i.e., mask integral binary image preprocessing);

获取缺陷信息并标记:对掩膜边缘图使用连通域算法获取掩膜边缘图内部连通域信息,掩膜边缘图内部连通域信息包括掩膜边缘图内部连通域面积、连通域数量、宽度和高度信息,根据连通域面积、连通域数量、连通域宽高比、连通域最大边缘值分别与对应设定参数做比较,若连通域信息超出对应的设定参数则判断掩膜边缘图存在缺陷,并记录存在缺陷的掩膜边缘图坐标,即缺陷坐标,根据缺陷坐标在原始图中标记。Obtain defect information and mark it: Use the connected domain algorithm to obtain the internal connected domain information of the mask edge map. The internal connected domain information of the mask edge map includes the area, number, width and height of the internal connected domain of the mask edge map. The connected domain area, number, aspect ratio and maximum edge value of the connected domain are compared with the corresponding set parameters. If the connected domain information exceeds the corresponding set parameters, it is determined that there is a defect in the mask edge map, and the coordinates of the defective mask edge map, i.e., the defect coordinates, are recorded, and marked in the original map according to the defect coordinates.

具体的:如图1所示,所述的一种光通片缺陷检测方法,包括以下步骤:Specifically: As shown in FIG1 , the optical wafer defect detection method comprises the following steps:

1、获取原始图:1. Get the original image:

通过带有高分辨率相机的图像采集装置获取如图2所示带有多个光通片的原始图,将原始图复制为灰度图;An original image with multiple optical pass sheets as shown in FIG2 is obtained by an image acquisition device with a high-resolution camera, and the original image is copied into a grayscale image;

2、获取轮廓信息:2. Get contour information:

对灰度图使用高斯模糊处理,降低灰度图噪声使灰度图变得平滑更容易提取特征;其中可以定义高斯模糊的内核为3,标准差为15。使用Sobel算子计算灰度图的总梯度,生成如图3所示灰度图的总梯度图,使灰度图仅显示像素强度变化率,对灰度图的总梯度图使用参数阈值法进行二值化,将灰度图的总梯度图分为前景和背景,即获得参数轮廓图;再使用OpenCV自适应阈值法对参数轮廓图进行二值化,将参数轮廓图分为边缘区域和非边缘区域,使参数轮廓图中的轮廓变为单像素显示,获取边缘轮廓图。Gaussian blur is used on the grayscale image to reduce the noise of the grayscale image so that the grayscale image becomes smoother and easier to extract features; the kernel of the Gaussian blur can be defined as 3 and the standard deviation as 15. The total gradient of the grayscale image is calculated using the Sobel operator to generate the total gradient map of the grayscale image as shown in Figure 3, so that the grayscale image only displays the pixel intensity change rate. The total gradient map of the grayscale image is binarized using the parameter threshold method, and the total gradient map of the grayscale image is divided into the foreground and the background, that is, the parameter contour map is obtained; the parameter contour map is then binarized using the OpenCV adaptive threshold method, and the parameter contour map is divided into the edge area and the non-edge area, so that the contour in the parameter contour map becomes a single pixel display, and the edge contour map is obtained.

轮廓检测目的为获取光通片顶点坐标,因此对非光通片连通区域进行清理,减少后续计算量;通过计算边缘轮廓图中检测到的连通域面积对比第一设定面积,删除边缘轮廓图中面积小于第一设定面积的区域,具体方法为将边缘轮廓图中面积小于第一设定面积的区域内的像素均置为黑色(像素值置为0),达到清理杂质的效果;其中,如图12,获取杂质区域可通过连通域算法获取得杂质连通域属性信息,杂质连通域属性信息包括杂质连通域左上角x坐标即初始像素x坐标,杂质连通域左上角y坐标即初始像素y坐标、杂质连通域宽度和杂质连通域高度,可获得杂质连通区域右下角x坐标即结束像素x坐标,杂质连通区域右下角y坐标即结束像素y坐标,其中:The purpose of contour detection is to obtain the coordinates of the vertices of the optical pass sheet, so the non-optical pass sheet connected area is cleaned up to reduce the amount of subsequent calculations; by calculating the area of the connected domain detected in the edge contour map and comparing it with the first set area, the area in the edge contour map that is smaller than the first set area is deleted. The specific method is to set all pixels in the area in the edge contour map that is smaller than the first set area to black (pixel value is set to 0) to achieve the effect of cleaning impurities; as shown in Figure 12, the impurity area can be obtained by the connected domain algorithm to obtain the impurity connected domain attribute information, and the impurity connected domain attribute information includes the x coordinate of the upper left corner of the impurity connected domain, that is, the x coordinate of the initial pixel , the y coordinate of the upper left corner of the impurity connected domain is the y coordinate of the initial pixel , impurity connected domain width and impurity connected domain height , the x coordinate of the lower right corner of the impurity connected area can be obtained, that is, the x coordinate of the end pixel , the y coordinate of the lower right corner of the impurity connected area is the y coordinate of the end pixel ,in:

逐像素将杂质连通域范围内的像素清除,并遍历所有连通域面积小于第一设定面积的连通域,优选的,第一设定面积可以为5、6、7、8或9个像素,但具体可根据实际情况需要而设置,遍历方式如下式:Pixels within the impurity connected domain are cleared pixel by pixel, and all connected domains whose area is smaller than the first set area are traversed. Preferably, the first set area may be 5, 6, 7, 8 or 9 pixels, but may be set according to actual needs. The traversal method is as follows:

式中,矩阵为边缘轮廓图中第i个连通域初始像素,矩阵为边缘轮廓图中第i个连通域对应的宽度与高度,矩阵为边缘轮廓图中第i个连通域结束像素。In the formula, the matrix is the initial pixel of the i-th connected domain in the edge contour map, and the matrix is the width and height corresponding to the i- th connected domain in the edge contour graph, and the matrix It is the end pixel of the i- th connected domain in the edge contour map.

对清理后的适应边缘轮廓图再一次使用Sobel算子计算梯度并通过参数阈值法进行二值化获取参数边缘轮廓图;通过边缘查找算法获取参数边缘轮廓图中的连通域的边缘,根据逼近算法对连通域的边缘进行多边形逼近获取连通域轮廓,并去除连通域轮廓中除凸四边形轮廓外的连通域轮廓,计算包围凸四边形轮廓的顶点坐标,如图13通过计算凸四边形轮廓顶点相邻三个点形成的两个向量之间的夹角余弦值并选择最大值判别获取到的凸四边形轮廓顶点坐标是否符合要求,判断凸四边形的形状是否接近矩形,下式为通过相邻三个点计算余弦值公式:The cleaned adaptive edge contour map is once again calculated using the Sobel operator to calculate the gradient and binarized using the parameter threshold method to obtain the parameter edge contour map; the edge of the connected domain in the parameter edge contour map is obtained using the edge search algorithm, and the edge of the connected domain is polygonally approximated according to the approximation algorithm to obtain the connected domain contour, and the connected domain contour except the convex quadrilateral contour in the connected domain contour is removed, and the vertex coordinates surrounding the convex quadrilateral contour are calculated, as shown in Figure 13. By calculating the cosine value of the angle between the two vectors formed by the three adjacent points of the convex quadrilateral contour vertex and selecting the maximum value, it is determined whether the obtained convex quadrilateral contour vertex coordinates meet the requirements, and whether the shape of the convex quadrilateral is close to a rectangle. The following formula is the formula for calculating the cosine value through three adjacent points:

式中为凸四边形第i个顶点坐标,为凸四边形第i个顶点的x坐标,为凸四边形第i个顶点的y坐标;为凸四边形第i+1个顶点坐标,为凸四边形第i+1个顶点的x坐标,为凸四边形第i+1个顶点的y坐标; , 为凸四边形第i+2个顶点坐标,为凸四边形第i+2个顶点的x坐标,为凸四边形第i+2个顶点的y坐标;向量为点指向点的向量,向量为点指向点的向量,为向量和向量两向量的夹角,为计算得到的最大余弦值,点与点为同一个点;In the formula is the coordinate of the ith vertex of the convex quadrilateral, is the x-coordinate of the ith vertex of the convex quadrilateral, is the y coordinate of the i- th vertex of the convex quadrilateral; are the coordinates of the i +1th vertex of the convex quadrilateral, is the x- coordinate of the i +1th vertex of the convex quadrilateral, is the y coordinate of the i +1th vertex of the convex quadrilateral; , are the coordinates of the i +2th vertex of the convex quadrilateral, is the x- coordinate of the i +2th vertex of the convex quadrilateral, is the y coordinate of the i +2th vertex of the convex quadrilateral; vector For point Pointing Point vector, vector For point Pointing Point The vector of For vector and vector The angle between two vectors, is the maximum cosine value calculated, point With point for the same point;

的值小于第二设定值(第二设定值可以为0.3、0.4或0.5等,具体可根据实现情况选定),则认为该凸四边形接近矩形,该凸四边形轮廓是光通片轮廓,符合要求;筛选出如图4符合要求的凸四边形轮廓顶点坐标。like If the value of is less than the second set value (the second set value may be 0.3, 0.4 or 0.5, etc., which may be selected according to the implementation situation), it is considered that the convex quadrilateral is close to a rectangle, and the contour of the convex quadrilateral is the contour of the light pass sheet, which meets the requirements; the vertex coordinates of the convex quadrilateral contour that meets the requirements are selected as shown in FIG. 4.

使用外接倾斜矩形算法计算凸四边形轮廓的外接倾斜矩形,即轮廓顶点坐标;由于外接倾斜矩形算法得到的轮廓顶点坐标为逆时针排列,为方便后续计算,首先通过轮廓顶点坐标计算轮廓中心坐标,如下式:The circumscribed inclined rectangle algorithm is used to calculate the circumscribed inclined rectangle of the convex quadrilateral contour, that is, the coordinates of the contour vertices. Since the contour vertex coordinates obtained by the circumscribed inclined rectangle algorithm are arranged counterclockwise, in order to facilitate subsequent calculations, the contour center coordinates are first calculated through the contour vertex coordinates, as shown in the following formula:

式中表示第个光通片的轮廓中心坐标,表示第个光通片的第1个轮廓顶点的坐标,为第个光通片的第1个轮廓顶点的x坐标,为第个光通片的第1个轮廓顶点的y坐标,表示第个光通片的第3个轮廓顶点的坐标,为第个光通片的第3个轮廓顶点的x坐标,为第个光通片的第3个轮廓顶点的y坐标。In the formula Indicates The center coordinates of the contour of the light pass film, Indicates The coordinates of the first contour vertex of the light pass sheet, For the The x coordinate of the first contour vertex of the light pass sheet, For the The y coordinate of the first contour vertex of the light pass sheet, Indicates The coordinates of the third contour vertex of the light pass sheet, For the The x coordinate of the third contour vertex of the light pass sheet, For the The y coordinate of the third contour vertex of the light channel.

再根据轮廓顶点坐标相对于轮廓中心坐标的坐标值对比,如图14按照顺时针重新排列,如下式:Then, according to the comparison of the coordinate values of the contour vertex coordinates relative to the contour center coordinates, rearrange them clockwise as shown in Figure 14, as follows:

等式右侧表示第i个轮廓中心坐标,表示第i个轮廓中心的x坐标,表示第i个轮廓中心的y坐标,都表示第i个轮廓原第j个轮廓顶点坐标,表示第i个轮廓原第j个轮廓顶点的x坐标,表示第i个轮廓原第j个轮廓顶点的y坐标;等式左侧表示重新排序后的第1个轮廓顶点坐标,表示重新排序后的第2个轮廓顶点坐标,表示重新排序后的第3个轮廓顶点坐标,表示重新排序后的第4个轮廓顶点坐标。The right side of the equation represents the coordinates of the center of the i - th contour, represents the x- coordinate of the center of the i - th contour, represents the y coordinate of the center of the i - th contour, and All represent the vertex coordinates of the i- th contour and the j -th contour. Represents the x- coordinate of the vertex of the original j- th contour of the i- th contour, Represents the y coordinate of the vertex of the original j-th contour of the i- th contour; the left side of the equation Represents the coordinates of the first contour vertex after reordering. Represents the coordinates of the second contour vertex after reordering. Represents the coordinates of the third contour vertex after reordering. Represents the coordinates of the 4th contour vertex after reordering.

如图15根据光通片轮廓顶点坐标计算倾斜角度,通过累加所有轮廓顶点坐标计算得到的倾斜角度求平均值得到轮廓倾斜角度theta,下式为计算轮廓倾斜角度公式:As shown in Figure 15, the inclination angle is calculated based on the coordinates of the vertices of the light pass sheet contour. The contour inclination angle theta is obtained by accumulating the inclination angles calculated from the coordinates of all contour vertices and taking the average value. The following formula is used to calculate the contour inclination angle:

式中,为轮廓倾斜角度,为轮廓数量,为第i个轮廓第1个点的坐标,为第i个轮廓第1个点的x坐标,为第i个轮廓第1个点的y坐标;为第i个轮廓第2个点的坐标,为第i个轮廓第2个点的x坐标,为第i个轮廓第2个点的y坐标;In the formula, is the profile inclination angle, is the number of contours, is the coordinate of the first point of the i -th contour, is the x- coordinate of the first point of the i -th contour, is the y coordinate of the first point of the i -th contour; is the coordinate of the second point of the i -th contour, is the x- coordinate of the second point of the i - th contour, is the y coordinate of the second point of the i - th contour;

如图15通过欧几里德距离公式计算轮廓宽度和轮廓高度:As shown in Figure 15, the contour width and contour height are calculated using the Euclidean distance formula:

式中,为轮廓宽度,为轮廓高度,为轮廓数量,为第i个光通片轮廓第1个点的坐标,为第i个轮廓第1个点的x坐标,为第i个轮廓第1个点的y坐标;为第i个光通片轮廓第2个点的坐标,为第i个轮廓第2个点的x坐标,为第i个轮廓第2个点的y坐标;为第i个光通片轮廓第3个点的坐标,为第i个轮廓第3个点的x坐标,为第i个轮廓第3个点的y坐标;In the formula, is the outline width, is the profile height, is the number of contours, is the coordinate of the first point of the i -th light channel contour, is the x- coordinate of the first point of the i -th contour, is the y coordinate of the first point of the i -th contour; is the coordinate of the second point of the i - th light channel contour, is the x- coordinate of the second point of the i - th contour, is the y coordinate of the second point of the i - th contour; is the coordinate of the third point of the i - th light channel contour, is the x- coordinate of the third point of the i - th contour, is the y coordinate of the third point of the i - th contour;

3、获取Blob中心坐标并补充轮廓顶点坐标:3. Get the coordinates of the Blob center and add the coordinates of the contour vertices:

Blob检测器对检测样式进行设定,使Blob检测器仅检测四边形样式斑块;Blob检测器对检测面积进行设定,使Blob检测器筛除不在第三设定面积范围内的斑块(图像中的光通片也可视为一种斑块),即,筛除第三设定面积范围外的斑块;使用配置完成的Blob检测器检测灰度图中获得如图5的Blob中心坐标;The Blob detector sets the detection pattern so that the Blob detector detects only quadrilateral pattern patches; the Blob detector sets the detection area so that the Blob detector screens out patches that are not within the third set area range (the light pass sheet in the image can also be regarded as a patch), that is, screens out patches outside the third set area range; the configured Blob detector is used to detect the grayscale image to obtain the Blob center coordinates as shown in Figure 5;

通过欧几里得距离公式计算轮廓中心坐标与Blob中心坐标之间的距离,如下式:Calculate the distance between the center coordinates of the contour and the center coordinates of the Blob using the Euclidean distance formula , as follows:

其中为第个轮廓中心坐标,为第个轮廓中心的x坐标,为第个轮廓中心的y坐标,为第个Blob中心坐标,为第个Blob中心的x坐标,为第个Blob中心的y坐标;in For the The coordinates of the contour center, For the The x- coordinate of the center of the contour, For the The y coordinate of the center of the contour, For the Blob center coordinates, For the The x coordinate of the center of the blob, For the The y coordinate of the center of the Blob;

dis小于或等于第四设定值时,则Blob中心坐标与轮廓中心坐标为同一个光通片的中心点,则无须补充,优选的,所述第四设定值可以为17、18、20、21或22个像素,但具体可根据实际情况需要而设置;当dis大于第四设定值时,则认为Blob中心坐标与轮廓中心坐标不一致,此时需要将Blob检测获得的光通片补充到轮廓检测获得的光通片中,具体为:以Blob中心坐标为矩形中心,以轮廓倾斜角度为矩形倾斜角度、以轮廓宽度为矩形宽度、以轮廓高度为矩形高度绘制Blob矩形,得到Blob矩形顶点坐标并去除超出灰度图边缘的Blob矩形顶点坐标;将如图6的Blob矩形顶点坐标进行顺时针排序,将获得的Blob矩形顶点坐标补充到轮廓顶点坐标点中,获得补充坐标;为防止在图像边缘的光通片被误检,对补充坐标进行筛选,去除超出灰度图边缘的补充坐标;When dis is less than or equal to the fourth set value, the Blob center coordinates and the contour center coordinates are the center points of the same optical pass sheet, and no supplement is required. Preferably, the fourth set value can be 17, 18, 20, 21 or 22 pixels, but it can be set according to actual needs; when dis is greater than the fourth set value, it is considered that the Blob center coordinates are inconsistent with the contour center coordinates. At this time, the optical pass sheet obtained by the Blob detection needs to be supplemented to the optical pass sheet obtained by the contour detection. Specifically: the Blob center coordinates are the center of the rectangle, and the contour inclination angle is The tilt angle of the rectangle and the width of the outline is the rectangle width, and the outline height Draw a Blob rectangle for the rectangle height, obtain the Blob rectangle vertex coordinates and remove the Blob rectangle vertex coordinates beyond the edge of the grayscale image; sort the Blob rectangle vertex coordinates as shown in Figure 6 clockwise, add the obtained Blob rectangle vertex coordinates to the contour vertex coordinate points to obtain supplementary coordinates; in order to prevent the optical pass sheet at the edge of the image from being misdetected, filter the supplementary coordinates and remove the supplementary coordinates beyond the edge of the grayscale image;

如图7所示,将在灰度图边缘范围内的补充坐标使用内缩算法去除光通片毛刺对最终检测效果的影响(如图16所示),获得内缩后的内缩坐标(如图8所示);计算内缩坐标公式为:As shown in FIG7 , the supplementary coordinates within the edge range of the grayscale image are used with the shrinking algorithm to remove the influence of the burrs on the final detection effect of the optical pass sheet (as shown in FIG16 ), and the shrinking coordinates after shrinking are obtained (as shown in FIG8 ); the shrinking coordinates are calculated The formula is:

其中in

式中为补充坐标,为内缩坐标,L为内缩距离,优选的,内缩距离可以为3、4、5或6个像素,但具体可根据实际情况需要而设置,为某一补充坐标与相邻的两个补充坐标组成的向量,向量的模,向量的模,为补充坐标的两条边的夹角,表示向量x方向的分量,表示向量y方向的分量,表示向量x方向的分量、表示向量y方向的分量。In the formula are supplementary coordinates, is the indentation coordinate, L is the indentation distance, preferably, the indentation distance can be 3, 4, 5 or 6 pixels, but can be set according to actual needs, , is a vector consisting of a supplementary coordinate and two adjacent supplementary coordinates. for The modulus of a vector, for The magnitude of a vector, is the angle between the two sides of the supplementary coordinates, Representation vector The component in the x direction, Representation vector The component in the y direction, Representation vector The component in the x direction, Representation vector Component in the y direction.

4、获取掩膜区域并处理:4. Get the mask area and process it:

为避免有倾斜角度的检测区域与非光通片区域影响检测效率,需要获取无倾斜角度的灰度图掩膜区域,创建与灰度图相同分辨率的黑色图像,在黑色图像上以内缩坐标为顶点绘制模拟光通片,将黑色图像内缩坐标区域内填充为白色,即将模拟光通片内填充为白色(像素值为255),如图9所示,对黑色图像内缩坐标使用多边形外接矩形算法获得内缩坐标的外接矩形四个顶点,该外接矩形为无倾斜角度的矩形,如下式:In order to avoid the detection area with tilt angle and the non-optical pass area affecting the detection efficiency, it is necessary to obtain the grayscale mask area without tilt angle, create a black image with the same resolution as the grayscale image, draw the simulated optical pass on the black image with the indented coordinates as the vertex, and fill the indented coordinate area of the black image with white, that is, fill the simulated optical pass with white (pixel value is 255), as shown in Figure 9, use the polygonal circumscribed rectangle algorithm for the indented coordinates of the black image to obtain the four vertices of the circumscribed rectangle of the indented coordinates. The circumscribed rectangle is a rectangle without tilt angle, as shown in the following formula:

如图17所示,外接矩形是通过寻找四边形各方向的最大或最小坐标值获得外接矩形边界,0、1、2、3为内缩坐标的四个顶点,获取边界的公式为:As shown in FIG17 , the bounding rectangle is obtained by finding the maximum or minimum coordinate value in each direction of the quadrilateral. 0, 1, 2, and 3 are the four vertices of the indented coordinates. The formula for obtaining the boundary is:

式中left为外接矩形左边界,right为外接矩形右边界,top为外接矩形上边界bottom为外接矩形下边界,为内缩坐标区域里所有坐标中最小的x坐标值,为内缩坐标区域里所有坐标中最小的y坐标值,为内缩坐标区域里所有坐标中最大的x坐标值,为内缩坐标区域里所有坐标中最大的y坐标值;Where left is the left boundary of the bounding rectangle, right is the right boundary of the bounding rectangle, top is the upper boundary of the bounding rectangle, and bottom is the lower boundary of the bounding rectangle. is the minimum x- coordinate value of all coordinates in the indented coordinate area. is the minimum y coordinate value of all coordinates in the indented coordinate area. is the maximum x- coordinate value of all coordinates in the indented coordinate area. The maximum y coordinate value among all coordinates in the indented coordinate area;

外接矩形区域即为如图9所示的黑色图像掩膜区域,该区域为无倾斜角度区域,遍历黑色图像掩膜区域内的像素,累计遍历到的黑色像素,若遍历到的黑色像素和与黑色图像掩膜区域内总像素和的比值小于第五设定值,则判断该掩膜区域合格,优选的,第五设定值为0.1、0.2、0.3、0.4或0.5等,但具体可根据实际情况需要而设置;The circumscribed rectangular area is the black image mask area as shown in FIG. 9 , which is a non-tilt angle area. The pixels in the black image mask area are traversed, and the traversed black pixels are accumulated. If the ratio of the sum of the traversed black pixels to the sum of the total pixels in the black image mask area is less than the fifth set value, the mask area is judged to be qualified. Preferably, the fifth set value is 0.1, 0.2, 0.3, 0.4 or 0.5, etc., but can be set according to actual needs;

灰度图预处理时,光源会对不同角度的图像区域造成影响,对中间直射范围的图像显示较高的亮度,边缘斜射范围的图像显示较低的亮度,由于亮度的不均匀问题,粗略的二值化处理很容易造成图像缺陷的误判。因此需要将图像分为不同的局部区域,每个局部区域的光照角度几乎一致,尽可能减少亮度的不均匀问题。When preprocessing grayscale images, the light source will affect image areas at different angles. Images in the middle direct range will show higher brightness, while images in the edge oblique range will show lower brightness. Due to the uneven brightness, rough binarization processing can easily lead to misjudgment of image defects. Therefore, it is necessary to divide the image into different local areas, and the illumination angle of each local area is almost the same to minimize the uneven brightness problem.

如图10所示,灰度图非掩膜区域即为非光通片区域,截取灰度图掩膜区域进行检测避免非光通片区域影响检测效率,对灰度图掩膜区域使用现有的积分阈值算法,首先对灰度图掩膜区域进行高斯模糊处理,设定高斯模糊标准差值sigma,使用边界延展算法(Opencv自带的算法)复制灰度图掩膜区域边界;As shown in FIG10 , the non-mask area of the grayscale image is the non-optical pass area. The grayscale image mask area is intercepted for detection to avoid the non-optical pass area affecting the detection efficiency. The existing integral threshold algorithm is used for the grayscale image mask area. First, the grayscale image mask area is Gaussian blurred, and the Gaussian blur standard deviation value sigma is set. The boundary extension algorithm (the algorithm provided by Opencv) is used to copy the grayscale image mask area boundary.

计算积分图内积分核的像素和:如图18所示,通过灰度图掩膜区域四个顶点相对坐标原点位置计算积分图内积分核的像素和;使用OpenCV的反边界模式拓展图像区域边界,sumsqsum分别表示边界拓展后图像的积分区域(即:积分图)与边界拓展后图像的积分平方区域(即:平方积分图),获取积分区域的四个顶点与背景图坐标原点所围成区域内的像素的累加和,如下式:Calculate the pixel sum of the integral kernel in the integral image: As shown in Figure 18, the pixel sum of the integral kernel in the integral image is calculated by the relative positions of the four vertices of the grayscale image mask area to the coordinate origin; use OpenCV's anti-boundary mode to expand the image area boundary, sum and sqsum represent the integral area of the image after boundary expansion (i.e., integral image) and the integral square area of the image after boundary expansion (i.e., square integral image), respectively, and obtain the cumulative sum of the pixels in the area enclosed by the four vertices of the integral area and the background image coordinate origin, as shown in the following formula:

式中, 都表示积分区域左上角坐标与坐标原点围成的区域内的像素总和、 都表示积分区域右上角坐标与坐标原点围成的区域内的像素总和、 都表示积分区域左下角坐标与坐标原点围成的区域内的像素总和、 都表示积分区域右下角坐标与坐标原点围成的区域内的像素总和,i为积分区域的X方向上前i个像素的和,j为积分区域的Y方向上前j个像素的和,ker为积分核大小,为像素和;In the formula, and Both represent the sum of the pixels in the area enclosed by the coordinates of the upper left corner of the integral area and the origin of the coordinates. and Both represent the sum of the pixels in the area enclosed by the coordinates of the upper right corner of the integral area and the origin of the coordinates. and Both represent the sum of the pixels in the area enclosed by the coordinates of the lower left corner of the integration area and the coordinate origin. and All represent the sum of pixels in the area enclosed by the coordinates of the lower right corner of the integration area and the coordinate origin, i is the sum of the first i pixels in the X direction of the integration area, j is the sum of the first j pixels in the Y direction of the integration area, ker is the size of the integration kernel, is the pixel sum;

同理计算积分平方区域的四个顶点与背景图坐标原点所围成区域内的像素累加和,如下式:Similarly, calculate the cumulative sum of pixels in the area enclosed by the four vertices of the integral square area and the origin of the background coordinate system, as follows:

式中,都表示积分平方区域的左上角坐标与坐标原点围成的区域内的像素总和、都表示积分平方区域的右上角坐标与坐标原点围成的区域内的像素总和、都表示积分平方区域的左下角坐标与坐标原点围成的区域内的像素总和、都表示积分平方区域的右下角坐标与坐标原点围成的区域内的像素总和,i为积分平方区域的X方向上前i个像素的和,j为积分平方区域的Y方向上前j个像素的和,ker为积分核大小,为平方像素和;In the formula, and Both represent the sum of the pixels in the area enclosed by the coordinates of the upper left corner of the integral square area and the coordinate origin. and Both represent the sum of the pixels in the area enclosed by the coordinates of the upper right corner of the integral square area and the origin of the coordinate system. and Both represent the sum of the pixels in the area enclosed by the coordinates of the lower left corner of the integral square area and the origin of the coordinate system. and All represent the sum of pixels in the area enclosed by the coordinates of the lower right corner of the integral square area and the coordinate origin, i is the sum of the first i pixels in the X direction of the integral square area, j is the sum of the first j pixels in the Y direction of the integral square area, ker is the integral kernel size, is the sum of square pixels;

通过积分区域内像素和获取像素均值,如下式:By integrating the pixels in the area and obtaining the pixel mean , as follows:

并获取像素方差var,如下式:And get the pixel variance var as follows:

计算积分二值化阈值,如下式:Calculate the integral binarization threshold as follows:

通过积分二值化阈值将灰度图掩膜区域逐像素进行二值化处理,获取掩膜积分二值图,如下式:The grayscale image mask area is binarized pixel by pixel through the integral binarization threshold to obtain the mask integral binary image, as shown in the following formula:

其中为灰度图掩膜区域中坐标点的像素值,为对应像素值计算的积分二值化阈值,为二值化后的像素值;in is the grayscale mask area The pixel value of the coordinate point, is the integral binarization threshold calculated for the corresponding pixel value, is the pixel value after binarization;

积分二值化处理时计算积分核内的像素和、平方像素和、像素均值和像素方差,使用积分图和积分平方图,在一次计算中获取多个像素的信息,加快局部统计信息的计算,提高性能,避免重复计算降低了计算复杂度,使用累积的像素值,增强准确性;When performing integral binarization, the pixel sum, square pixel sum, pixel mean and pixel variance within the integral kernel are calculated. The integral map and integral square map are used to obtain information of multiple pixels in one calculation, speed up the calculation of local statistical information, improve performance, avoid repeated calculations, reduce calculation complexity, and use accumulated pixel values to enhance accuracy.

使用连通域算法计算掩膜积分二值图内连通域的面积,如图11所示,对掩膜积分二值图内不影响光通片质量(即:连通域面积小于第一设定面积)的极小特征(即:极小连通域)进行去除(即:去除杂质),将掩膜积分二值图中除内缩坐标区域以外的像素置0(即:去除干扰因素),避免掩膜区域中光通片毛边、非光通片区域影响检测;使用Sobel算子获取掩膜积分二值图的总梯度并生成掩膜梯度图,使掩膜积分二值图仅显示像素强度变化率;对掩膜梯度图使用参数阈值法进行二值化,将掩膜梯度图分为前景和背景,即获得掩膜参数轮廓图;对掩膜梯度图使用参数阈值法进行二值化,将掩膜梯度图分为前景和背景,即获得掩膜参数轮廓图;使用自适应阈值法对掩膜参数轮廓图进行二值化,将掩膜参数轮廓图分为边缘区域和非边缘区域,获取掩膜边缘轮廓图;对掩膜边缘轮廓图再一次使用Sobel算子计算总梯度并通过参数阈值法进行二值化(即:预处理)获取掩膜边缘图;The connected domain algorithm is used to calculate the area of the connected domain in the mask integral binary image, as shown in Figure 11. The extremely small features (i.e., the extremely small connected domain) in the mask integral binary image that do not affect the quality of the optical pass film (i.e., the area of the connected domain is less than the first set area) are removed (i.e., impurities are removed), and the pixels in the mask integral binary image except the indented coordinate area are set to 0 (i.e., interference factors are removed) to avoid the burrs of the optical pass film and the non-optical pass film area in the mask area affecting the detection; the Sobel operator is used to obtain the total gradient of the mask integral binary image and generate a mask gradient image, so that the mask integral binary image only displays pixel intensity changes. rate; binarize the mask gradient map using the parameter threshold method, divide the mask gradient map into the foreground and the background, and obtain the mask parameter contour map; binarize the mask gradient map using the parameter threshold method, divide the mask gradient map into the foreground and the background, and obtain the mask parameter contour map; binarize the mask parameter contour map using the adaptive threshold method, divide the mask parameter contour map into the edge area and the non-edge area, and obtain the mask edge contour map; calculate the total gradient of the mask edge contour map using the Sobel operator again and binarize it using the parameter threshold method (i.e., preprocessing) to obtain the mask edge map;

5、获取缺陷信息并标记:5. Obtain defect information and mark it:

对掩膜边缘图使用连通域算法获取掩膜边缘图内部连通域信息,所述掩膜边缘图内部连通域信息包括掩膜边缘图内部连通域面积、连通域数量、宽度和高度信息,根据连通域信息与设定条件(即:设定参数)对比判断掩膜边缘图缺陷(即:根据设定条件判断光通片表面缺陷);Using a connected domain algorithm to obtain the connected domain information inside the mask edge map, the connected domain information inside the mask edge map includes the area, number, width and height of the connected domain inside the mask edge map, and judging the defects of the mask edge map (i.e. judging the surface defects of the optical pass sheet according to the set conditions) by comparing the connected domain information with the set conditions (i.e. setting parameters);

其中,点伤等较大面积缺陷是根据掩膜边缘图检测获得的连通域面积与第六设定直径计算出的面积对比得来:Among them, larger area defects such as point damage are obtained by comparing the connected domain area obtained by mask edge map detection with the area calculated by the sixth set diameter:

式中,表示第i个掩膜边缘图内是否存在点伤,=1时表示存在点伤,=0时表示不存在点伤;为第i个掩膜边缘图内的第j个连通域的面积,为第六设定直径,优选的,第六设定直径为5、6、7、8或9个像素,但具体可根据实际情况需要而设置,n为第i个掩膜边缘图内连通域的数量;In the formula, Indicates whether there is a point defect in the i - th mask edge image. =1 indicates that there is a point injury. =0 means there is no point damage; is the area of the jth connected domain in the ith mask edge graph, is the sixth set diameter, preferably, the sixth set diameter is 5, 6, 7, 8 or 9 pixels, but can be set according to actual needs, n is the number of connected domains in the i- th mask edge map;

其中,麻点等较多的斑点缺陷是根据掩膜边缘图检测获得的连通域数量对比第七设定数量,统计所有属于缺陷的连通域数量: Among them, the defects with more spots such as pits are detected by comparing the number of connected domains obtained by the mask edge map detection with the seventh set number, and the number of connected domains belonging to all defects is counted:

式中,表示第i个掩膜边缘图不存在麻点缺陷,表示第i个掩膜边缘图存在属于麻点缺陷,N为第七设定数量麻点,n为第i个掩膜边缘图内连通域的数量,优选的,第七设定数量麻点可以为2、3、4或5个麻点;In the formula, Indicates that there is no pit defect in the i- th mask edge image, indicates that there is a pit defect in the i- th mask edge graph, N is the seventh set number of pits, n is the number of connected domains in the i -th mask edge graph, and preferably, the seventh set number of pits may be 2, 3, 4 or 5 pits;

其中,划痕等较为细长的缺陷检测,根据连通域宽度和连通域高度比值与连通域最大边缘值共同判定,第一步判断是否为细长连通域,根据连通域宽度与高度的比值是否大于第八设定值或小于第九设定值,其中,第八设定值大于第九设定值,若掩膜边缘图连通域宽度与高度的比值大于第八设定值或小于第九设定值则为细长连通域,如下式:Among them, the detection of relatively long and thin defects such as scratches is determined by the ratio of the connected domain width to the connected domain height and the maximum edge value of the connected domain. The first step is to determine whether it is a long and thin connected domain, based on whether the ratio of the connected domain width to the height is greater than the eighth set value or less than the ninth set value, wherein the eighth set value is greater than the ninth set value. If the ratio of the mask edge map connected domain width to the height is greater than the eighth set value or less than the ninth set value, it is a long and thin connected domain, as shown in the following formula:

式中,为第i个掩膜边缘图的第j个连通域的宽度,i个掩膜边缘图的第j个连通域的高度,n为第i个掩膜边缘图内连通域的数量,为第八设定值,为第九设定值,时表示该连通域不属于细长区域,时表示该连通域属于细长区域,优选的,第九设定值为2/17、1/16、1/15、2/15、1/14或2/13,第八设定值为12、13、14、15、16或17,但具体可根据实际情况需要而设置;In the formula, is the width of the jth connected domain of the ith mask edge graph, The height of the jth connected domain of the ith mask edge graph, n is the number of connected domains in the ith mask edge graph, is the eighth setting value, is the ninth setting value, , indicating that the connected domain does not belong to the elongated region. When , it indicates that the connected domain belongs to a slender area. Preferably, the ninth setting value is 2/17, 1/16, 1/15, 2/15, 1/14 or 2/13, and the eighth setting value is 12, 13, 14, 15, 16 or 17, but it can be set according to actual needs;

第二步:判断连通域最大边缘值是否大于第十设定值(细长缺陷或划痕的宽度和高度相比,较大值即为所述连通域最大边缘值):Step 2: Determine whether the maximum edge value of the connected domain is greater than the tenth set value (the larger value of the width and height of the slender defect or scratch is the maximum edge value of the connected domain):

式中为连通域最大边缘值,为第十设定值,时表示连通域不属于划痕缺陷,时表示连通域属于划痕缺陷,优选的,第十设定值为13、14、15、16或17个像素。In the formula is the maximum edge value of the connected domain, is the tenth setting value, When , it means that the connected domain does not belong to the scratch defect. When , it indicates that the connected domain belongs to a scratch defect. Preferably, the tenth setting value is 13, 14, 15, 16 or 17 pixels.

统计所有属于缺陷(点伤、麻点、划痕等)的掩膜边缘图后,记录该掩膜边缘图的中心坐标,并对原始图中对应的坐标点进行打点标记,完成光通片缺陷检测。After counting all the mask edge images that are defects (spots, pits, scratches, etc.), record the center coordinates of the mask edge image, and mark the corresponding coordinate points in the original image to complete the optical film defect detection.

以上实施例仅用以说明本发明的技术方案,而非对发明的保护范围进行限制。显然,所描述的实施例仅仅是本发明部分实施例,而不是全部实施例。基于这些实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明所要保护的范围。尽管参照上述实施例对本发明进行了详细的说明,本领域普通技术人员依然可以在不冲突的情况下,不作出创造性劳动对本发明各实施例中的特征根据情况相互组合、增删或作其他调整,从而得到不同的、本质未脱离本发明的构思的其他技术方案,这些技术方案也同样属于本发明所要保护的范围。The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the scope of protection of the invention. Obviously, the described embodiments are only some embodiments of the present invention, rather than all embodiments. Based on these embodiments, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in this field can still combine, add, delete or make other adjustments to the features in the various embodiments of the present invention according to the circumstances without conflict, without making creative work, so as to obtain different other technical solutions that do not deviate from the concept of the present invention in essence, and these technical solutions also belong to the scope of protection of the present invention.

Claims (8)

1.一种光通片缺陷检测方法,其特征在于,包括以下步骤:1. A method for detecting defects in optical wafers, comprising the following steps: 步骤一:通过图像采集装置获取带有光通片的原始图,将原始图复制为灰度图;Step 1: Obtain the original image with the optical pass film through an image acquisition device, and copy the original image into a grayscale image; 步骤二:对灰度图进行预处理,通过轮廓检测和夹角余弦值筛选,获取轮廓顶点坐标,并计算轮廓中心坐标、轮廓宽度、轮廓高度以及轮廓倾斜角度;具体为:对灰度图使用高斯模糊处理,降低灰度图噪声使灰度图变得平滑,为提取特征做准备;使用Sobel算子计算灰度图的总梯度并生成灰度图的总梯度图,使灰度图仅显示像素强度变化率,进而对灰度图的总梯度图使用参数阈值法进行二值化,将灰度图的总梯度图分为前景和背景,即获得参数轮廓图;再使用OpenCV自适应阈值法对参数轮廓图进行二值化,将参数轮廓图分为边缘区域和非边缘区域,使参数轮廓图中的轮廓变为单像素显示,即获取边缘轮廓图;计算边缘轮廓图中检测到的连通域面积并对比第一设定面积,删除边缘轮廓图中连通域面积小于第一设定面积的区域;使用Sobel算子计算边缘轮廓图的总梯度并通过参数阈值法进行二值化获取参数边缘轮廓图;使用边缘查找算法获取参数边缘轮廓图中的连通区域的边缘,对连通区域的边缘进行多边形逼近,获取连通区域轮廓;去除连通区域轮廓中除凸四边形轮廓以外的连通区域轮廓,通过凸四边形轮廓顶点坐标互相计算夹角余弦值,选取凸四边形轮廓顶点坐标形成的夹角余弦值的最大值与第二设定值比较,小于第二设定值判断凸四边形的形状接近矩形,筛选出形状接近矩形的凸四边形轮廓,并使用外接倾斜矩形算法计算凸四边形轮廓的外接倾斜矩形顶点,即轮廓顶点坐标;通过轮廓顶点坐标计算轮廓中心坐标,将轮廓顶点坐标与轮廓中心坐标对比,按照顺时针重新排列;根据轮廓顶点坐标排序的前两个点与X坐标轴的夹角进行反三角函数计算获得轮廓倾斜角度,并计算轮廓宽度和轮廓高度;Step 2: Preprocess the grayscale image, obtain the coordinates of the contour vertices through contour detection and angle cosine value screening, and calculate the coordinates of the contour center, contour width, contour height and contour inclination angle; specifically: use Gaussian blur processing on the grayscale image to reduce the noise of the grayscale image and make the grayscale image smooth, in preparation for feature extraction; use the Sobel operator to calculate the total gradient of the grayscale image and generate the total gradient map of the grayscale image, so that the grayscale image only displays the pixel intensity change rate, and then use the parameter threshold method to binarize the total gradient map of the grayscale image, and divide the total gradient map of the grayscale image into foreground and background, that is, obtain the parameter contour map; then use the OpenCV adaptive threshold method to binarize the parameter contour map, divide the parameter contour map into edge area and non-edge area, so that the contour in the parameter contour map becomes a single pixel display, that is, obtain the edge contour map; calculate the area of the connected domain detected in the edge contour map and compare it with the first set area, and delete the area in the edge contour map where the connected domain area is smaller than the first set area; use the Sobel operator to calculate Calculate the total gradient of the edge contour map and perform binarization through the parameter threshold method to obtain the parameter edge contour map; use the edge search algorithm to obtain the edge of the connected area in the parameter edge contour map, perform polygonal approximation on the edge of the connected area, and obtain the connected area contour; remove the connected area contours except the convex quadrilateral contour in the connected area contour, calculate the cosine value of the angle between the vertex coordinates of the convex quadrilateral contour, select the maximum value of the cosine value of the angle formed by the vertex coordinates of the convex quadrilateral contour and compare it with the second set value, and if it is less than the second set value, it is judged that the shape of the convex quadrilateral is close to a rectangle, screen out the convex quadrilateral contour with a shape close to a rectangle, and use the circumscribed inclined rectangle algorithm to calculate the vertices of the circumscribed inclined rectangle of the convex quadrilateral contour, that is, the coordinates of the contour vertices; calculate the contour center coordinates through the contour vertex coordinates, compare the contour vertex coordinates with the contour center coordinates, and rearrange them clockwise; perform inverse trigonometric function calculation on the angle between the first two points sorted by the contour vertex coordinates and the X-coordinate axis to obtain the contour inclination angle, and calculate the contour width and contour height; 步骤三:使用Blob检测获取灰度图中Blob中心坐标,通过Blob中心坐标与轮廓中心坐标对比,将Blob中心坐标与轮廓信息结合,补充轮廓顶点坐标,获得补充坐标,并对补充坐标使用内缩算法获得内缩坐标;具体为:Blob检测器对检测样式进行设定,使Blob检测器仅检测四边形样式斑块;Blob检测器对检测面积进行设定,使Blob检测器筛除在第三设定面积范围外的斑块;使用配置完成的Blob检测器直接检测灰度图,获得Blob中心坐标;通过欧几里得距离公式计算Blob中心坐标与轮廓中心坐标之间的距离dis,当dis小于或等于第四设定值时,则Blob中心坐标与轮廓中心坐标为同一个光通片的中心点,则无须补充;当dis大于第四设定值时,则认为Blob中心坐标与轮廓中心坐标不一致,此时需要将Blob检测获得的光通片补充到轮廓检测获得的光通片中,获得补充坐标;为防止图像边缘的光通片被误检,去除超出灰度图边缘的补充坐标;并将在灰度图边缘内的补充坐标使用内缩算法进行多边形内缩获取内缩坐标;Step 3: Use Blob detection to obtain the center coordinates of the Blob in the grayscale image, compare the center coordinates of the Blob with the center coordinates of the contour, combine the center coordinates of the Blob with the contour information, supplement the coordinates of the contour vertices, obtain the supplementary coordinates, and use the shrinkage algorithm to obtain the shrinkage coordinates on the supplementary coordinates; specifically: the Blob detector sets the detection style so that the Blob detector only detects quadrilateral style patches; the Blob detector sets the detection area so that the Blob detector screens out patches outside the third set area range; use the configured Blob detector to directly detect the grayscale image to obtain the center coordinates of the Blob; calculate the distance dis between the center coordinates of the Blob and the center coordinates of the contour using the Euclidean distance formula When dis is less than or equal to the fourth setting value, the Blob center coordinates and the contour center coordinates are the center points of the same light pass sheet, and no supplement is required; when dis is greater than the fourth setting value, it is considered that the Blob center coordinates are inconsistent with the contour center coordinates. At this time, the light pass sheet obtained by the Blob detection needs to be supplemented to the light pass sheet obtained by the contour detection to obtain supplementary coordinates; to prevent the light pass sheet at the edge of the image from being misdetected, the supplementary coordinates that exceed the edge of the grayscale image are removed; and the supplementary coordinates within the edge of the grayscale image are subjected to polygonal indentation using the indentation algorithm to obtain the indentation coordinates; 步骤四:创建与灰度图分辨率一致的黑色图像,对黑色图像的内缩坐标使用多边形外接矩形算法获取内缩坐标的外接矩形区域即黑色图像掩膜区域,对与黑色图像掩膜区域坐标相同的灰度图掩膜区域进行积分二值化及预处理,生成掩膜边缘图;具体为:创建与灰度图相同分辨率的黑色图像,在黑色图像上以内缩坐标为顶点绘制模拟光通片,将黑色图像内缩坐标区域内填充为白色;对内缩坐标使用多边形外接矩形算法获得内缩坐标的外接矩形四个顶点,四个顶点围成的外接矩形区域即为黑色图像掩膜区域,遍历黑色图像掩膜区域内的像素,若黑色图像掩膜区域的黑色像素和与总像素和的比值小于第五设定值,则判断该黑色图像掩膜区域为合格;对与黑色图像掩膜区域坐标相同的灰度图掩膜区域通过使用经计算的积分图和平方积分图,计算出所有位置的像素和、平方像素和、像素均值和像素方差,在一次计算中获取多个像素的信息,并使用累积的像素值进行计算,完成积分二值化得到掩膜积分二值图;对掩膜积分二值图使用连通域算法获取各连通域面积,连通域面积小于第一设定面积的为极小连通域并对极小连通域去除,即去除杂质;将掩膜积分二值图中除内缩坐标区域以外的像素置0,即去除干扰因素;使用Sobel算子获取掩膜积分二值图的总梯度并生成掩膜梯度图,使掩膜积分二值图仅显示像素强度变化率;对掩膜梯度图使用参数阈值法进行二值化,将掩膜梯度图分为前景和背景,即获得掩膜参数轮廓图;使用自适应阈值法对掩膜参数轮廓图进行二值化,将掩膜参数轮廓图分为边缘区域和非边缘区域,获取掩膜边缘轮廓图;对掩膜边缘轮廓图再一次使用Sobel算子计算总梯度并通过参数阈值法进行二值化获取掩膜边缘图;Step 4: Create a black image with the same resolution as the grayscale image, use a polygonal circumscribed rectangle algorithm for the indented coordinates of the black image to obtain the circumscribed rectangular area of the indented coordinates, namely the black image mask area, perform integral binarization and preprocessing on the grayscale image mask area with the same coordinates as the black image mask area to generate a mask edge map; specifically: create a black image with the same resolution as the grayscale image, draw a simulated light pass film on the black image with the indented coordinates as vertices, and fill the indented coordinate area of the black image with white; use a polygonal circumscribed rectangle algorithm for the indented coordinates to obtain the four vertices of the circumscribed rectangle of the indented coordinates, and the circumscribed rectangular area surrounded by the four vertices is the black image mask area, traverse the pixels in the black image mask area, and if the ratio of the black pixel sum to the total pixel sum in the black image mask area is less than the fifth set value, the black image mask area is judged to be qualified; for the grayscale image mask area with the same coordinates as the black image mask area, use the calculated integral map and square integral map to calculate the pixel sum and square pixel sum of all positions , pixel mean and pixel variance, obtain information of multiple pixels in one calculation, and use the accumulated pixel values for calculation, complete the integral binarization to obtain the mask integral binary map; use the connected domain algorithm to obtain the area of each connected domain on the mask integral binary map, the connected domain area less than the first set area is the minimum connected domain and the minimum connected domain is removed, that is, remove impurities; set the pixels in the mask integral binary map except the indented coordinate area to 0, that is, remove interference factors; use the Sobel operator to obtain the total gradient of the mask integral binary map and generate a mask gradient map, so that the mask integral binary map only displays the pixel intensity change rate; use the parameter threshold method to binarize the mask gradient map, divide the mask gradient map into foreground and background, that is, obtain the mask parameter contour map; use the adaptive threshold method to binarize the mask parameter contour map, divide the mask parameter contour map into edge area and non-edge area, and obtain the mask edge contour map; use the Sobel operator to calculate the total gradient of the mask edge contour map again and binarize it by the parameter threshold method to obtain the mask edge map; 步骤五:对掩膜边缘图进行缺陷检测获取缺陷信息,随后在原始图中进行缺陷标记;具体为:对掩膜边缘图使用连通域算法获取掩膜边缘图内部连通域信息,若连通域信息超出对应的设定参数,则判断掩膜边缘图存在缺陷,并记录存在缺陷的掩膜边缘图坐标,即缺陷坐标,根据缺陷坐标在原始图中标记。Step 5: Perform defect detection on the mask edge map to obtain defect information, and then mark the defects in the original image; specifically: use the connected domain algorithm on the mask edge map to obtain the internal connected domain information of the mask edge map. If the connected domain information exceeds the corresponding set parameters, it is judged that there is a defect in the mask edge map, and the coordinates of the defective mask edge map, that is, the defect coordinates, are recorded, and marked in the original image according to the defect coordinates. 2.根据权利要求1所述的光通片缺陷检测方法,其特征在于,步骤二还包括以下步骤:2. The optical fiber defect detection method according to claim 1, characterized in that step 2 further comprises the following steps: 根据逼近算法对连通域的边缘进行多边形逼近获取连通域轮廓,并去除连通域轮廓中除凸四边形轮廓外的连通域轮廓,计算包围凸四边形轮廓的四个顶点坐标,即获得凸四边形的四个轮廓顶点坐标;According to the approximation algorithm, polygonal approximation is performed on the edge of the connected domain to obtain the connected domain contour, and the connected domain contour except the convex quadrilateral contour is removed from the connected domain contour, and the coordinates of the four vertices surrounding the convex quadrilateral contour are calculated, that is, the coordinates of the four contour vertices of the convex quadrilateral are obtained; 根据凸四边形轮廓顶点坐标互相计算夹角余弦值,通过计算相邻三个点形成的两个向量之间的夹角余弦值并选择最大值来判断凸四边形的形状是否接近矩形,具体如下式:The cosine values of the angles between the vertices of the convex quadrilateral outline are calculated, and the cosine values of the angles between the two vectors formed by three adjacent points are calculated and the maximum value is selected to determine whether the shape of the convex quadrilateral is close to a rectangle. The specific formula is as follows: 式中为凸四边形第i个顶点坐标,为凸四边形第i个顶点的x坐标,为凸四边形第i个顶点的y坐标;为凸四边形第i+1个顶点坐标,为凸四边形第i+1个顶点的x坐标,为凸四边形第i+1个顶点的y坐标;,为凸四边形第i+2个顶点坐标,为凸四边形第i+2个顶点的x坐标,为凸四边形第i+2个顶点的y坐标;向量为点指向点的向量,向量为点指向点的向量,为向量和向量两向量的夹角,为计算得到的最大余弦值,点与点为同一个点;In the formula is the coordinate of the ith vertex of the convex quadrilateral, is the x- coordinate of the ith vertex of the convex quadrilateral, is the y coordinate of the i- th vertex of the convex quadrilateral; are the coordinates of the i +1th vertex of the convex quadrilateral, is the x- coordinate of the i+ 1th vertex of the convex quadrilateral, is the y coordinate of the i+ 1th vertex of the convex quadrilateral; , are the coordinates of the i +2th vertex of the convex quadrilateral, is the x- coordinate of the i+ 2nd vertex of the convex quadrilateral, is the y coordinate of the i+ 2nd vertex of the convex quadrilateral; vector For point Pointing Point vector, vector For point Pointing Point The vector of For vector and vector The angle between two vectors, is the maximum cosine value calculated, point With point for the same point; 的值小于第二设定值,则认为该凸四边形的形状接近矩形,该凸四边形轮廓是光通片轮廓,符合要求。like If the value of is less than the second set value, it is considered that the shape of the convex quadrilateral is close to a rectangle, and the contour of the convex quadrilateral is the contour of the light pass sheet, which meets the requirements. 3.根据权利要求2所述的光通片缺陷检测方法,其特征在于,3. The optical fiber defect detection method according to claim 2, characterized in that: 根据轮廓顶点坐标计算轮廓倾斜角度,具体如下式:The contour inclination angle is calculated according to the contour vertex coordinates, as follows: 式中,为轮廓倾斜角度,为轮廓数量,为第i个轮廓第1个点的坐标,为第i个轮廓第1个点的x坐标,为第i个轮廓第1个点的y坐标;为第i个轮廓第2个点的坐标,为第i个轮廓第2个点的x坐标,为第i个轮廓第2个点的y坐标;In the formula, is the profile inclination angle, is the number of contours, is the coordinate of the first point of the i -th contour, is the x- coordinate of the first point of the i -th contour, is the y coordinate of the first point of the i -th contour; is the coordinate of the second point of the i -th contour, is the x- coordinate of the second point of the i - th contour, is the y coordinate of the second point of the i - th contour; 根据轮廓顶点坐标通过欧几里德距离公式计算轮廓宽度和轮廓高度,如下式:The contour width and height are calculated according to the contour vertex coordinates using the Euclidean distance formula, as shown below: 式中,为轮廓宽度,为轮廓高度,为轮廓数量,为第i个光通片轮廓第1个点的坐标,为第i个轮廓第1个点的x坐标,为第i个轮廓第1个点的y坐标;为第i个光通片轮廓第2个点的坐标,为第i个轮廓第2个点的x坐标,为第i个轮廓第2个点的y坐标;为第i个光通片轮廓第3个点的坐标,为第i个轮廓第3个点的x坐标,为第i个轮廓第3个点的y坐标。In the formula, is the outline width, is the profile height, is the number of contours, is the coordinate of the first point of the i -th light channel contour, is the x- coordinate of the first point of the i -th contour, is the y coordinate of the first point of the i -th contour; is the coordinate of the second point of the i - th light channel contour, is the x- coordinate of the second point of the i - th contour, is the y coordinate of the second point of the i - th contour; is the coordinate of the third point of the i - th light channel contour, is the x- coordinate of the third point of the i - th contour, is the y coordinate of the third point of the i - th contour. 4.根据权利要求2所述的光通片缺陷检测方法,其特征在于,步骤二中获取四个轮廓顶点坐标包括以下步骤:4. The optical sheet defect detection method according to claim 2, wherein obtaining the coordinates of four contour vertices in step 2 comprises the following steps: 使用检测到的凸四边形轮廓顶点的相邻三个点计算夹角余弦值,通过凸四边形轮廓三或四个角最大余弦值与第二设定值相比,若凸四边形轮廓最大余弦值小于第二设定值判断该凸四边形的形状接近矩形;通过使用各凸四边形轮廓的左上角顶点和右上角顶点两点的反三角函数计算出各凸四边形轮廓的倾斜角度,计算出所有凸四边形轮廓的倾斜角度之和后计算平均值。The cosine value of the angle is calculated using three adjacent points of the detected vertices of the convex quadrilateral outline, and the maximum cosine value of the three or four corners of the convex quadrilateral outline is compared with the second set value. If the maximum cosine value of the convex quadrilateral outline is less than the second set value, it is judged that the shape of the convex quadrilateral is close to a rectangle; the inclination angle of each convex quadrilateral outline is calculated by using the inverse trigonometric function of the upper left corner vertex and the upper right corner vertex of each convex quadrilateral outline, the sum of the inclination angles of all convex quadrilateral outlines is calculated, and then the average value is calculated. 5.根据权利要求1所述的光通片缺陷检测方法,其特征在于,步骤三中所述将Blob检测获得的光通片补充到轮廓检测获得的光通片中,具体为:以Blob中心坐标为矩形中心,以轮廓倾斜角度为矩形倾斜角度、以轮廓宽度为矩形宽度、以轮廓高度为矩形高度绘制Blob矩形,得到Blob矩形顶点坐标;5. The optical pass defect detection method according to claim 1 is characterized in that the optical pass obtained by Blob detection is added to the optical pass obtained by contour detection in step 3, specifically: the center coordinates of the Blob are used as the center of the rectangle, and the contour inclination angle is used as the center of the rectangle. The tilt angle of the rectangle and the width of the outline is the rectangle width, and the outline height Draw a Blob rectangle for the rectangle height and get the coordinates of the Blob rectangle vertices; 将Blob矩形顶点坐标进行顺时针排序,将排序后的Blob矩形顶点坐标补充到轮廓顶点坐标点中,获得补充坐标;Sort the Blob rectangle vertex coordinates clockwise, and add the sorted Blob rectangle vertex coordinates to the contour vertex coordinate points to obtain the supplementary coordinates; 将灰度图边缘内的补充坐标进行内缩获取内缩坐标,具体如下式:The supplementary coordinates within the edge of the grayscale image are indented to obtain the indented coordinates, as shown in the following formula: 其中in 式中为补充坐标,为内缩坐标,L为内缩距离,为某一补充坐标与相邻的两个补充坐标组成的向量,向量的模,向量的模,为补充坐标的两条边的夹角,表示向量x方向的分量,表示向量y方向的分量,表示向量x方向的分量、表示向量y方向的分量。In the formula are supplementary coordinates, is the indentation coordinate, L is the indentation distance, , is a vector consisting of a supplementary coordinate and two adjacent supplementary coordinates. for The modulus of a vector, for The magnitude of a vector, is the angle between the two sides of the supplementary coordinates, Representation vector The component in the x direction, Representation vector The component in the y direction, Representation vector The component in the x direction, Representation vector Component in the y direction. 6.根据权利要求1所述光通片缺陷检测方法,其特征在于:6. The optical fiber defect detection method according to claim 1, characterized in that: 对黑色图像内缩坐标使用多边形外接矩形算法获得内缩坐标的外接矩形四个顶点,如下式:The polygonal circumscribed rectangle algorithm is used to obtain the four vertices of the circumscribed rectangle of the indented coordinates of the black image, as shown below: 式中left为外接矩形左边界,right为外接矩形右边界,top为外接矩形上边界bottom为外接矩形下边界,为内缩坐标区域里所有坐标中最小的x坐标值,为内缩坐标区域里所有坐标中最小的y坐标值,为内缩坐标区域里所有坐标中最大的x坐标值,为内缩坐标区域里所有坐标中最大的y坐标值;Where left is the left boundary of the bounding rectangle, right is the right boundary of the bounding rectangle, top is the upper boundary of the bounding rectangle, and bottom is the lower boundary of the bounding rectangle. is the minimum x- coordinate value of all coordinates in the indented coordinate area. is the minimum y coordinate value of all coordinates in the indented coordinate area. is the maximum x- coordinate value of all coordinates in the indented coordinate area. The maximum y coordinate value among all coordinates in the indented coordinate area; 所述黑色图像掩膜区域为无倾斜角度黑色图像掩膜区域,遍历黑色图像掩膜区域内的像素,累计遍历到的黑色像素,获取黑色图像掩膜区域内的黑色像素和与总像素和的比值,若比值小于第五设定值时,则判断该掩膜区域合格;The black image mask area is a black image mask area without an inclination angle, pixels in the black image mask area are traversed, the traversed black pixels are accumulated, and a ratio of the sum of black pixels in the black image mask area to the sum of total pixels is obtained. If the ratio is less than a fifth set value, the mask area is judged to be qualified; 灰度图掩膜区域图像处理采用积分阈值算法,对灰度图掩膜区域进行高斯模糊处理,设定高斯模糊标准差值sigma,使用边界延展算法复制灰度图掩膜区域边界;The grayscale image mask area image processing uses an integral threshold algorithm to perform Gaussian blur processing on the grayscale image mask area, sets the Gaussian blur standard deviation value sigma, and uses the boundary extension algorithm to copy the grayscale image mask area boundary; 计算积分图内积分核的像素和:使用反边界模式拓展灰度图掩膜区域边界,sum表示边界拓展后图像的积分区域,sqsum表示边界拓展后图像的积分平方区域,获取积分区域的四个顶点与背景图坐标原点所围成区域内的像素的累加和,如下式:Calculate the pixel sum of the integral kernel in the integral image: Use the anti-boundary mode to expand the grayscale mask area boundary. sum represents the integral area of the image after boundary expansion. sqsum represents the integral square area of the image after boundary expansion. Get the cumulative sum of the pixels in the area enclosed by the four vertices of the integral area and the origin of the background image coordinates, as shown in the following formula: 式中,都表示积分区域左上角坐标与坐标原点围成的区域内的像素总和 都表示积分区域右上角坐标与坐标原点围成的区域内的像素总和 都表示积分区域左下角坐标与坐标原点围成的区域内的像素总和 都表示积分区域右下角坐标与坐标原点围成的区域内的像素总和,i为积分区域的X方向上前i个像素的和,j为积分区域的Y方向上前j个像素的和,ker为积分核大小,为像素和;In the formula, and Both represent the sum of the pixels in the area enclosed by the coordinates of the upper left corner of the integral area and the origin of the coordinates . and Both represent the sum of the pixels in the area enclosed by the coordinates of the upper right corner of the integral area and the origin of the coordinates . and Both represent the sum of the pixels in the area enclosed by the coordinates of the lower left corner of the integration area and the coordinate origin . and All represent the sum of pixels in the area enclosed by the coordinates of the lower right corner of the integration area and the coordinate origin, i is the sum of the first i pixels in the X direction of the integration area, j is the sum of the first j pixels in the Y direction of the integration area, ker is the size of the integration kernel, is the pixel sum; 同理计算积分平方区域的四个顶点与背景图坐标原点所围成区域内的像素累加和,如下式:Similarly, calculate the cumulative sum of pixels in the area enclosed by the four vertices of the integral square area and the origin of the background coordinate system, as follows: 式中,都表示积分平方区域的左上角坐标与坐标原点围成的区域内的像素总和、都表示积分平方区域的右上角坐标与坐标原点围成的区域内的像素总和、都表示积分平方区域的左下角坐标与坐标原点围成的区域内的像素总和 都表示积分平方区域的右下角坐标与坐标原点围成的区域内的像素总和,i为积分平方区域的X方向上前i个像素的和,j为积分平方区域的Y方向上前j个像素的和,ker为积分核大小,为平方像素和;In the formula, and Both represent the sum of the pixels in the area enclosed by the coordinates of the upper left corner of the integral square area and the coordinate origin. and Both represent the sum of the pixels in the area enclosed by the coordinates of the upper right corner of the integral square area and the origin of the coordinate system. and Both represent the sum of the pixels in the area enclosed by the coordinates of the lower left corner of the integral square area and the origin of the coordinate system . and All represent the sum of pixels in the area enclosed by the coordinates of the lower right corner of the integral square area and the coordinate origin, i is the sum of the first i pixels in the X direction of the integral square area, j is the sum of the first j pixels in the Y direction of the integral square area, ker is the integral kernel size, is the sum of square pixels; 通过积分区域内像素和获取像素均值,如下式:By integrating the pixels in the area and obtaining the pixel mean , as follows: 并获取像素方差var,如下式:And get the pixel variance var as follows: 计算积分二值化阈值th,如下式:Calculate the integral binarization threshold th as follows: 通过积分二值化阈值将灰度图掩膜区域逐像素进行二值化处理,获取掩膜积分二值图,如下式:The grayscale image mask area is binarized pixel by pixel through the integral binarization threshold to obtain the mask integral binary image, as shown in the following formula: 其中:为灰度图掩膜区域中坐标点的像素值,为对应像素值计算的积分二值化阈值,为二值化后的像素值;in: is the grayscale mask area The pixel value of the coordinate point, is the integral binarization threshold calculated for the corresponding pixel value, is the pixel value after binarization; 所述将连通域面积小于第一设定面积的极小连通域进行去除为将面积小于第一设定面积的极小连通域中的像素置为0。The removing of the extremely small connected domain whose area is smaller than the first set area is to set the pixels in the extremely small connected domain whose area is smaller than the first set area to 0. 7.根据权利要求6所述的光通片缺陷检测方法,其特征在于,所述黑色图像的分辨率与灰度图的分辨率相同,即灰度图掩膜区域与黑色图像掩膜区域坐标相同,对与所述无倾斜角度黑色图像掩膜区域坐标相同的无倾斜角度灰度图掩膜区域进行积分二值化阈值计算,计算像素方差时,取像素方差大于0的值,若像素方差小于0,则像素方差取0,二值化时使用计算得到的积分二值化阈值逐像素对灰度图掩膜区域进行二值化处理。7. The optical pass sheet defect detection method according to claim 6 is characterized in that the resolution of the black image is the same as the resolution of the grayscale image, that is, the grayscale image mask area has the same coordinates as the black image mask area, and an integral binarization threshold calculation is performed on the grayscale image mask area with no tilt angle having the same coordinates as the black image mask area with no tilt angle. When calculating the pixel variance, a value greater than 0 is taken for the pixel variance. If the pixel variance is less than 0, the pixel variance is taken as 0. When binarization is performed, the calculated integral binarization threshold is used to binarize the grayscale image mask area pixel by pixel. 8.根据权利要求1所述的光通片缺陷检测方法,其特征在于:对掩膜边缘图进行缺陷检测,随后在原始图中对缺陷进行标记包括以下步骤:8. The optical wafer defect detection method according to claim 1, characterized in that: performing defect detection on the mask edge image and then marking the defects in the original image comprises the following steps: 5.1、对掩膜边缘图使用连通域算法获取掩膜边缘图内部连通域信息,所述掩膜边缘图内部连通域信息包括掩膜边缘图内部连通域面积、连通域数量、宽度和高度;5.1. Using a connected domain algorithm to obtain the connected domain information inside the mask edge map, the connected domain information inside the mask edge map includes the area, number, width and height of the connected domain inside the mask edge map; 5.2、点伤缺陷检测,根据掩膜边缘图检测获得的连通域面积与第六设定直径计算出的面积对比,当连通域面积大于第六设定直径计算出的面积时,则认为该掩膜边缘图存在点伤缺陷;5.2. Point defect detection: compare the area of the connected domain obtained by the mask edge map detection with the area calculated by the sixth set diameter. When the area of the connected domain is larger than the area calculated by the sixth set diameter, it is considered that there is a point defect in the mask edge map; 5.3、麻点缺陷检测,根据掩膜边缘图检测到的连通域数量与设定的数量对比,若连通域数量大于第七设定数量麻点则认为该掩膜边缘图存在麻点缺陷;5.3. Pockmark defect detection: compare the number of connected domains detected by the mask edge map with the set number. If the number of connected domains is greater than the seventh set number of pockmarks, it is considered that the mask edge map has a pockmark defect; 5.4、细长缺陷检测,第一步:根据掩膜边缘图连通域宽度与高度的比值是否大于第八设定值或小于第九设定值,其中,第八设定值大于第九设定值,若掩膜边缘图连通域宽度与高度的比值大于第八设定值或小于第九设定值则为细长连通域,第二步:根据连通域最大边缘值与第十设定值对比,当连通域最大边缘值大于第十设定值时,则认为该掩膜边缘图存在细长缺陷;连通域的宽度和高度相比,较大值即为所述连通域最大边缘值;5.4. Slender defect detection, step 1: whether the ratio of the width to the height of the connected domain of the mask edge map is greater than the eighth set value or less than the ninth set value, wherein the eighth set value is greater than the ninth set value, if the ratio of the width to the height of the connected domain of the mask edge map is greater than the eighth set value or less than the ninth set value, it is a slender connected domain, step 2: according to the comparison between the maximum edge value of the connected domain and the tenth set value, when the maximum edge value of the connected domain is greater than the tenth set value, it is considered that the mask edge map has a slender defect; the larger value of the width and height of the connected domain is the maximum edge value of the connected domain; 5.5、检测后储存所有判定为缺陷的掩膜边缘图的中心坐标,并对原始图中对应的坐标点进行打点标记。5.5. After detection, store the center coordinates of all mask edge images that are judged to be defects, and mark the corresponding coordinate points in the original image.
CN202411060113.0A 2024-08-05 2024-08-05 A method for detecting defects in optical wafers Active CN118570213B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202411060113.0A CN118570213B (en) 2024-08-05 2024-08-05 A method for detecting defects in optical wafers

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202411060113.0A CN118570213B (en) 2024-08-05 2024-08-05 A method for detecting defects in optical wafers

Publications (2)

Publication Number Publication Date
CN118570213A CN118570213A (en) 2024-08-30
CN118570213B true CN118570213B (en) 2024-11-05

Family

ID=92469773

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202411060113.0A Active CN118570213B (en) 2024-08-05 2024-08-05 A method for detecting defects in optical wafers

Country Status (1)

Country Link
CN (1) CN118570213B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110070524A (en) * 2019-04-03 2019-07-30 北京东舟技术股份有限公司 A kind of intelligent terminal panel visual fault detection system
CN111221934A (en) * 2020-02-05 2020-06-02 沈阳无距科技有限公司 Method and device for determining operation boundary of unmanned aerial vehicle

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105405142B (en) * 2015-11-12 2019-04-05 冯平 A kind of the side defect inspection method and system of glass panel
CN113298776B (en) * 2021-05-21 2023-01-24 佛山职业技术学院 Method for detecting appearance defects of metal closed water pump impeller
CN114494226B (en) * 2022-02-11 2024-03-12 安徽大学 Method for detecting greasy dirt defect of spinning cake based on graph centroid tracking algorithm
CN117911353A (en) * 2024-01-11 2024-04-19 浙江工业大学 A method for detecting surface defects of circular crystal oscillator

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110070524A (en) * 2019-04-03 2019-07-30 北京东舟技术股份有限公司 A kind of intelligent terminal panel visual fault detection system
CN111221934A (en) * 2020-02-05 2020-06-02 沈阳无距科技有限公司 Method and device for determining operation boundary of unmanned aerial vehicle

Also Published As

Publication number Publication date
CN118570213A (en) 2024-08-30

Similar Documents

Publication Publication Date Title
CN112419250B (en) Digital Image Extraction, Crack Repair and Crack Parameter Calculation Method for Pavement Cracks
CN109978839B (en) Detection method for low-texture defects in wafers
CN113688807B (en) Self-adaptive defect detection method, device, recognition system and storage medium
CN109767445B (en) A high-precision intelligent detection method for PCB defects
CN111474177A (en) Liquid crystal screen backlight foreign matter defect detection method based on computer vision
CN111612781A (en) A screen defect detection method, device and head-mounted display device
CN111539935A (en) Online cable surface defect detection method based on machine vision
CN114792310B (en) A method for detecting Mura defects with blurred edges in LCD screens
CN108629775A (en) A kind of hot high-speed rod surface image processing method
CN114897881B (en) A grain defect detection method based on edge features
US7613355B2 (en) Image processing device and registration data generation method in image processing
CN115100221A (en) Glass defect segmentation method
CN108416766A (en) Visual inspection method for defects of double-side incident light guide plate
CN109102497B (en) High-resolution light guide plate image defect detection method
CN110567965A (en) A method for detecting visual defects on the edge of a smartphone glass cover
CN115311282B (en) Wafer defect detection method based on image enhancement
CN114359414A (en) Lens smudge identification method and device, computer equipment and storage medium
CN119624961B (en) Wafer surface defect detection method, equipment and storage medium based on machine vision
CN114486916A (en) Defect detection method of mobile phone glass cover based on machine vision
CN109272525B (en) A method for detecting white spot defect of light guide plate
CN115760696A (en) Surface scratch detection method
CN118446965A (en) Method, system, equipment and medium for detecting image defects of honeycomb core composite material
CN114938410B (en) Mobile phone screen picture-inspection partition method and system
WO2025139960A1 (en) Image detection method and apparatus, electronic device, and storage medium
CN118570213B (en) A method for detecting defects in optical wafers

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
EE01 Entry into force of recordation of patent licensing contract

Application publication date: 20240830

Assignee: NUCLEAR INDUSTRY YANTAI TONCIN INDUSTRY CO.,LTD.

Assignor: Yantai University

Contract record no.: X2024980033307

Denomination of invention: A method for detecting defects in optical chips

Granted publication date: 20241105

License type: Common License

Record date: 20241209

EE01 Entry into force of recordation of patent licensing contract
EE01 Entry into force of recordation of patent licensing contract

Application publication date: 20240830

Assignee: YANTAI SUNNY HEXING ENVIRONMENT PROTECTION EQUIPMENT Co.,Ltd.

Assignor: Yantai University

Contract record no.: X2025980009037

Denomination of invention: A method for detecting defects in optical chips

Granted publication date: 20241105

License type: Common License

Record date: 20250521

EE01 Entry into force of recordation of patent licensing contract