[go: up one dir, main page]

CN106157303A - A kind of method based on machine vision to Surface testing - Google Patents

A kind of method based on machine vision to Surface testing Download PDF

Info

Publication number
CN106157303A
CN106157303A CN201610487518.1A CN201610487518A CN106157303A CN 106157303 A CN106157303 A CN 106157303A CN 201610487518 A CN201610487518 A CN 201610487518A CN 106157303 A CN106157303 A CN 106157303A
Authority
CN
China
Prior art keywords
threshold segmentation
image
region
noise
area
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201610487518.1A
Other languages
Chinese (zh)
Inventor
黄亮
徐巍
郑天祥
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Gongshang University
Original Assignee
Zhejiang Gongshang 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 Zhejiang Gongshang University filed Critical Zhejiang Gongshang University
Priority to CN201610487518.1A priority Critical patent/CN106157303A/en
Publication of CN106157303A publication Critical patent/CN106157303A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/0002Inspection of images, e.g. flaw detection
    • G06T7/0004Industrial image inspection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10004Still image; Photographic image
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30108Industrial image inspection
    • G06T2207/30136Metal

Landscapes

  • Engineering & Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Image Analysis (AREA)
  • Image Processing (AREA)

Abstract

本发明公开了一种基于机器视觉对表面检测的方法,包括以下步骤:1)采用LED环形灯直接暗视场正面照明方式采集图像;2)使用动态阈值分割法将表面区域中划痕检测的感兴趣区域提取出来;3)再通过使用区域特征、区域形态学对表面区域使用腐蚀运算去掉分割区域中杂点和小的突出物,确保计算上有足够的精度;4)最后使用放射变换、图像平滑、连通区域提取等算法检测出划痕并显示其结果,本方法检测表面缺陷,更好的降低了图像采集过程中,受限于环境光线的干扰,最精细化地分离出了金属缺陷与同为高亮显示的边缘。

The invention discloses a method for surface detection based on machine vision, which comprises the following steps: 1) adopting an LED ring light to directly collect images in the dark field frontal lighting mode; 2) using a dynamic threshold segmentation method to detect scratches in the surface area The region of interest is extracted; 3) Then, by using regional features and regional morphology, use corrosion operations on the surface area to remove noise points and small protrusions in the segmented area to ensure sufficient accuracy in the calculation; 4) Finally, use radiation transformation, Algorithms such as image smoothing and connected region extraction detect scratches and display the results. This method detects surface defects, which better reduces the interference of ambient light during the image acquisition process and separates metal defects in the most refined manner. Same as highlighted edges.

Description

一种基于机器视觉对表面检测的方法A method of surface detection based on machine vision

技术领域technical field

本发明涉及领域,特别涉及一种基于机器视觉对表面检测的方法。The invention relates to the field, in particular to a method for surface detection based on machine vision.

背景技术Background technique

在传统的产品生产过程中,一般情况下对产品的表面缺陷检测是采用人工检测的方法。随着科学技术的不断发展,特别是计算机技术的发展,出现了计算机视觉检测技术。利用这种新技术设计出来的系统不受恶劣环境和主观因素的影响,能快速、准确地检测产品的质量,完成人工无法完成的检测任务。机器视觉检测结合了计算机图像处理和模式识别理论,它综合了计算机技术、数据结构、图像处理,模式识别和软件工程等不同领域的相关知识。In the traditional product production process, the surface defect detection of products generally adopts the method of manual detection. With the continuous development of science and technology, especially the development of computer technology, computer vision detection technology has emerged. The system designed using this new technology is not affected by harsh environments and subjective factors, can quickly and accurately detect the quality of products, and complete detection tasks that cannot be completed manually. Machine vision inspection combines computer image processing and pattern recognition theory, and it integrates relevant knowledge in different fields such as computer technology, data structure, image processing, pattern recognition and software engineering.

在对金属表面检测的过程中,受限于拍摄环境的限制,拍摄出的金属表面划痕在黑色背景区域中显示为高亮,而金属边缘显示也是高亮,就目前的技术很难细致准确通过机器视觉技术做到严格地区分。In the process of detecting the metal surface, due to the limitations of the shooting environment, the scratches on the metal surface are highlighted in the black background area, and the metal edge is also highlighted. It is difficult to be detailed and accurate with the current technology Strict distinction is achieved through machine vision technology.

发明内容Contents of the invention

本发明所要解决的技术问题是提供一种基于机器视觉对表面检测的方法,本方法检测表面缺陷,更好的降低了图像采集过程中,受限于环境光线的干扰;能最精细化地分离出金属缺陷与同为高亮显示的边缘,以解决现有技术中导致的上述多项缺陷。The technical problem to be solved by the present invention is to provide a method for surface inspection based on machine vision. This method detects surface defects, which better reduces the interference of ambient light during the image acquisition process; Metal defects and edges that are also highlighted are used to solve the above-mentioned multiple defects caused by the prior art.

为实现上述目的,本发明提供以下的技术方案:一种基于机器视觉对表面检测的方法,包括以下步骤:In order to achieve the above object, the present invention provides the following technical solutions: a method for surface detection based on machine vision, comprising the following steps:

1)采用LED环形灯直接暗视场正面照明方式采集图像;1) Use the LED ring light to collect images directly in the dark field frontal lighting method;

2)使用动态阈值分割法将表面区域中划痕检测的感兴趣区域提取出来;2) Use the dynamic threshold segmentation method to extract the region of interest for scratch detection in the surface area;

3)再通过使用区域特征、区域形态学对表面区域使用腐蚀运算去掉分割区域中杂点和小的突出物,确保计算上有足够的精度;3) Then use regional features and regional morphology to use corrosion operations on the surface area to remove noise points and small protrusions in the segmented area to ensure sufficient accuracy in the calculation;

