WO2017113422A1 - 图像的斑点处理方法 - Google Patents

图像的斑点处理方法 Download PDF

Info

Publication number
WO2017113422A1
WO2017113422A1 PCT/CN2015/100352 CN2015100352W WO2017113422A1 WO 2017113422 A1 WO2017113422 A1 WO 2017113422A1 CN 2015100352 W CN2015100352 W CN 2015100352W WO 2017113422 A1 WO2017113422 A1 WO 2017113422A1
Authority
WO
WIPO (PCT)
Prior art keywords
point
spot
contour
pixel
parent
Prior art date
Application number
PCT/CN2015/100352
Other languages
English (en)
French (fr)
Inventor
韩琨
Original Assignee
深圳配天智能技术研究院有限公司
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 深圳配天智能技术研究院有限公司 filed Critical 深圳配天智能技术研究院有限公司
Priority to PCT/CN2015/100352 priority Critical patent/WO2017113422A1/zh
Priority to CN201580079762.8A priority patent/CN107615333B/zh
Publication of WO2017113422A1 publication Critical patent/WO2017113422A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis

Definitions

  • the present invention relates to the field of machine vision technology, and in particular to a speckle processing method for an image.
  • the technical problem to be solved by the present invention is to provide a speckle processing method for an image, which can accurately detect whether a target has a defect if the color of the speckle is not given.
  • a technical solution adopted by the present invention is to provide a method for processing a speckle of an image, the method comprising: binarizing a grayscale image to obtain a binary image; and performing a connected domain on the binary image Marking to obtain a plurality of spots filled with different mark values, and recording the start point of the spot and the area of the spot; tracking the outline of the spot by the start point of the spot to determine the parent-child relationship between the outlines; and contouring according to the parent-child relationship Organize into a topology; calculate the characteristics of the spots based on the topology.
  • the step of performing the connected domain labeling on the binary image includes: acquiring a starting point of the spot as a seed point; filling a pixel of the same color connected to the seed point on the current scan line where the seed point is located to be corresponding to the spot Mark the value and count the current scan line where the seed point is located to be connected to the seed point Number of pixels of the same color; determining whether there is a pixel area of the same color and not filled with the filled pixel on the current scan line on the adjacent scan line of the current scan line; if present and filled A pixel area of the same color and not filled by the pixel point extracts a pixel point from the pixel area as a seed point, and returns a pixel of the same color that is connected to the seed point on the current scan line where the seed point is located.
  • the step is to mark the value corresponding to the spot, and count the number of pixels of the same color that will be connected to the seed point on the current scan line where the seed point is located.
  • the step of recording the area of the spot includes: obtaining an area of the pixel point corresponding to the seed point, and counting the number of all the pixels of the same color connected to the seed point to obtain the area of the spot.
  • the step of acquiring the starting point of the spot includes: scanning the pixel points of the binary image one by one, and determining that the currently scanned pixel point is the starting point of the spot when determining that the currently scanned pixel point is not filled and is different from the scanned pixel point color. .
  • the step of tracking the contour of the spot by the start point of the spot and determining the parent-child relationship between the contours includes: using the starting point of the spot as the contour point; determining the value of the adjacent pixel point relative to the predetermined position of the contour point and Whether the marker values of the contour points are the same; if they are not the same, it indicates that the contour of the spot where the contour point is located has a parent-child relationship with the contour of the spot where the adjacent pixel points of the predetermined position are located.
  • the step of tracking the contour of the spot by the start point of the spot, and determining the parent-child relationship between the contours further includes: if not, determining whether the flag value of other adjacent pixel points around the contour point is further determined along the predetermined direction Same as the marker value of the contour point, and the other adjacent pixel point with the same marker value as the contour point is used as the contour point, and returns the marker value and the contour point of the adjacent pixel point which is determined with respect to the predetermined position of the contour point.
  • the steps to mark the values are the same.
  • the predetermined direction is a clockwise direction.
  • the step of tracking the contour of the spot by the start point of the spot and determining the parent-child relationship between the contours further includes: if the same, the adjacent pixel points of the predetermined position are used as contour points, and returning to determine the predetermined position relative to the contour point. The step of whether the tag value of the adjacent pixel is the same as the tag value of the contour point.
  • the step of organizing the contour into a topology according to the parent-child relationship includes: organizing the starting point of the spot into a topology according to the parent-child relationship.
  • the step of calculating the feature of the spot according to the topology confirming whether the selected spot is filled with holes; if performing hole filling, acquiring the sub-profile of the contour of the selected spot; the area and sub-profile of the selected spot The area of the corresponding spot is summed to obtain the area of the selected spot after the hole is filled.
  • the image processing method of the image of the present invention includes: binarizing the grayscale image to obtain a binary image; and performing connected domain marking on the binary image to Obtaining a plurality of spots filled with different marker values, and recording the start point of the spots and the area of the spots; tracking the contours of the spots by the start point of the spots to determine the parent-child relationship between the contours; organizing the contours into a topology according to the parent-child relationship Structure; calculates the characteristics of the spot based on the topology.
  • the feature of each spot can be calculated according to the topology structure organized by the outline of the spot, and it is possible to accurately detect whether the target has a defect and satisfy the user's request.
  • FIG. 1 is a schematic flow chart of a speckle processing method of an image of the present invention
  • FIG. 2 is a schematic flow chart of a sub-step of step S101 in FIG. 1;
  • Figure 3 is a schematic illustration of a spot filled with different marker values of the present invention.
  • FIG. 4 is a schematic flow chart of a sub-step of step S103 in FIG. 1;
  • FIG. 5 is a schematic flow chart of the sub-steps of step S105 in FIG. 1.
  • FIG. 1 is a schematic flow chart of a speckle processing method for an image of the present invention. The method includes the following steps:
  • Step S101 Perform binarization processing on the image to obtain a binary image.
  • Step S102 Perform a connected domain mark on the binary image to obtain a plurality of spots filled with different mark values, and record the start point of the spot and the area of the spot.
  • performing the connectivity domain marking on the binary image specifically includes the following sub-steps:
  • Step S1011 Obtain the starting point of the spot and use it as a seed point.
  • step S1011 the pixel points of the binary image are scanned one by one, and the currently scanned pixel point is determined. When not filled and different from the scanned pixel color, it is determined that the currently scanned pixel is the starting point of the spot. It should be understood that when scanning the pixels of the binary image, it may be scanning one by one by row, or by column by column or the like. For example, the binarized pixels are scanned line by line, such as when filling white pixels, when scanning to the next black pixel, the black pixel and the filled white pixel The colors are different, so you can determine the black pixel point as the starting point of the spot.
  • Step S1012 Fill the pixel of the same color connected to the seed point with the mark value corresponding to the spot on the current scan line where the seed point is located, and count the same color that is connected to the seed point on the current scan line where the seed point is located. The number of pixels.
  • the pixel points of the same color connected to the seed point may be filled into the tag values corresponding to the spots one by one row by row, and the same color of the current color on the current scan line where the seed point is connected with the seed point is counted row by row.
  • the number of pixels It can also be said that the pixel points of the same color connected to the seed point are filled into the tag values corresponding to the spots one by one, and the pixel points of the same color that will be connected to the seed point on the current scan line where the seed point is located are counted column by column. Number.
  • the tag value may be a numerical value, a symbol with an identifier, or other tag values. It should be understood that the tag value is mainly used to distinguish different spots, and can be specifically set according to actual needs.
  • Step S1013 judging whether there is a pixel area of the same color and not filled with the filled pixel point on the current scan line on the adjacent scan line of the current scan line.
  • step S1014 is performed: extracting a pixel point from the pixel area as a seed point, and returning to On the current scan line where the seed point is located, the pixel of the same color that is connected to the seed point is filled with the marker value corresponding to the spot, and the pixel of the same color that is connected to the seed point on the current scan line where the seed point is located is counted. The number of steps returns to step S1012.
  • step S1014 it is preferred to select each pixel region adjacent to the endpoint of the filled interval
  • One of the two pixels is used as a seed point, or two of the two pixel points adjacent to the end point of the filled interval are used as seed points.
  • any one or more of the adjacent pixel points of the filled interval may be selected as the seed point.
  • step S1015 If there is no pixel area of the same color and not filled in the adjacent scan line of the current scan line, it is indicated that the filling is completed, and step S1015 is ended. After step S1015, the remaining pixels of the binary image are scanned one by one to obtain the starting point of the next spot, and the above steps are repeatedly performed in sequence, as shown in FIG. 3, and finally the spots are marked as numerical values, including the tag values of 3, 4 , 5 spots.
  • performing the connectivity domain labeling on the binary images one by one in a row includes:
  • step (2) (4) and determine a new seed point: in the interval [x1, x2], check the pixels on the two scan lines adjacent to the upper and lower sides of the current scan line y. If there are non-boundary, unfilled pixels, the rightmost pixel of each interval is pushed onto the stack as a seed point, and the process returns to step (2).
  • the step of recording the area of the spot comprises: obtaining the area of the pixel point corresponding to the seed point, and counting the number of all the pixels of the same color connected to the seed point to obtain the area of the spot. For example, if the number of pixels of the same color that will be connected to the seed point on the current scan line where the seed point is located is 10, the same color of the adjacent scan line on the adjacent scan line of the current scan line is connected to the seed point. The number of pixels is 50, and the area of the spot is 60 pixels.
  • Step S103 Tracking the outline of the spot by the start point of the spot to determine the parent-child relationship between the outlines.
  • step S103 includes the following sub-steps:
  • Step S1031 The starting point of the spot is taken as the contour point. As shown in the following figure, P is used as the contour point, where P may be the starting point of the spot, and P may not be the starting point of the spot.
  • Step S1032 It is judged whether the mark value of the adjacent pixel point with respect to the predetermined position of the contour point is the same as the mark value of the contour point.
  • step S1032 it is judged whether or not the flag value of the eight adjacent pixel points around the contour point is the same as the flag value of the contour point.
  • adjacent pixels on the right side of each contour point P are 0, and adjacent pixel points around each contour point are sequentially numbered in a clockwise direction. It should be understood that the present invention is not limited to having 0 adjacent pixels on the right side of each contour point P, and a specific setting may be designed according to time.
  • the predetermined position is the upper right corner position of the current contour point P, such as the pixel number numbered 7, where the contour point P is located and numbered 7
  • the pixels are in different outlines.
  • the current contour point P is the starting point of the spot, it is judged whether the mark value of the adjacent pixel point with respect to the predetermined position of the contour point P is the same as the mark value of the contour point P, and if so, the contour point is input at the P point, otherwise
  • the hour hand 7-0-1-2-3-4-5-6 searches this order until it encounters the next contour point, labeled P1.
  • the predetermined position is determined by the following formula:
  • Y is the predetermined position and X is the position number of the previous contour point of the current contour point relative to the current contour point.
  • P is the starting point of the spot, that is, P is a point on the contour path
  • P is a point on the contour path
  • point P starts from the position of (X+2) mod8 and looks for the next path. That is, Y represents the meaning of X plus 2 divided by 8 modulo, which is reflected in the position where the image is 2 clockwise from P-1, as in the above-mentioned nine-square graph, P-1 is 4, from P -1 Click the number of clockwise 2 grids to 6.
  • step S1033 is performed: indicating that the contour of the spot where the contour point is located and the adjacent pixel point of the predetermined position are located
  • the outline of the spot has a parent-child relationship.
  • the parent contour of the contour of the spot is determined, that is, the contour of the spot where the contour point is located is the adjacent pixel of the predetermined position.
  • the parent outline of the outline of the spot where the point is located when it is determined that the mark value of the adjacent pixel point with respect to the predetermined position of the contour point is not the same as the mark value of the contour point, the outline of the spot where the contour point is located may be directly obtained as the predetermined position.
  • the parent contour of the outline of the spot where the adjacent pixel is located no longer needs to continue tracking, just trace to a point.
  • the outline in which the pixel number numbered 7 is located is the parent outline of the outline in which the outline point P is located.
  • the outline of the spot with the mark value of 3 is the parent of the outline of the spot with the mark value of 4.
  • the outline of the spot with the mark value of 4 is the parent of the outline of the spot with the mark value of 5.
  • the outline of the spot having a small mark value is the parent outline of the outline of the spot having the large mark value
  • the outline of the spot having a large mark value may be the parent outline of the outline of the spot having a small mark value, according to actual needs.
  • other markers can be used to distinguish between parent-child relationships between profiles.
  • its parent outline is not considered.
  • Step S1034 determining whether the mark value of other adjacent pixel points around the contour point is the same as the mark value of the contour point along the predetermined direction, and using the other adjacent pixel point having the same mark value as the contour point as the contour point. And returning to the step of judging whether the flag value of the adjacent pixel point with respect to the predetermined position of the contour point is the same as the flag value of the contour point.
  • step S1035 is performed: the adjacent pixel position of the predetermined position is taken as the contour point, and the determination is made with respect to the predetermined position of the contour point. The step of whether the tag value of the adjacent pixel is the same as the tag value of the contour point.
  • Step S104 Organize the contour into a topology according to the parent-child relationship.
  • step S104 all sub-contours corresponding to each parent contour are composed into a topology.
  • the contour of the spot with a mark value of 3 includes a sub-profile of a spot having a mark value of 4 and a spot having a mark value of 5. profile.
  • the starting point of the spot is organized into a topology according to the parent-child relationship.
  • Step S105 Calculate the feature of the spot according to the topology.
  • step S105 includes the following sub-steps:
  • Step S1051 It is confirmed whether or not the hole is filled in the selected spot.
  • Step S1052 If hole filling is performed, the sub-contour of the contour of the selected spot is acquired.
  • Step S1053 The area of the selected spot is summed with the area of the spot corresponding to the sub-contour, and the area of the selected spot after the hole is filled is obtained.
  • the present invention is not limited to the area in which the spots are acquired, and may be other features of the spots, such as the number of spots, including the number of spots larger than the predetermined area.
  • the image processing method of the image of the present invention includes: binarizing the grayscale image to obtain a binary image; performing a connected domain labeling on the binary image to obtain a plurality of spots filled with different marker values. And recording the starting point of the spot and the area of the spot; tracking the outline of the spot by the start point of the spot to determine the parent-child relationship between the contours; organizing the contour into a topological structure according to the parent-child relationship; calculating the feature of the spot according to the topological structure.
  • the feature of each spot can be calculated according to the topology structure organized by the outline of the spot, and it is possible to accurately detect whether the target has a defect and satisfy the user's request.