4)最后使用放射变换、图像平滑、连通区域提取等算法检测出划痕并显示其结果。4) Finally, use algorithms such as radial transformation, image smoothing, and connected region extraction to detect scratches and display the results.

优选的,所述步骤2)中,图像阈值化的目的是按照灰度级,对像素集合进行一个划分,得到的每个子集形成一个与现实景物相对应的区域,各个区域内部具有一致的属性,而相邻区域布局有这种一致属性,阈值分割操作被定义为Preferably, in the step 2), the purpose of image thresholding is to divide the pixel set according to the gray level, and each subset obtained forms an area corresponding to the real scene, and each area has consistent attributes inside , while the adjacent region layout has this consistent property, the threshold segmentation operation is defined as

S={(r,c)∈Rgmin≤fr,c≤gmax};S={(r,c)∈Rgmin≤f r , c≤gmax};

因此,阈值分割将图像ROIR内灰度值处于某一指定灰度值范围内全部点选到输出区域S中,使gmin=0或gmax=2b-1,如果光照能保持恒定,阈值gmin和gmax能在系统设置时被定选且永远不用被调整.阈值分割分为固定阈值分割和动态阈值分割;Therefore, threshold segmentation selects all the grayscale values in the image ROIR within a specified range of grayscale values into the output area S, so that gmin=0 or gmax=2 b -1, if the illumination can be kept constant, the thresholds gmin and gmax can be selected during system settings and never needs to be adjusted. Threshold segmentation is divided into fixed threshold segmentation and dynamic threshold segmentation;

动态阈值分割将图像与其局部背景进行比较的操作被称为动态阈值分割处理,用fr,c表示输入图像,用gr,c表示平滑后的图像,则对亮物体的动态阈值分割处理如下Dynamic Threshold Segmentation The operation of comparing an image with its local background is called dynamic threshold segmentation processing. Let f r , c represent the input image, and use g r , c to represent the smoothed image. The dynamic threshold segmentation processing for bright objects is as follows

S={(r,c)∈Rfr,c-gr,c≥gdiff};S={(r,c)∈Rf r , cg r , c≥g diff };

而对暗物体的动态阈值分割处理是S={(r,c)∈Rfr,c-gr,c≤-gdiff}。The dynamic threshold segmentation process for dark objects is S={(r, c)∈Rf r , cg r , c≤-g diff }.

优选的,所述步骤3)中,采用的算法为a=R=∑(r,c)∈R1=∑ni-1cei-csi+1;Preferably, in the step 3), the algorithm adopted is a=R=∑(r, c)∈R1=∑ni-1cei-csi+1;

由上式可知,区域的面积a就是区域内的点数R。It can be seen from the above formula that the area a of the region is the number of points R in the region.

优选的,所述步骤4)中,是把数字图像或数字序列中一点的值用该点的一个拎域中各点值的中值代替,让周围的像素值接近真实值,从而消除孤立的噪声点;Preferably, in said step 4), the value of a point in the digital image or digital sequence is replaced by the median value of each point value in a domain of the point, so that the surrounding pixel values are close to the true value, thereby eliminating isolated noise point;

方法是去某种结构的二维滑动模板,将板内像素按照像素值的大小进行排序,生成单调上升(或下降)的为二维数据序列,阈值分割的结果中含有噪声,这并不是最后结果,噪声的处理,通过使用图像平滑来进行抑制。The method is to remove the two-dimensional sliding template of a certain structure, sort the pixels in the board according to the size of the pixel value, and generate a monotonically rising (or falling) two-dimensional data sequence. The result of threshold segmentation contains noise, which is not the last As a result, noise processing is suppressed by using image smoothing.

优选的,所述步骤4)中,检测结果在去除噪声的过程中,所有少于4个像素的连通区域被看作噪声并被去除,为了区分噪声和缺陷,假设噪声是均匀分布的,而同属一个划痕的缺陷是彼此靠近的,因此,可以通过膨胀将缺陷区域中小的缝隙闭合.为了能够计算出连通区域,必须定义合适两个像素应被视为彼此连通。Preferably, in step 4), in the process of removing noise from the detection result, all connected regions with less than 4 pixels are regarded as noise and removed. In order to distinguish noise from defects, it is assumed that the noise is uniformly distributed, and Defects belonging to the same scratch are close to each other, therefore, small gaps in the defect area can be closed by dilation. In order to be able to calculate the connected area, it must be defined that two pixels should be considered as connected to each other.

采用以上技术方案的有益效果是:本发明的方法检测表面缺陷,更好的降低了图像采集过程中,受限于环境光线的干扰,最精细化地分离出了金属缺陷与同为高亮显示的边缘。不仅如此,本方法简单易操作,可行性性非常强。The beneficial effect of adopting the above technical solution is: the method of the present invention detects surface defects, which better reduces the interference of ambient light during the image acquisition process, and most finely separates the metal defects and the same highlight the edge of. Not only that, the method is simple and easy to operate, and the feasibility is very strong.

附图说明Description of drawings

图1是本发明的控制框图。Fig. 1 is a control block diagram of the present invention.

具体实施方式detailed description

下面结合附图详细说明本发明的优选实施方式。Preferred embodiments of the present invention will be described in detail below in conjunction with the accompanying drawings.

图1出示本发明的具体实施方式:一种基于机器视觉对表面检测的方法,包括以下步骤:Fig. 1 shows the specific embodiment of the present invention: a kind of method for surface detection based on machine vision comprises the following steps:

1)采用LED环形灯直接暗视场正面照明方式采集图像;1) Use the LED ring light to collect images directly in the dark field frontal lighting method;