Landscapes

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

Abstract

本发明公开了一种图像的斑点处理方法,该方法包括:对灰度图像进行二值化,以得到二值图像;对二值图像进行连通域标记,以得到多个填充有不同标记值的斑点,并记录斑点的起点以及斑点的面积;通过斑点的起点对斑点的轮廓进行跟踪,以判断各轮廓之间的父子关系;根据父子关系将轮廓组织成拓扑结构;根据拓扑结构计算斑点的特征。通过上述方式,本发明在斑点的颜色未给定的情况下,能够根据斑点的轮廓所组织成的拓扑结构计算每个斑点的特征,准确检测目标是否存在缺陷。

Description

图像的斑点处理方法 技术领域
本发明涉及机器视觉技术领域,特别是涉及一种图像的斑点处理方法。
背景技术
在工业检测中,常常需要提取感兴趣的目标,并对目标区域的特征进行分析,以检测目标是否存在缺陷等。一般情况下,提取斑点可以很好的完成上述任务。
在传统方法中,通常需要用户对斑点的颜色进行限制,以便给定用户感兴趣的目标,并在给定斑点的颜色情况下确定斑点的轮廓之间的拓扑结构,从而能够检测到目标是否存在缺陷等。其中,一种常用的确定轮廓之间的层级关系的方式一般采用编码的思想,给不同的轮廓赋予不同的整数值,从而我们就可以根据整数值确定轮廓之间的层次关系。
然而,上述确定轮廓之间的层次关系的方式只适用于给定斑点的颜色,且从斑点的轮廓之间的拓扑结构所计算出的斑点的特征不能准确地检测目标是否存在缺陷,远远达不到用户的要求。
综上所述,有必要提供一种图像的斑点处理方法以解决上述问题。
发明内容
本发明主要解决的技术问题是提供一种图像的斑点处理方法,在斑点的颜色未给定的情况下,能够准确地检测目标是否存在缺陷。
为解决上述技术问题,本发明采用的一个技术方案是:提供一种图像的斑点处理方法,该方法包括:对灰度图像进行二值化,以得到二值图像;对二值图像进行连通域标记,以得到多个填充有不同标记值的斑点,并记录斑点的起点以及斑点的面积;通过斑点的起点对斑点的轮廓进行跟踪,以判断各轮廓之间的父子关系;根据父子关系将轮廓组织成拓扑结构;根据拓扑结构计算斑点的特征。
其中,对二值图像进行连通域标记的步骤包括:获取斑点的起点,并作为种子点;在种子点所在的当前扫描线上将与种子点连通的相同颜色的像素点填充成与斑点对应的标记值,并统计种子点所在的当前扫描线上将与种子点连通 的相同颜色的像素点的个数;在当前扫描线的相邻扫描线上判断是否存在与当前扫描线上的已填充像素点连通的相同颜色且未被填充的像素区域;若存在与已填充像素点连通的相同颜色且未被填充的像素区域,则从像素区域中提取一像素点作为种子点,并返回在种子点所在的当前扫描线上将与种子点连通的相同颜色的像素点填充成与斑点对应的标记值,并统计种子点所在的当前扫描线上将与种子点连通的相同颜色的像素点的个数的步骤。
其中,记录斑点的面积的步骤包括:获取种子点对应的像素点的面积,统计所有与种子点连通的相同颜色的像素点的个数,以获得斑点的面积。
其中,获取斑点的起点的步骤包括:逐个扫描二值图像的像素点,在判断当前扫描的像素点未被填充且与已扫描的像素点颜色不同时,确定当前扫描的像素点为斑点的起点。
其中,通过斑点的起点对斑点的轮廓进行跟踪,并判断各轮廓之间的父子关系的步骤包括:将斑点的起点作为轮廓点;判断相对于轮廓点预定位置的相邻像素点的标记值与轮廓点的标记值是否相同;若不相同,则表示轮廓点所处的斑点的轮廓与预定位置的相邻像素点所处的斑点的轮廓存在父子关系。
其中,通过斑点的起点对斑点的轮廓进行跟踪,并判断各轮廓之间的父子关系的步骤进一步包括:若不相同,则进一步沿预定方向判断轮廓点周围的其他相邻像素点的标记值是否与轮廓点的标记值相同,并将第一个与轮廓点的标记值相同的其他相邻像素点作为轮廓点,并返回判断相对于轮廓点预定位置的相邻像素点的标记值与轮廓点的标记值是否相同的步骤。
其中,预定方向为顺时针方向。
其中,通过斑点的起点对斑点的轮廓进行跟踪,并判断各轮廓之间的父子关系的步骤进一步包括:若相同,将预定位置相邻像素点作为轮廓点,并返回判断相对于轮廓点预定位置的相邻像素点的标记值与轮廓点的标记值是否相同的步骤。
其中,判断相对于轮廓点预定位置的相邻像素点的标记值与轮廓点的标记值是否相同的步骤包括:若当前的轮廓点为斑点的起点时,预定位置为当前的轮廓点的右上角位置,若当前的轮廓点不是斑点的起点时,预定位置由以下公式确定:Y=(X+2)mod8;其中,以每一轮廓点的右侧相邻像素点为0,并沿顺时针方向对每一轮廓点周围的相邻像素点进行顺序编号,其中Y表示预定位置,X为当前的轮廓点的前一轮廓点相对于当前的轮廓点的位置编号。
其中,根据父子关系将轮廓组织成拓扑结构的步骤包括:根据父子关系将斑点的起点组织成拓扑结构。
其中,根据拓扑结构计算斑点的特征的步骤:确认是否对选定的斑点进行孔填充;若进行孔填充,则获取选定的斑点的轮廓的子轮廓;将选定的斑点的面积与子轮廓对应的斑点的面积进行求和,进而获取选定的斑点在孔填充后的面积。
本发明的有益效果是:区别于现有技术的情况,本发明的图像的斑点处理方法包括:对灰度图像进行二值化,以得到二值图像;对二值图像进行连通域标记,以得到多个填充有不同标记值的斑点,并记录斑点的起点以及斑点的面积;通过斑点的起点对斑点的轮廓进行跟踪,以判断各轮廓之间的父子关系;根据父子关系将轮廓组织成拓扑结构;根据拓扑结构计算斑点的特征。通过上述方式,本发明在斑点的颜色未给定的情况下,能够根据斑点的轮廓所组织成的拓扑结构计算每个斑点的特征,可以准确地检测目标是否存在缺陷,满足用户的要求。
附图说明
图1是本发明图像的斑点处理方法的流程示意图;
图2是图1中步骤S101的子步骤流程示意图;
图3是本发明填充有不同标记值的斑点的示意图;
图4是图1中步骤S103的子步骤流程示意图;
图5是图1中步骤S105的子步骤流程示意图。
具体实施方式
本发明公开一种图像的斑点处理方法,如图1所示,图1是本发明图像的斑点处理方法的流程示意图。该方法包括以下步骤:
步骤S101:对图像进行二值化处理,以得到二值图像。
步骤S102:对二值图像进行连通域标记,以得到多个填充有不同标记值的斑点,并记录斑点的起点以及斑点的面积。
如图2所示,对二值图像进行连通域标记具体包括以下子步骤:
步骤S1011:获取斑点的起点,并作为种子点。
在步骤S1011中,逐个扫描二值图像的像素点,在判断当前扫描的像素点 未被填充且与已扫描的像素点颜色不同时,确定当前扫描的像素点为斑点的起点。应理解,扫描二值图像的像素点时,可以是逐行逐个扫描,也可以说逐列逐个扫描等。举例而言,逐行逐个对二值化的像素点进行扫描,如对白色的像素点进行填充时,当扫描到下一个黑色像素点时,此时黑色像素点与已填充的白色像素点的颜色不同,因此可以确定黑色的像素点为斑点的起点。
步骤S1012:在种子点所在的当前扫描线上将与种子点连通的相同颜色的像素点填充成与斑点对应的标记值,并统计种子点所在的当前扫描线上将与种子点连通的相同颜色的像素点的个数。
在步骤S1012中,可以逐行逐个将与种子点连通的相同颜色的像素点填充成与斑点对应的标记值,并逐行统计种子点所在的当前扫描线上将与种子点连通的相同颜色的像素点的个数。也可以说逐列逐个将与种子点连通的相同颜色的像素点填充成与斑点对应的标记值,并逐列统计种子点所在的当前扫描线上将与种子点连通的相同颜色的像素点的个数。其中,标记值可以是数值,也可以是具有标识的符号,又或者是其他标记值。应理解,标记值主要是用来区分不同斑点的,可以根据实际需要特定设置。
具体地,当逐行逐个扫描时,从种子点出发,沿当前扫描线向左、右两个方向填充,直到边界,并分别标记区间的左、右端点坐标值x1和x2,并统计在标记区间[x1,x2]的像素点个数。当逐列逐个扫描时,从种子点出发,沿当前扫描线向上、下两个方向填充,直到边界,并分别标记区间的上、下端点坐标值y1和y2,并统计在标记区间[y1,y2]的像素点个数。
步骤S1013:在当前扫描线的相邻扫描线上判断是否存在与当前扫描线上的已填充像素点连通的相同颜色且未被填充的像素区域。
具体地,在区间[x1,x2]中检查与当前扫描线上、下相邻的两条扫描线上的像素点是否存在非边界或未填充的像素点。又或者在区间[y1,y2]中检查与当前扫描线左、右相邻的两条扫描线上的像素点是否存在非边界或未填充的像素点。
如果在当前扫描线的相邻扫描线上存在与已填充像素点连通的相同颜色且未被填充的像素区域时,则执行步骤S1014:从像素区域中提取一像素点作为种子点,并返回在种子点所在的当前扫描线上将与种子点连通的相同颜色的像素点填充成与斑点对应的标记值,并统计种子点所在的当前扫描线上将与种子点连通的相同颜色的像素点的个数的步骤,即返回步骤S1012。
在步骤S1014中,优选将每一像素区域中选择与已填充的区间的端点相邻 的两个像素点中的一者作为种子点,又或者将与已填充的区间的端点相邻的两个像素点中的两个端点作为种子点。当然,在其他实施例中,可以选择与已填充的区间的相邻的像素点中任意一个或多个作为种子点。当选定种子点后,可以选择一个方向逐个填充像素点,如最右边像素点,也可以选择两个相反的方向逐个填充像素点。
如果在当前扫描线的相邻扫描线上没有存在与已填充像素点连通的相同颜色且未被填充的像素区域时,说明此次填充完成,执行步骤S1015:结束。在步骤S1015后,继续逐个扫描二值图像的剩余像素点,以得到下一个斑点的起点,依次反复执行上述步骤,如图3所示,最终将斑点标记成数值,包括标记值为3、4、5的斑点。
举例而言,以逐行逐个对二值图像进行连通域标记具体包括:
(1)初始化:堆栈置空。将种子点(x,y)入栈。
(2)出栈:若栈空则结束。否则取栈顶元素(x,y),以y作为当前扫描线。
(3)填充并确定种子点所在区间:从种子点(x,y)出发,沿当前扫描线向左、右两个方向填充,直到边界。分别标记区间的左、右端点坐标为x1和x2。
(4)并确定新的种子点:在区间[x1,x2]中检查与当前扫描线y上、下相邻的两条扫描线上的像素。若存在非边界、未填充的像素,则把每一区间的最右像素作为种子点压入堆栈,返回第(2)步。
进一步地,记录斑点的面积的步骤包括:获取种子点对应的像素点的面积,统计所有与种子点连通的相同颜色的像素点的个数,以获得斑点的面积。举例而言,如种子点所在的当前扫描线上将与种子点连通的相同颜色的像素点的个数为10个,种子点所在当前扫描线的相邻扫描线上与种子点连通的相同颜色的像素点的个数为50个,则斑点的面积为60个像素点的面积。
步骤S103:通过斑点的起点对斑点的轮廓进行跟踪,以判断各轮廓之间的父子关系。
如图4所示,步骤S103包括以下子步骤:
步骤S1031:将斑点的起点作为轮廓点。如下图以P作为轮廓点,其中,P可以是斑点的起点,P也可以不是斑点的起点。
5 6 7
4 P 0
3 2 1
步骤S1032:判断相对于轮廓点预定位置的相邻像素点的标记值与轮廓点的标记值是否相同。
在步骤S1032中,判断相对于轮廓点周边八个相邻像素点的标记值与轮廓点的标记值是否相同。其中,以每一轮廓点P的右侧相邻像素点为0,并沿顺时针方向对每一轮廓点周围的相邻像素点进行顺序编号。应理解,本发明并不限定以每一轮廓点P的右侧相邻像素点为0,可以根据时间设计特定设置。
在本实施例中,当前的轮廓点P为斑点的起点时,预定位置为当前的轮廓点P的右上角位置,如编号为7的像素点,其中轮廓点P所处的轮廓与编号为7的像素点所处的轮廓不同。当前的轮廓点P为斑点的起点时,判断相对于轮廓点P预定位置的相邻像素点的标记值与轮廓点P的标记值是否相同,如果是,则P点输入轮廓点,否则按顺时针7-0-1-2-3-4-5-6这个顺序搜索直到遇到下一轮廓点为止,标记为P1。
若当前的轮廓点不是斑点的起点时,预定位置由以下公式确定:
Y=(X+2)mod8
其中,Y表示预定位置,X为当前的轮廓点的前一轮廓点相对于当前的轮廓点的位置编号。具体地,如果P是不是斑点的起点,即P是轮廓路径上的一个点,那么它肯定是由一个点进入的,我们设置为P1点,P1点的位置为X(0<=X<=7),那么P点从(X+2)mod8这个位置开始寻找下一步的路径。即,Y表示X加2除于8取模的意思,它反映在图像就是从P-1点按顺时针数2个格子的位置,如在上述九宫图中,P-1就是4,从P-1点按顺时针数2个格子的位置为6。
如果确定相对于轮廓点预定位置的相邻像素点的标记值与轮廓点的标记值不相同时,则执行步骤S1033:表示轮廓点所处的斑点的轮廓与预定位置的相邻像素点所处的斑点的轮廓存在父子关系。
在本实施例中,确定轮廓点后,按照上面所述的跟踪步骤,在遇到下一个 轮廓点之前,所有经过的像素点均为父轮廓的像素点,这样跟踪几个点后,就确定了斑点的轮廓的父轮廓,即轮廓点所处的斑点的轮廓是预定位置的相邻像素点所处的斑点的轮廓的父轮廓。另外,在一些实施例中,当确定相对于轮廓点预定位置的相邻像素点的标记值与轮廓点的标记值不相同时,可直接得出轮廓点所处的斑点的轮廓是预定位置的相邻像素点所处的斑点的轮廓的父轮廓,不再需要继续跟踪,只需跟踪到一个点即可。
举例而言,如果确定编号为7的像素点的标记值与轮廓点P的标记值不相同,说明编号为7的像素点所处在的轮廓是轮廓点P所处在的轮廓的父轮廓。当轮廓点所处的斑点的标记值为3,预定位置的相邻像素点所处的斑点的标记值为4,则标记值为3的斑点的轮廓是标记值为4的斑点的轮廓的父轮廓。当轮廓点所处的斑点的标记值为4,预定位置的相邻像素点所处的斑点的标记值为5,则标记值为4的斑点的轮廓是标记值为5的斑点的轮廓的父轮廓。也就是说,标记值小的斑点的轮廓是标记值大的斑点的轮廓的父轮廓,当然,根据实际需要,可以将标记值大的斑点的轮廓是标记值小的斑点的轮廓的父轮廓。在一些实施例中,可以用其他标记来区分轮廓之间的父子关系。另外,对于位于边界的斑点,不考虑它的父轮廓。
步骤S1034:沿预定方向判断轮廓点周围的其他相邻像素点的标记值是否与轮廓点的标记值相同,并将第一个与轮廓点的标记值相同的其他相邻像素点作为轮廓点,并返回判断相对于轮廓点预定位置的相邻像素点的标记值与轮廓点的标记值是否相同的步骤。
在步骤S1034中,预定位置由以下公式Y=(X+2)mod8确定。其中,预定方向为顺时针方向。
如果确定相对于轮廓点预定位置的相邻像素点的标记值与轮廓点的标记值相同时,则执行步骤S1035:将预定位置相邻像素点作为轮廓点,并返回判断相对于轮廓点预定位置的相邻像素点的标记值与轮廓点的标记值是否相同的步骤。
步骤S104:根据父子关系将轮廓组织成拓扑结构。
在步骤S104中,将每一父轮廓对应的所有子轮廓组成拓扑结构,如标记值为3的斑点的轮廓所包含的子轮廓是标记值为4的斑点的轮廓和标记值为5的斑点的轮廓。优选地,根据父子关系将斑点的起点组织成拓扑结构。
步骤S105:根据拓扑结构计算斑点的特征。
如图5所示,步骤S105包括以下子步骤:
步骤S1051:确认是否对选定的斑点进行孔填充。
步骤S1052:若进行孔填充,则获取选定的斑点的轮廓的子轮廓。
步骤S1053:将选定的斑点的面积与子轮廓对应的斑点的面积进行求和,进而获取选定的斑点在孔填充后的面积。
应理解,本发明并不限定获取斑点的面积,还可以是斑点的其他特征,如斑点的个数,包括大于预设面积的斑点的个数。
综上所述,本发明的图像的斑点处理方法包括:对灰度图像进行二值化,以得到二值图像;对二值图像进行连通域标记,以得到多个填充有不同标记值的斑点,并记录斑点的起点以及斑点的面积;通过斑点的起点对斑点的轮廓进行跟踪,以判断各轮廓之间的父子关系;根据父子关系将轮廓组织成拓扑结构;根据拓扑结构计算斑点的特征。通过上述方式,本发明在斑点的颜色未给定的情况下,能够根据斑点的轮廓所组织成的拓扑结构计算每个斑点的特征,可以准确地检测目标是否存在缺陷,满足用户的要求。
以上仅为本发明的实施例,并非因此限制本发明的专利范围,凡是利用本发明说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本发明的专利保护范围内。