2)使用动态阈值分割法将表面区域中划痕检测的感兴趣区域提取出来;2) Use the dynamic threshold segmentation method to extract the region of interest for scratch detection in the surface area;

3)再通过使用区域特征、区域形态学对表面区域使用腐蚀运算去掉分割区域中杂点和小的突出物,确保计算上有足够的精度;3) Then use regional features and regional morphology to use corrosion operations on the surface area to remove noise points and small protrusions in the segmented area to ensure sufficient accuracy in the calculation;

4)最后使用放射变换、图像平滑、连通区域提取等算法检测出划痕并显示其结果。4) Finally, use algorithms such as radial transformation, image smoothing, and connected region extraction to detect scratches and display the results.

所述步骤2)中,图像阈值化的目的是按照灰度级,对像素集合进行一个划分,得到的每个子集形成一个与现实景物相对应的区域,各个区域内部具有一致的属性,而相邻区域布局有这种一致属性,阈值分割操作被定义为In the step 2), the purpose of image thresholding is to divide the pixel set according to the gray level, and each subset obtained forms an area corresponding to the real scene, and each area has consistent attributes inside, and the corresponding Neighborhood layouts have this consistent property, and the threshold segmentation operation is defined as

S={(r,c)∈Rgmin≤fr,c≤gmax};S={(r,c)∈Rgmin≤f r , c≤gmax};

因此,阈值分割将图像ROIR内灰度值处于某一指定灰度值范围内全部点选到输出区域S中,使gmin=0或gmax=2b-1,如果光照能保持恒定,阈值gmin和gmax能在系统设置时被定选且永远不用被调整;阈值分割分为固定阈值分割和动态阈值分割;Therefore, threshold segmentation selects all the grayscale values in the image ROIR within a specified range of grayscale values into the output area S, so that gmin=0 or gmax=2 b -1, if the illumination can be kept constant, the thresholds gmin and gmax can be selected during system settings and never needs to be adjusted; threshold segmentation is divided into fixed threshold segmentation and dynamic threshold segmentation;

动态阈值分割将图像与其局部背景进行比较的操作被称为动态阈值分割处理,用fr,c表示输入图像,用gr,c表示平滑后的图像,则对亮物体的动态阈值分割处理如下Dynamic Threshold Segmentation The operation of comparing an image with its local background is called dynamic threshold segmentation processing. Let f r , c represent the input image, and use g r , c to represent the smoothed image. The dynamic threshold segmentation processing for bright objects is as follows

S={(r,c)∈Rfr,c-gr,c≥gdiff};S={(r,c)∈Rf r , cg r , c≥g diff };

而对暗物体的动态阈值分割处理是S={(r,c)∈Rfr,c-gr,c≤-gdiff}。The dynamic threshold segmentation process for dark objects is S={(r, c)∈Rf r , cg r , c≤-g diff }.

所述步骤3)中,采用的算法为a=R=∑(r,c)∈R1=∑ni-1cei-csi+1;In the step 3), the algorithm adopted is a=R=∑(r, c)∈R1=∑ni-1cei-csi+1;

由上式可知,区域的面积a就是区域内的点数R。It can be seen from the above formula that the area a of the region is the number of points R in the region.

所述步骤4)中,是把数字图像或数字序列中一点的值用该点的一个拎域中各点值的中值代替,让周围的像素值接近真实值,从而消除孤立的噪声点;In said step 4), the value of one point in the digital image or digital sequence is replaced by the median value of each point value in a domain of the point, so that the surrounding pixel values are close to the true value, thereby eliminating isolated noise points;

方法是去某种结构的二维滑动模板,将板内像素按照像素值的大小进行排序,生成单调上升(或下降)的为二维数据序列,阈值分割的结果中含有噪声,这并不是最后结果,噪声的处理,通过使用图像平滑来进行抑制。The method is to remove the two-dimensional sliding template of a certain structure, sort the pixels in the board according to the size of the pixel value, and generate a monotonically rising (or falling) two-dimensional data sequence. The result of threshold segmentation contains noise, which is not the last As a result, noise processing is suppressed by using image smoothing.

所述步骤4)中,检测结果在去除噪声的过程中,所有少于4个像素的连通区域被看作噪声并被去除,为了区分噪声和缺陷,假设噪声是均匀分布的,而同属一个划痕的缺陷是彼此靠近的,因此,可以通过膨胀将缺陷区域中小的缝隙闭合.为了能够计算出连通区域,必须定义合适两个像素应被视为彼此连通。In the step 4), in the process of removing noise from the detection result, all connected regions with less than 4 pixels are regarded as noise and removed. In order to distinguish noise from defects, it is assumed that the noise is uniformly distributed and belongs to the same division The defects of traces are close to each other, therefore, the small gaps in the defect area can be closed by dilation. In order to be able to calculate the connected area, it must be defined that the appropriate two pixels should be considered as connected to each other.

本发明的方法检测表面缺陷,更好的降低了图像采集过程中,受限于环境光线的干扰。最精细化得分离出了金属缺陷与同为高亮显示的边缘。不仅如此,本方法简单易操作,可行性性非常强。The method of the invention detects surface defects, and better reduces the interference limited by ambient light during the image acquisition process. The most refined result is the separation of metal defects and edges that are also highlighted. Not only that, the method is simple and easy to operate, and the feasibility is very strong.