Claims (11)

  1. 一种图像的斑点处理方法,其特征在于,所述方法包括:
    对图像进行二值化处理,以得到二值图像;
    对所述二值图像进行连通域标记,以得到多个填充有不同标记值的斑点,并记录所述斑点的起点以及所述斑点的面积;
    通过所述斑点的起点对所述斑点的轮廓进行跟踪,以判断各所述轮廓之间的父子关系;
    根据所述父子关系将所述轮廓组织成拓扑结构;
    根据所述拓扑结构计算所述斑点的特征。
  2. 根据权利要求1所述的方法,其特征在于,所述对所述二值图像进行连通域标记的步骤包括:
    获取所述斑点的起点,并作为种子点;
    在所述种子点所在的当前扫描线上将与所述种子点连通的相同颜色的像素点填充成与所述斑点对应的标记值,并统计所述种子点所在的当前扫描线上将与所述种子点连通的相同颜色的像素点的个数;
    在所述当前扫描线的相邻扫描线上判断是否存在与所述当前扫描线上的已填充像素点连通的相同颜色且未被填充的像素区域;
    若存在与所述已填充像素点连通的相同颜色且未被填充的像素区域,则从所述像素区域中提取一像素点作为所述种子点,并返回在所述种子点所在的当前扫描线上将与所述种子点连通的相同颜色的像素点填充成与所述斑点对应的标记值,并统计所述种子点所在的当前扫描线上将与所述种子点连通的相同颜色的像素点的个数的步骤。
  3. 根据权利要求2所述的方法,其特征在于,所述记录所述斑点的面积的步骤包括:
    获取所述种子点对应的像素点的面积,统计所有与所述种子点连通的相同颜色的像素点的个数,以获得所述斑点的面积。
  4. 根据权利要求2所述的方法,其特征在于,所述获取所述斑点的起点的步骤包括:
    逐个扫描所述二值图像的像素点,在判断当前扫描的所述像素点未被填充 且与已扫描的所述像素点颜色不同时,确定所述当前扫描的像素点为所述斑点的起点。
  5. 根据权利要求1所述的方法,其特征在于,所述通过所述斑点的起点对所述斑点的轮廓进行跟踪,并判断各所述轮廓之间的父子关系的步骤包括:
    将所述斑点的起点作为轮廓点;
    判断相对于所述轮廓点预定位置的相邻像素点的标记值与所述轮廓点的标记值是否相同;
    若不相同,则表示所述轮廓点所处的斑点的轮廓与所述预定位置的相邻像素点所处的斑点的轮廓存在父子关系。
  6. 根据权利要求5所述的方法,其特征在于,所述通过所述斑点的起点对所述斑点的轮廓进行跟踪,并判断各所述轮廓之间的父子关系的步骤进一步包括:
    若不相同,则进一步沿预定方向判断轮廓点周围的其他相邻像素点的标记值是否与所述轮廓点的标记值相同,并将第一个与所述轮廓点的标记值相同的其他相邻像素点作为所述轮廓点,并返回所述判断相对于所述轮廓点预定位置的相邻像素点的标记值与所述轮廓点的标记值是否相同的步骤。
  7. 根据权利要求6所述的方法,其特征在于,所述预定方向为顺时针方向。
  8. 根据权利要求6所述的方法,其特征在于,所述通过所述斑点的起点对所述斑点的轮廓进行跟踪,并判断各所述轮廓之间的父子关系的步骤进一步包括:
    若相同,将所述预定位置相邻像素点作为所述轮廓点,并返回所述判断相对于所述轮廓点预定位置的相邻像素点的标记值与所述轮廓点的标记值是否相同的步骤。
  9. 根据权利要求6所述的方法,其特征在于,所述判断相对于所述轮廓点预定位置的相邻像素点的标记值与所述轮廓点的标记值是否相同的步骤包括:
    若当前的轮廓点为所述斑点的起点时,所述预定位置为所述当前的轮廓点的右上角位置,若所述当前的轮廓点不是所述斑点的起点时,所述预定位置由以下公式确定:
    Y=(X+2)mod8;
    其中,以每一轮廓点的右侧相邻像素点为0,并沿顺时针方向对每一所述轮廓点周围的相邻像素点进行顺序编号,其中Y表示所述预定位置,X为所述当 前的轮廓点的前一轮廓点相对于所述当前的轮廓点的位置编号。
  10. 根据权利要求1所述的方法,其特征在于,所述根据所述父子关系将所述轮廓组织成拓扑结构的步骤包括:
    根据所述父子关系将所述斑点的起点组织成拓扑结构。
  11. 根据权利要求1所述的方法,其特征在于,所述根据所述拓扑结构计算所述斑点的特征的步骤:
    确认是否对选定的所述斑点进行孔填充;
    若进行孔填充,则获取所述选定的斑点的轮廓的子轮廓;
    将所述选定的斑点的面积与所述子轮廓对应的斑点的面积进行求和,进而获取所述选定的斑点在孔填充后的面积。
PCT/CN2015/100352 2015-12-31 2015-12-31 图像的斑点处理方法 WO2017113422A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
PCT/CN2015/100352 WO2017113422A1 (zh) 2015-12-31 2015-12-31 图像的斑点处理方法
CN201580079762.8A CN107615333B (zh) 2015-12-31 2015-12-31 图像的斑点处理方法

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2015/100352 WO2017113422A1 (zh) 2015-12-31 2015-12-31 图像的斑点处理方法

Publications (1)

Publication Number Publication Date
WO2017113422A1 true WO2017113422A1 (zh) 2017-07-06

Family

ID=59224166

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/100352 WO2017113422A1 (zh) 2015-12-31 2015-12-31 图像的斑点处理方法

Country Status (2)

Country Link
CN (1) CN107615333B (zh)
WO (1) WO2017113422A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117152187A (zh) * 2023-10-30 2023-12-01 山东中科冶金矿山机械有限公司 一种地质测绘中裂缝轮廓提取方法

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109448067B (zh) * 2018-09-18 2023-01-10 广东智媒云图科技股份有限公司 一种基于螺旋结构的绘画方法及装置

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040126005A1 (en) * 1999-08-05 2004-07-01 Orbotech Ltd. Apparatus and methods for the inspection of objects
CN101388071A (zh) * 2007-09-12 2009-03-18 韩国科亚电子股份有限公司 图像处理设备和方法以及计算机可读介质
CN102760289A (zh) * 2011-04-29 2012-10-31 王晓东 一种嵌入式复杂连通域搜索方法
CN103872983A (zh) * 2014-04-04 2014-06-18 天津市鑫鼎源科技发展有限公司 太阳能电池表面缺陷检测设备及方法
CN103914849A (zh) * 2014-04-18 2014-07-09 扬州福尔喜果蔬汁机械有限公司 一种红枣图像的检测方法
CN104715474A (zh) * 2015-01-20 2015-06-17 电子科技大学 基于标记分水岭算法的高分辨率合成孔径雷达图像线性建筑物检测方法

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7668376B2 (en) * 2004-06-30 2010-02-23 National Instruments Corporation Shape feature extraction and classification
US20070036434A1 (en) * 2005-08-15 2007-02-15 Peter Saveliev Topology-Based Method of Partition, Analysis, and Simplification of Dynamical Images and its Applications

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040126005A1 (en) * 1999-08-05 2004-07-01 Orbotech Ltd. Apparatus and methods for the inspection of objects
CN101388071A (zh) * 2007-09-12 2009-03-18 韩国科亚电子股份有限公司 图像处理设备和方法以及计算机可读介质
CN102760289A (zh) * 2011-04-29 2012-10-31 王晓东 一种嵌入式复杂连通域搜索方法
CN103872983A (zh) * 2014-04-04 2014-06-18 天津市鑫鼎源科技发展有限公司 太阳能电池表面缺陷检测设备及方法
CN103914849A (zh) * 2014-04-18 2014-07-09 扬州福尔喜果蔬汁机械有限公司 一种红枣图像的检测方法
CN104715474A (zh) * 2015-01-20 2015-06-17 电子科技大学 基于标记分水岭算法的高分辨率合成孔径雷达图像线性建筑物检测方法

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
MENG XIANCHEN ET AL.: "Efficient Blob Analysis of Binary Image for Defects Inspection in Valve Rocker Arm Installation", COMPUTER SYSTEMS AND APPLICATIONS, vol. 23, no. 2, 28 February 2014 (2014-02-28) *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117152187A (zh) * 2023-10-30 2023-12-01 山东中科冶金矿山机械有限公司 一种地质测绘中裂缝轮廓提取方法
CN117152187B (zh) * 2023-10-30 2024-01-26 山东中科冶金矿山机械有限公司 一种地质测绘中裂缝轮廓提取方法