通过采用LED环形灯直接暗视场正面照明方式采集图像,然后使用动态阈值分割法将表面区域中划痕检测的感兴趣区域提取出来,再通过使用区域特征、区域形态学对表面区域使用腐蚀运算去掉分割区域中杂点和小的突出物,确保计算上有足够的精度,最后使用放射变换、图像平滑、连通区域提取等算法检测出划痕并显示其结果。The image is collected by using the LED ring light direct dark field frontal illumination method, and then the dynamic threshold segmentation method is used to extract the area of interest for scratch detection in the surface area, and then the corrosion operation is used on the surface area by using area features and area morphology Remove noise points and small protrusions in the segmented area to ensure sufficient calculation accuracy, and finally use algorithms such as radial transformation, image smoothing, and connected region extraction to detect scratches and display the results.

照明的方向性通常有两种:漫射和直接照射。There are generally two types of directionality in lighting: diffuse and direct.

漫射时,光在各个方向的强度几乎是一样的。直接照射时,光源发出的光集中在非常窄的空间范围内。本文检测对象是表面划痕,由于此类缺陷检测面积小,划痕不明显等条件,明场照明方式下,难以得到理想的划痕图像。因此本次检测采用LED环形灯直接暗视场照明方式,环形光与物体表面呈非常小的角度,这样可以突出被测物的缺口及凸起,所以划痕、纹理或雕刻文字等被增强,看得更加清晰。When diffused, the intensity of light is nearly the same in all directions. When directly illuminated, the light emitted by the light source is concentrated in a very narrow spatial range. The detection object in this paper is surface scratches. Due to the small detection area of such defects and the inconspicuous scratches, it is difficult to obtain ideal scratch images under bright field illumination. Therefore, this test adopts the direct dark field lighting method of LED ring light. The ring light has a very small angle with the surface of the object, which can highlight the gaps and protrusions of the measured object, so scratches, textures or engraved characters are enhanced. See more clearly.

采集到的图像不能提供图像中包含物体的信息。为了得到图像中的物体信息,必须进行图像分割,图像分割就是将图像划成一些区域,在同一区域内,图像的特征相近;而不同的区域内,图像特征相差较大。图像特征可以是图像本身的特征,如像素的灰度、边缘轮廓和纹理等。图像阈值化分割是一种最常用,同时也是最简单的图像分割方法。图像阈值化的目的是按照灰度级,对像素集合进行一个划分,得到的每个子集形成一个与现实景物相对应的区域,各个区域内部具有一致的属性,而相邻区域布局有这种一致属性。阈值分割操作被定义为The captured image does not provide information about the objects contained in the image. In order to obtain the object information in the image, image segmentation must be performed. Image segmentation is to divide the image into some areas. In the same area, the image features are similar; in different areas, the image features are quite different. Image features can be the features of the image itself, such as the grayscale of pixels, edge contours, and textures. Image thresholding segmentation is one of the most commonly used and simplest image segmentation methods. The purpose of image thresholding is to divide the pixel set according to the gray level, and each subset obtained forms an area corresponding to the real scene. Each area has consistent attributes inside, and the layout of adjacent areas has this consistency. Attributes. The threshold segmentation operation is defined as

S={(r,c)∈Rgmin≤fr,c≤gmax}S={(r,c)∈Rgmin≤fr, c≤gmax}

因此,阈值分割将图像ROIR内灰度值处于某一指定灰度值范围内全部点选到输出区域S中。使gmin=0或gmax=2b-1。如果光照能保持恒定,阈值gmin和gmax能在系统设置时被定选且永远不用被调整。阈值分割分为固定阈值分割和动态阈值分割。动态阈值分割将图像与其局部背景进行比较的操作被称为动态阈值分割处理,用fr,c表示输入图像,用gr,c表示平滑后的图像,则对亮物体的动态阈值分割处理如下Therefore, threshold segmentation selects all the points in the image ROIR whose gray value is within a specified gray value range into the output area S. Let gmin=0 or gmax=2b-1. If the illumination can be kept constant, the thresholds gmin and gmax can be selected during system setup and never need to be adjusted. Threshold segmentation is divided into fixed threshold segmentation and dynamic threshold segmentation. Dynamic threshold segmentation The operation of comparing an image with its local background is called dynamic threshold segmentation processing. Use fr, c to represent the input image, and use gr, c to represent the smoothed image. The dynamic threshold segmentation processing of bright objects is as follows

S={(r,c)∈Rfr,c-gr,c≥gdif}S={(r,c)∈Rfr,c-gr,c≥gdif}

而对暗物体的动态阈值分割处理是And the dynamic threshold segmentation processing for dark objects is

S={(r,c)∈Rfr,c-gr,c≤-gdiff}S={(r,c)∈Rfr,c-gr,c≤-gdiff}

在动态阈值分割处理中,平滑滤波器的尺寸决定了能被分割出来的物体的尺寸。如果滤波器尺寸太小,那么在物体的中心估计出的局部背景将不理想。In dynamic threshold segmentation, the size of the smoothing filter determines the size of the object that can be segmented. If the filter size is too small, the estimated local background at the center of the object will be suboptimal.

经过前面的处理,可以得到从图像中提取到的区域或亚像素精度轮廓。但它们只包含了对分割结果的原始描述。后面还必须从分割结果中选出某些区域或轮廓,作为分割结果中不想要的部分去除。到目前为止,最简单的区域特征是区域的面积:After the previous processing, the region extracted from the image or the sub-pixel precision contour can be obtained. But they only contain raw descriptions of the segmentation results. Later, certain regions or contours must be selected from the segmentation results to be removed as unwanted parts in the segmentation results. By far the simplest region feature is the area of the region:

a=R=∑(r,c)∈R1=∑ni-1cei-csi+1a=R=∑(r,c)∈R1=∑ni-1cei-csi+1

由上式可知,区域的面积a就是区域内的点数R。如果区域用一幅二值图像表示,那么用公式中的第一个求和等式计算区域的面积;如果区域是用行程编码表示的,那么用公式4中的第二个求和等式计算区域的面积。一个区域能够被视为其所有行程的一个并集,而每个行程的面积是极容易计算的。注意第二个累加式的项比第一个累加式的少很多。所以,区域的行程表示法可以使区域面积的计算速度快很多,这个特点对几乎所有的区域特征都适用。It can be seen from the above formula that the area a of the region is the number of points R in the region. If the region is represented by a binary image, then use the first summation equation in the formula to calculate the area of the region; if the region is represented by run-length encoding, then use the second summation equation in formula 4 to calculate The area of the region. A region can be regarded as a union of all its strokes, and the area of each stroke is very easy to calculate. Note that the second accumulator has much fewer terms than the first accumulator. Therefore, the stroke representation of the region can make the calculation of the area much faster, and this feature is applicable to almost all regional features.

通过前面一系列的处理过后,可以对感兴趣区域进行缺陷检测,需要再次使用动态阈值分割操作来检测缺陷,可以用中值滤波器来估计背景。After the previous series of processing, defect detection can be performed on the region of interest, and the dynamic threshold segmentation operation needs to be used again to detect defects, and the median filter can be used to estimate the background.

中值滤波的基本原理是把数字图像或数字序列中一点的值用该点的一个拎域中各点值的中值代替,让周围的像素值接近真实值,从而消除孤立的噪声点。方法是去某种结构的二维滑动模板,将板内像素按照像素值的大小进行排序,生成单调上升(或下降)的为二维数据序列。阈值分割的结果中含有噪声,这并不是最后结果。噪声的处理,通过使用图像平滑来进行抑制。The basic principle of median filtering is to replace the value of a point in a digital image or digital sequence with the median value of each point in a domain of the point, so that the surrounding pixel values are close to the real value, thereby eliminating isolated noise points. The method is to remove a certain structure of the two-dimensional sliding template, sort the pixels in the board according to the size of the pixel value, and generate a monotonically rising (or falling) two-dimensional data sequence. The result of threshold segmentation contains noise, which is not the final result. Noise processing, suppressed by using image smoothing.

通过上述操作,表面划痕检测基本结束,由于在去除噪声的过程中,所有少于4个像素的连通区域被看作噪声并被去除。为了区分噪声和缺陷,假设噪声是均匀分布的,而同属一个划痕的缺陷是彼此靠近的,因此,可以通过膨胀将缺陷区域中小的缝隙闭合。为了能够计算出连通区域,必须定义合适两个像素应被视为彼此连通。以上便是本次检测过程,通过上述操作,就能得到所想要的检测结果。Through the above operations, the detection of surface scratches basically ends, because in the process of removing noise, all connected regions with less than 4 pixels are regarded as noise and removed. In order to distinguish noise and defects, it is assumed that the noise is uniformly distributed, and the defects belonging to the same scratch are close to each other. Therefore, small gaps in the defect area can be closed by dilation. In order to be able to compute connected regions, it must be defined that two pixels should be considered connected to each other. The above is the detection process, and the desired detection result can be obtained through the above operations.

从指定目录中连续读入表面划痕图像的模板,并对图像大小进行设置,使用LED环形光直接暗视场照明所得表面划痕图。Continuously read in the template of the surface scratch image from the specified directory, and set the image size, and use the LED ring light to directly illuminate the surface scratch image in the dark field.

划痕在黑色背景区域中显示为高亮,但是表面的边缘以及表面平面部分中的4个内部正方形的边缘也是高亮的,为了区分划痕与表面的边缘,首先分割出亮的边缘区域。然后从表面的区域中减去分割出的区域,从而将划痕检测的感兴趣区域缩小到相减后的区域。The scratches are highlighted in the black background area, but the edge of the surface and the edges of the four inner squares in the surface plane part are also highlighted. In order to distinguish the scratches from the edge of the surface, the bright edge area is segmented first. The segmented region is then subtracted from the region of the surface, thereby narrowing down the region of interest for scratch detection to the subtracted region.

通过以上处理,下一步来确定需要检测的平面,因此要对感兴趣区域进行提取。需要从分割结果中去掉表面的亮边界和中间4个小的正方形的亮边界。首先必须知道表面在图像中的方向和大小,为得到表面的方向和尺寸,再次使用区域形态学分割出内部的4个正方形。首先使用2次闭运算填充前面分割出的内部正方形边缘上的小空洞,内部正方形边界上有缝隙。Through the above processing, the next step is to determine the plane to be detected, so the region of interest needs to be extracted. It is necessary to remove the bright borders of the surface and the bright borders of the four small squares in the middle from the segmentation results. First of all, the direction and size of the surface in the image must be known. In order to obtain the direction and size of the surface, the 4 inner squares are segmented using the area morphology again. Firstly, two closing operations are used to fill the small holes on the edge of the previously divided internal square, and there are gaps on the boundary of the internal square.

至此,划痕任在分割出的亮的边界区域中。为了能够检测出划痕,需要将划痕从分割结果中分离出来。由于已知内部正方形的边界区域的形状,可以使用合适的结构元素开运算去除划痕。为此生成一个结构元素,由二个轴平行的矩形组成,代表内部正方形的两个对边。So far, the scratches are still in the segmented bright border area. To be able to detect scratches, the scratches need to be separated from the segmentation results. Since the shape of the boundary region of the inner square is known, the scratches can be removed using a suitable structuring element opening operation. For this a structuring element is generated consisting of two rectangles with parallel axes representing the two opposite sides of the inner square.

当在合适的方向生成矩形时,结构元素可以不作旋转。但是需要根据方向变换矩形中心。Structural elements may not be rotated when generating rectangles in the proper orientation. But the center of the rectangle needs to be transformed according to the orientation.