Also Published As

Publication number Publication date
CN107615333A (zh) 2018-01-19
CN107615333B (zh) 2021-06-08

Similar Documents

Publication Publication Date Title
TWI413937B (zh) 影像辨識方法與裝置
CN110264445B (zh) 分块模板匹配结合形态学处理的电池丝印质量检测方法
US6929183B2 (en) Reconstruction of virtual raster
CN101517612B (zh) 图像读取装置和图像读取方法
US9218537B2 (en) Image processing device and image processing method
CN104700062A (zh) 一种识别二维码的方法及设备
JP6372149B2 (ja) 表示制御装置、表示制御方法および表示制御プログラム
US8971569B2 (en) Marker processing method, marker processing device, marker, object having a marker, and marker processing program
JP5773436B2 (ja) 情報端末装置
CN105096299A (zh) 多边形检测方法和多边形检测装置
US9367737B2 (en) Floor plan space detection
CN110765992B (zh) 印章鉴别方法、介质、设备及装置
CN109509166A (zh) 印刷电路板图像检测方法和装置
CN106529368A (zh) 二维码识别区域定位的方法
CN112446262A (zh) 文本分析方法、装置、终端和计算机可读存储介质
CN110415296A (zh) 一种有阴影光照下矩形状电器件的定位方法
WO2017113422A1 (zh) 图像的斑点处理方法
CN109685791A (zh) 一种基于多窗自相关纹理检测的瓦楞纸板鲁棒检测算法
CN108182707B (zh) 采集不完整条件下的棋盘格标定模板及其自动识别方法
CN109977959A (zh) 一种火车票字符区域分割方法及装置
CN107945190A (zh) 二值图像快速连通区域计算方法
CN106097281B (zh) 一种用于投影交互系统的标定图及其标定检测方法
CN115375679B (zh) 一种缺陷芯片寻边寻点定位方法及装置
CN110675384B (zh) 图像处理方法及装置
KR101635804B1 (ko) 원형 허프 변환 기반의 자동 바둑 기보 시스템 및 그 방법

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 15912046

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 15912046

Country of ref document: EP

Kind code of ref document: A1