开运算可以用作模板匹配,会返回输入区域内所有与结构元素相匹配的点。正如所期待的,结果含有内部正方形边界。然而结果任含有表面部分外边界,这是因为内正方形到表面边界的距离与内正方形的边长大小一样。为了去掉为边界部分,取开运算的结果和腐蚀后的表面区域交集。The opening operation can be used as template matching, and will return all points in the input area that match the structure elements. As expected, the result contains an inner square boundary. However, the result still contains the outer boundary of the surface part, because the distance from the inner square to the surface boundary is the same as the side length of the inner square. In order to remove the boundary part, the intersection of the result of the open operation and the etched surface area is taken.

这样得到仅含有4个内部正方形边界的区域RegionSquares。最后要检查的表面就是表面区域与内正方形边界的差。This results in the region RegionSquares with only 4 inner square boundaries. The last surface to check is the difference between the surface area and the boundary of the inner square.

在计算差值之前,使用圆形结构元素对表面区域进行腐蚀以去除边界。圆的半径为Border-Width与BorderTolerance的和,这两个值都是事先定义的。半径加上BorderTolerance是为了检测时去掉与边界非常靠近的像素,这些像素灰度会受到边界的影响,可能被错误地判断缺陷。同理,代表内正方形边界区域也要膨胀一些。得到的含有表面检测平面的感兴趣区域Re-gionSurface。注意表面白色边界和内正方形白色边界没有包含在区域中。The surface area is eroded using circular structuring elements to remove boundaries before computing the difference. The radius of the circle is the sum of Border-Width and BorderTolerance, both values are defined in advance. The radius plus BorderTolerance is to remove pixels that are very close to the border during detection. The grayscale of these pixels will be affected by the border and may be misjudged as a defect. In the same way, the boundary area of the representative inner square should also be inflated. The resulting region of interest Re-gionSurface containing the surface detection plane. Note that the surface white border and the inner square white border are not included in the region.

经过上面的处理,现在可以对感兴趣区域进行缺陷检测了:再次使用动态阈值分割操作来检测缺陷,此时可以用中值滤波器来估计背景。基于已知的最大划痕宽度ScratchWidthMax,利用Scratch-WidthMax作为中值滤波器半径去除所有划痕。由于采用暗视场正面照明,划痕在图像中为亮的区域,可以容易地使用预先定义的ScratchGrayDiffMin作为阈值分割。After the above processing, defect detection can now be performed on the region of interest: the dynamic threshold segmentation operation is used again to detect defects, and the median filter can be used to estimate the background at this time. Based on the known maximum scratch width ScratchWidthMax, use Scratch-WidthMax as the median filter radius to remove all scratches. Due to the darkfield frontal illumination, scratches appear as bright areas in the image, which can be easily segmented using the predefined ScratchGrayDiffMin as a threshold.

在这种情况下,所有少于4个像素的连通区域被看做噪声并被去除。并不是所有噪声都完全被去除了,进一步提高阈值可能会同时去除部分不连续的缺陷区域。为了区分噪声和缺陷,假设噪声是均匀分布的,而同属一个划痕的缺陷是彼此靠近的,因此,可以通过膨胀将缺陷区域中小的缝隙闭合。原来断开的缺陷经过膨胀后连在一起了,对膨胀后的区域重新计算连通区域。为了得到缺陷的原始形状,取未膨胀前的原始区域与连通区域的交集。In this case, all connected regions with less than 4 pixels are considered as noise and removed. Not all the noise is completely removed, further increasing the threshold may remove some discontinuous defect regions at the same time. In order to distinguish noise and defects, it is assumed that the noise is uniformly distributed, and the defects belonging to the same scratch are close to each other. Therefore, small gaps in the defect area can be closed by dilation. The original disconnected defects are connected together after expansion, and the connected area is recalculated for the expanded area. In order to get the original shape of the defect, the intersection of the original area before expansion and the connected area is taken.

注意交集运算不影响各成分的连通性,于是,通过膨胀仅增加了连通区域的轮廓。最后选出所有比预定最小划痕大的区域。Note that the intersection operation does not affect the connectivity of each component, so only the outline of the connected region is increased by dilation. Finally, all regions larger than the predetermined minimum scratches are selected.

以上所述的仅是本发明的优选实施方式,应当指出,对于本领域的普通技术人员来说,在不脱离本发明创造构思的前提下,还可以做出若干变形和改进,这些都属于本发明的保护范围。The above is only the preferred embodiment of the present invention, it should be pointed out that for those skilled in the art, without departing from the inventive concept of the present invention, some modifications and improvements can also be made, and these all belong to the present invention. protection scope of the invention.

Claims (5)

1. one kind based on the machine vision method to Surface testing, it is characterised in that comprise the following steps:
1) LED circular lamp direct dark field frontlighting mode is used to gather image;
2) dynamic threshold segmentation method is used by the region of interesting extraction of scratch detection in region, surface out;
3) again by use provincial characteristics, regional morphology region, surface use erosion operation is removed in cut zone miscellaneous point and Little outthrust, it is ensured that have enough precision in calculating;
4) radiation conversion, image smoothing, connected region is finally used to extract scheduling algorithm and detect cut and show its result.
Method based on machine vision to Surface testing the most according to claim 1, it is characterised in that described step 2) In, the purpose of image threshold is according to gray level, and collection of pixels carries out a division, and each subset obtained forms one The region corresponding with real-world scene, has consistent attribute, and adjacent area layout has this consistent genus inside regional Property, Threshold segmentation operation is defined as
S={ (r, c) ∈ Rgmin≤fr, c≤gmax};
Therefore, in gray value in image ROIR is in a certain appointment intensity value ranges by Threshold segmentation, all point chooses output area In S, make gmin=0 or gmax=2b-1, if illumination can keep constant, threshold value gmin and gmax can be determined when system is arranged Select and never with being adjusted;Threshold segmentation is divided into fixed threshold segmentation and dynamic threshold segmentation;
The operation that image and its local background are compared by dynamic threshold segmentation is referred to as dynamic threshold segmentation and processes, and uses fr, c Represent input picture, use gr, c represents the image after smoothing, then processes as follows to the dynamic threshold segmentation of bright object
S={ (r, c) ∈ Rfr, c-gr, c >=gdiff};
And the dynamic threshold segmentation process to dark object is S={ (r, c) ∈ Rfr, c-gr, c≤-gdiff}。
Method based on machine vision to Surface testing the most according to claim 1, it is characterised in that described step 3) In, the algorithm of employing is a=R=∑ (r, c) ∈ R1=∑ ni-1cei-csi+1;
From above formula, the area a in region is exactly the R that counts in region.
Method based on machine vision to Surface testing the most according to claim 1, it is characterised in that described step 4) In, it is to carry the Mesophyticum of each point value in territory one of this point of the value of any in digital picture or Serial No. to replace, allows around Pixel value close to actual value, thus eliminate isolated noise spot;
Method is the two-dimentional sleiding form of certain structure, pixel in plate is ranked up according to the size of pixel value, generates single Adjust rise (or decline) for 2-D data sequence, containing noise in the result of Threshold segmentation, this is not end product, noise Process, by use image smoothing suppress.
Method based on machine vision to Surface testing the most according to claim 1, it is characterised in that described step 4) In, testing result is during removing noise, and all connected regions being less than 4 pixels are counted as noise and are removed, for Differentiation noise and defect, it is assumed that noise is equally distributed, and the defect belonging to a cut together is close to each other, therefore, By expanding, gap medium and small for defect area can be closed;In order to calculate connected region, it is necessary to define suitable two Pixel should be considered to communicate with each other.
CN201610487518.1A 2016-06-24 2016-06-24 A kind of method based on machine vision to Surface testing Pending CN106157303A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610487518.1A CN106157303A (en) 2016-06-24 2016-06-24 A kind of method based on machine vision to Surface testing

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610487518.1A CN106157303A (en) 2016-06-24 2016-06-24 A kind of method based on machine vision to Surface testing

Publications (1)

Publication Number Publication Date
CN106157303A true CN106157303A (en) 2016-11-23

Family

ID=57349525

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610487518.1A Pending CN106157303A (en) 2016-06-24 2016-06-24 A kind of method based on machine vision to Surface testing

Country Status (1)

Country Link
CN (1) CN106157303A (en)

Cited By (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107255641A (en) * 2017-06-06 2017-10-17 西安理工大学 A kind of method that Machine Vision Detection is carried out for GRIN Lens surface defect
CN107358598A (en) * 2017-05-24 2017-11-17 上海视马艾智能科技有限公司 A kind of scratch detection method and apparatus
CN107358597A (en) * 2017-05-24 2017-11-17 上海视马艾智能科技有限公司 A kind of glue point method of inspection and device
CN107977960A (en) * 2017-11-24 2018-05-01 南京航空航天大学 A kind of car surface scratch detection algorithm based on improved SUSAN operators
CN108459030A (en) * 2018-02-08 2018-08-28 东华大学 One kind being applied to non-planar plastic smooth surface flaw on-line measuring device and method
CN109374638A (en) * 2018-12-18 2019-02-22 王章飞 A kind of wood floor surface detection device and its detection method based on machine vision
CN109829904A (en) * 2019-01-29 2019-05-31 京东方科技集团股份有限公司 Detect the method, apparatus of dust, electronic equipment, readable storage medium storing program for executing on screen
CN110021012A (en) * 2019-03-27 2019-07-16 安徽皓视光电科技有限公司 Mobile lens sight glass defect inspection method based on machine vision technique
CN110514665A (en) * 2019-09-03 2019-11-29 博科视(苏州)技术有限公司 A kind of detection method of electronic product plastic shell scratch defects
CN111060526A (en) * 2018-10-16 2020-04-24 苏州微微视视觉科技有限公司 Method for detecting surface defects of metal target based on picture processing
CN111223080A (en) * 2020-01-02 2020-06-02 长江存储科技有限责任公司 Wafer detection method and device, electronic equipment and storage medium
CN112508937A (en) * 2020-12-22 2021-03-16 北京百度网讯科技有限公司 Method and device for generating scratch data, electronic equipment and storage medium
WO2021168733A1 (en) * 2020-02-27 2021-09-02 京东方科技集团股份有限公司 Defect detection method and apparatus for defect image, and computer-readable storage medium
CN115359044A (en) * 2022-10-18 2022-11-18 南通群富金属科技有限公司 Metal part surface scratch detection method based on image enhancement
CN115575321A (en) * 2022-09-26 2023-01-06 广州惠中木业有限公司 Wood board surface defect detection system and method based on mechanical vision

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102759528A (en) * 2012-07-09 2012-10-31 陕西科技大学 Method for detecting diseases of crop leaves
CN103700116A (en) * 2012-09-27 2014-04-02 中国航天科工集团第二研究院二O七所 Background modeling method for movement target detection
CN105261037A (en) * 2015-10-08 2016-01-20 重庆理工大学 Moving object detection method capable of automatically adapting to complex scenes
CN105388162A (en) * 2015-10-28 2016-03-09 镇江苏仪德科技有限公司 Raw material silicon wafer surface scratch detection method based on machine vision

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102759528A (en) * 2012-07-09 2012-10-31 陕西科技大学 Method for detecting diseases of crop leaves
CN103700116A (en) * 2012-09-27 2014-04-02 中国航天科工集团第二研究院二O七所 Background modeling method for movement target detection
CN105261037A (en) * 2015-10-08 2016-01-20 重庆理工大学 Moving object detection method capable of automatically adapting to complex scenes
CN105388162A (en) * 2015-10-28 2016-03-09 镇江苏仪德科技有限公司 Raw material silicon wafer surface scratch detection method based on machine vision

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
何小利等: "基于机器视觉技术的物体表面缺陷检测", 《洛阳师范学院学报》 *
刘泽等: "钢轨表面缺陷检测机器视觉系统的设计", 《电子测量与仪器学报》 *

Cited By (20)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107358598A (en) * 2017-05-24 2017-11-17 上海视马艾智能科技有限公司 A kind of scratch detection method and apparatus
CN107358597A (en) * 2017-05-24 2017-11-17 上海视马艾智能科技有限公司 A kind of glue point method of inspection and device
CN107255641B (en) * 2017-06-06 2019-11-22 西安理工大学 A method of machine vision inspection for surface defects of self-focusing lens
CN107255641A (en) * 2017-06-06 2017-10-17 西安理工大学 A kind of method that Machine Vision Detection is carried out for GRIN Lens surface defect
CN107977960A (en) * 2017-11-24 2018-05-01 南京航空航天大学 A kind of car surface scratch detection algorithm based on improved SUSAN operators
CN107977960B (en) * 2017-11-24 2021-08-06 南京航空航天大学 A Car Surface Scratch Detection Algorithm Based on Improved SUSAN Operator
CN108459030A (en) * 2018-02-08 2018-08-28 东华大学 One kind being applied to non-planar plastic smooth surface flaw on-line measuring device and method
CN111060526A (en) * 2018-10-16 2020-04-24 苏州微微视视觉科技有限公司 Method for detecting surface defects of metal target based on picture processing
CN109374638A (en) * 2018-12-18 2019-02-22 王章飞 A kind of wood floor surface detection device and its detection method based on machine vision
CN109374638B (en) * 2018-12-18 2022-01-18 深圳市鼎源检测技术有限公司 Wood floor surface detection device based on machine vision and detection method thereof
CN109829904A (en) * 2019-01-29 2019-05-31 京东方科技集团股份有限公司 Detect the method, apparatus of dust, electronic equipment, readable storage medium storing program for executing on screen
CN110021012A (en) * 2019-03-27 2019-07-16 安徽皓视光电科技有限公司 Mobile lens sight glass defect inspection method based on machine vision technique
CN110021012B (en) * 2019-03-27 2023-09-26 安徽皓视光电科技有限公司 Mobile phone lens window glass defect detection method based on machine vision technology
CN110514665A (en) * 2019-09-03 2019-11-29 博科视(苏州)技术有限公司 A kind of detection method of electronic product plastic shell scratch defects
CN111223080A (en) * 2020-01-02 2020-06-02 长江存储科技有限责任公司 Wafer detection method and device, electronic equipment and storage medium
WO2021168733A1 (en) * 2020-02-27 2021-09-02 京东方科技集团股份有限公司 Defect detection method and apparatus for defect image, and computer-readable storage medium
CN112508937A (en) * 2020-12-22 2021-03-16 北京百度网讯科技有限公司 Method and device for generating scratch data, electronic equipment and storage medium
CN115575321A (en) * 2022-09-26 2023-01-06 广州惠中木业有限公司 Wood board surface defect detection system and method based on mechanical vision
CN115575321B (en) * 2022-09-26 2023-07-21 广州惠中木业有限公司 Wood board surface defect detection system and method based on machine vision
CN115359044A (en) * 2022-10-18 2022-11-18 南通群富金属科技有限公司 Metal part surface scratch detection method based on image enhancement

Similar Documents

Publication Publication Date Title
CN106157303A (en) A kind of method based on machine vision to Surface testing
CN115082683B (en) Injection molding defect detection method based on image processing
CN109961049B (en) Cigarette brand identification method under complex scene
CN109242853B (en) An intelligent detection method for PCB defects based on image processing
CN105445277B (en) A kind of FPC surface quality Visual intelligent detection method
CN103439338B (en) Film defects sorting technique
CN104715238B (en) A kind of pedestrian detection method based on multi-feature fusion
CN113781402A (en) Chip surface scratch defect detection method, device and computer equipment
CN116503388B (en) Defect detection method, device and storage medium
TW201519162A (en) Method, electronic device and medium for adjusting depth values
CN112734761B (en) Industrial product image boundary contour extraction method
CN107610085A (en) A kind of welding point defect detecting system based on computer vision
CN107154044B (en) Chinese food image segmentation method
CN106447673A (en) Chip pin extraction method under non-uniform illumination condition
CN103971367B (en) Hydrologic data image segmenting method
CN107274452B (en) Automatic detection method for acne
JP6665550B2 (en) Tire contact surface analysis device, tire contact surface analysis system, and tire contact surface analysis method
CN110263778A (en) A kind of meter register method and device based on image recognition
CN114723728A (en) Method and system for detecting CD line defects of silk screen of glass cover plate of mobile phone camera
CN106666767A (en) Method for efficiently shelling sunflower seeds on basis of vision technologies
CN103093241B (en) Based on the remote sensing image nonuniformity cloud layer method of discrimination of homogeneity process
TWI498830B (en) A method and system for license plate recognition under non-uniform illumination
CN105869147B (en) A kind of amblyopia visual aid stray light recognition methods
JP2004296592A (en) Defect classification equipment, defect classification method, and program
CN110276260B (en) A product detection method based on depth camera

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20161123

RJ01 Rejection of invention patent application after publication