[go: up one dir, main page]

CN104574448A - Method for identifying connected pixel blocks - Google Patents

Method for identifying connected pixel blocks Download PDF

Info

Publication number
CN104574448A
CN104574448A CN201410710102.2A CN201410710102A CN104574448A CN 104574448 A CN104574448 A CN 104574448A CN 201410710102 A CN201410710102 A CN 201410710102A CN 104574448 A CN104574448 A CN 104574448A
Authority
CN
China
Prior art keywords
run
thisrow
lastrow
nodes
target
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
CN201410710102.2A
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 CN201410710102.2A priority Critical patent/CN104574448A/en
Publication of CN104574448A publication Critical patent/CN104574448A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/40Analysis of texture
    • G06T7/41Analysis of texture based on statistical description of texture
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/90Determination of colour characteristics

Landscapes

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

Abstract

本发明适用于图像处理领域,提供了一种连通像素块的识别方法,所述方法包括:逐行扫描待识别图像,获取所述待识别图像的每一行图像的游程段;将所述游程段计入本行图像的游程节点,将所述游程节点分为目标游程节点和背景游程节点,并获取所述游程节点的游程信息;用于根据所述游程节点的游程信息和预设的连通识别关系识别相邻两行的目标游程节点是否连通;更新ThisRow目标游程节点的指针,直到最后一行图像处理完成。本发明实施例,逐行扫描待识别图像,获取待识别图像的每一行图像的游程段,将游程段计入每一行的游程节点,并获取该游程节点的游程信息,根据预设的连通识别关系判断相邻两行图像是否连通,解决了标记冗余现象。

The present invention is applicable to the field of image processing, and provides a method for identifying connected pixel blocks. The method includes: scanning an image to be identified line by line, and obtaining a run segment of each line of the image to be identified; Include the run nodes of the image in this line, divide the run nodes into target run nodes and background run nodes, and obtain the run information of the run nodes; used for identification based on the run information of the run nodes and the preset connectivity The relationship identifies whether the target run-length nodes of two adjacent rows are connected; update the pointer of the ThisRow target run-length node until the last row of image processing is completed. In the embodiment of the present invention, the image to be recognized is scanned line by line, and the run segment of each line of the image to be recognized is obtained, and the run segment is included in the run node of each line, and the run information of the run node is obtained, and identified according to the preset connectivity The relationship judges whether two adjacent lines of images are connected, and solves the phenomenon of label redundancy.

Description

一种连通像素块的识别方法A Recognition Method of Connected Pixel Blocks

技术领域technical field

本发明属于图像处理领域,尤其涉及一种连通像素块的识别方法。The invention belongs to the field of image processing, in particular to a method for identifying connected pixel blocks.

背景技术Background technique

Blob是指具有相似图像特征(如颜色、纹理等)、而且在空间上是连通的像素组成的块。Blob分析是计算机视觉和图像理解的一个很重要的组成部分,在对图像中物体的位置、形状和大小几乎没有任何先验知识的情况下可以很方便的定位物体,计算物体的各种几何特征,从而可以根据这些特征对物体进行选择和分类。Blob refers to a block composed of pixels that have similar image features (such as color, texture, etc.) and are spatially connected. Blob analysis is a very important part of computer vision and image understanding. It can easily locate objects and calculate various geometric features of objects without any prior knowledge of the position, shape and size of objects in the image. , so that objects can be selected and classified based on these features.

Blob分析的核心是连通区域检测算法,目前的算法根据处理方法大致可以分为两类:基于像素扫描的方法和基于游程编码的方法。基于像素的标记方法比较有代表性的是递归法和两次扫描法。递归法扫描图像,找到没有标记的X点,给它分配一个新的标记L,递归分配标记L给X点的邻点,直到所有点都有标记。这种方法需要反复扫描图像,空间复杂度和时间复杂度都很高。两次扫描法对上面的方法进行了改进:第一次扫描,对所有连通区域进行临时标记,同时用等价表来记录所有标记冗余;第二次扫描等价表,利用特定的搜索算法,进行等价标记合并。基于游程编码的方法首先对二值图像进行游程编码,然后对编码后的图像进行连通区域标记,同样利用等价表,来记录标记冗余,该方法能有效地压缩图像,使得搜索空间变小,从而降低了算法搜索的空间复杂度。利用等价表记录标记冗余,避免了重复扫描连通区域,但是,在图像中连通区域数目很大或者连通区域形状很复杂时,标记冗余现象严重,等价表结构复杂,搜索等价表进行等价标记合并的算法耗时很长。在工业环境下采集的图像由于噪声、光照等原因,采集的图像经过二值化处理后存在很多噪声,基于等价表的算法非常耗时,而且当噪声很严重时算法很不稳定,很难应用到工业视觉检测中。The core of Blob analysis is the connected region detection algorithm. The current algorithms can be roughly divided into two categories according to the processing method: the method based on pixel scanning and the method based on run-length coding. Representative pixel-based marking methods are the recursive method and the two-scan method. The recursive method scans the image, finds the X point that has no mark, assigns it a new mark L, and recursively assigns the mark L to the neighbors of the X point until all points have marks. This method needs to scan the image repeatedly, and the space complexity and time complexity are high. The two-scanning method improves the above method: in the first scan, all connected areas are temporarily marked, and at the same time, the equivalence table is used to record all label redundancy; in the second scan, the equivalence table is used to use a specific search algorithm , for equivalence marker merging. The method based on run-length coding first performs run-length coding on the binary image, and then marks the connected regions of the coded image, and also uses the equivalence table to record the label redundancy. This method can effectively compress the image and make the search space smaller. , thereby reducing the space complexity of the algorithm search. Use the equivalence table to record mark redundancy to avoid repeated scanning of connected regions. However, when the number of connected regions in the image is large or the shape of the connected region is complex, the phenomenon of mark redundancy is serious, and the structure of the equivalence table is complex. Searching the equivalence table The algorithm to do equivalence tag merging is very time consuming. The images collected in the industrial environment have a lot of noise after binarization processing due to noise, lighting and other reasons. The algorithm based on the equivalence table is very time-consuming, and when the noise is very serious, the algorithm is very unstable and difficult. Applied to industrial visual inspection.

发明内容Contents of the invention

鉴于此,本发明提供一种连通像素块的识别方法,以解决现有技术标记冗余的技术问题。In view of this, the present invention provides a method for identifying connected pixel blocks to solve the technical problem of label redundancy in the prior art.

本发明实施例是这样实现的,一种连通像素块的识别方法,所述方法包括以下步骤:The embodiment of the present invention is achieved in this way, a method for identifying connected pixel blocks, the method includes the following steps:

逐行扫描待识别图像,获取所述待识别图像的每一行图像的游程段;Scan the image to be recognized line by line, and obtain the run segment of each row of the image to be recognized;

将所述游程段计入本行图像的游程节点,将所述游程节点分为目标游程节点和背景游程节点,并获取所述游程节点的游程信息,所述游程信息包括:标记信息known、索引信息index、起始坐标start、终止坐标end和灰度值value;Count the run segment into the run node of the row image, divide the run node into a target run node and a background run node, and obtain the run information of the run node. The run information includes: tag information known, index Information index, start coordinate start, end coordinate end and gray value value;

用于根据所述游程节点的游程信息和预设的连通识别关系识别相邻两行的目标游程节点是否连通,其中,ThisRow表示本行图像,LastRow表示上一行图像;It is used to identify whether the target run nodes in two adjacent rows are connected according to the run information of the run nodes and the preset connected identification relationship, wherein, ThisRow represents the image of the current row, and LastRow represents the image of the previous row;

更新ThisRow目标游程节点的指针,直到最后一行图像处理完成。Update the pointer of the ThisRow target run node until the last row image processing is completed.

本发明实施例,逐行扫描待识别图像,获取待识别图像的每一行图像的游程段,将游程段计入每一行的游程节点,并获取该游程节点的游程信息,根据预设的连通识别关系判断相邻两行图像是否连通,使得法使用游程链表和动态数组的方法,只需扫描图像一次,并且无需建立等价表和进行等价标记合并,解决了现有算法中的标记冗余现象。In the embodiment of the present invention, the image to be recognized is scanned line by line, and the run segment of each line of the image to be recognized is obtained, and the run segment is included in the run node of each line, and the run information of the run node is obtained, and identified according to the preset connectivity The method uses the run-length linked list and the dynamic array method to judge whether two adjacent rows of images are connected, which only needs to scan the image once, and does not need to establish an equivalence table and merge equivalent marks, which solves the mark redundancy in the existing algorithm Phenomenon.

附图说明Description of drawings

为了更清楚地说明本发明实施例中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the accompanying drawings that need to be used in the descriptions of the embodiments or the prior art. Obviously, the accompanying drawings in the following descriptions are only of the present invention. For some embodiments, those of ordinary skill in the art can also obtain other drawings based on these drawings without paying creative efforts.

图1是本发明实施例提供的连通像素块识别方法的流程图;Fig. 1 is a flowchart of a method for identifying connected pixel blocks provided by an embodiment of the present invention;

如图2a所示为本发明一个实施例提供的相邻两行目标游程节点连通关系示意图;As shown in Figure 2a, it is a schematic diagram of the connection relationship between two adjacent rows of target run nodes provided by an embodiment of the present invention;

如图2b所示为本发明另一实施例提供的相邻两行目标游程节点连通关系示意图;As shown in Figure 2b, it is a schematic diagram of the connection relationship between two adjacent rows of target run nodes provided by another embodiment of the present invention;

如图2c所示为本发明再一实施例提供的相邻两行目标游程节点连通关系示意图;As shown in Figure 2c, it is a schematic diagram of the connection relationship between two adjacent rows of target run nodes provided by another embodiment of the present invention;

如图2d所示为本发明再一实施例提供的相邻两行目标游程节点连通关系示意图;As shown in Figure 2d, it is a schematic diagram of the connection relationship between two adjacent rows of target run nodes provided by another embodiment of the present invention;

如图2e所示为本发明再一实施例提供的相邻两行目标游程节点连通关系示意图;As shown in FIG. 2e, it is a schematic diagram of the connection relationship between two adjacent rows of target run nodes provided by another embodiment of the present invention;

如图2f所示为本发明再一实施例提供的相邻两行目标游程节点连通关系示意图;As shown in Figure 2f, it is a schematic diagram of the connection relationship between two adjacent rows of target run nodes provided by another embodiment of the present invention;

如图2g所示为本发明再一实施例提供的相邻两行目标游程节点连通关系示意图;As shown in Figure 2g, it is a schematic diagram of the connection relationship between two adjacent rows of target run nodes provided by another embodiment of the present invention;

如图2h所示为本发明再一实施例提供的相邻两行目标游程节点连通关系示意图。FIG. 2h is a schematic diagram of the connection relationship between two adjacent rows of target run nodes provided by yet another embodiment of the present invention.

具体实施方式Detailed ways

为了使本发明的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本发明进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本发明,并不用于限定本发明。In order to make the object, technical solution and advantages of the present invention clearer, the present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described here are only used to explain the present invention, not to limit the present invention.

为了说明本发明所述的技术方案,下面通过具体实施例来进行说明。In order to illustrate the technical solutions of the present invention, specific examples are used below to illustrate.

实施例一Embodiment one

如图1所示为本发明实施例提供的连通像素块识别方法的流程图,所述方法包括以下步骤:As shown in Figure 1, it is a flowchart of a method for identifying connected pixel blocks provided by an embodiment of the present invention, and the method includes the following steps:

步骤S101,逐行扫描待识别图像,获取所述待识别图像的每一行图像的游程段。Step S101, scan the image to be recognized line by line, and acquire the run length of each line of the image to be recognized.

在本发明实施例中,识别系统逐行扫描待识别图像,以获取待识别图像的每一行图像的游程段。In the embodiment of the present invention, the recognition system scans the image to be recognized line by line, so as to obtain the run segment of each line of the image to be recognized.

步骤S102,将所述游程段计入本行图像的游程节点,将所述游程节点分为目标游程节点和背景游程节点,并获取所述游程节点的游程信息,所述游程信息包括:标记信息known、索引信息index、起始坐标start、终止坐标end和灰度值value。Step S102, counting the run segments into the run nodes of the row image, dividing the run nodes into target run nodes and background run nodes, and obtaining the run information of the run nodes, the run information including: label information known, index information index, start coordinate start, end coordinate end and gray value value.

在本发明实施例中,识别系统在获取每一行图像的游程段之后,将该游程段计入本行图像的游程节点并分为目标游程节点和背景游程节点,同时获取游程节点的游程信息,其中,游程信息包括但不限于:标记信息known、索引信息index、起始坐标start、终止坐标end和灰度值value,其中,游程信息表达的意思如下:In the embodiment of the present invention, after the recognition system acquires the run segment of each line of image, the run segment is included in the run node of the row image and divided into the target run node and the background run node, and the run information of the run node is obtained at the same time, Among them, the run length information includes but not limited to: mark information known, index information index, start coordinate start, end coordinate end and gray value value, where the meaning expressed by the run length information is as follows:

标记信息:用于表示该游程节点是否被标记。Mark information: used to indicate whether the run node is marked.

索引信息:用于表示游程节点在本行图像的索引,记录游程节点在本行图像的位置信息。Index information: used to indicate the index of the run node in the image of the row, and record the position information of the run node in the image of the row.

起始坐标:用于表示游程节点在本行图像的起始坐标。Start coordinates: It is used to indicate the start coordinates of the run node in the current line image.

终止坐标:用于表示游程节点在本行图像的终止坐标。Termination coordinates: It is used to indicate the termination coordinates of the run node in the current line image.

灰度值:用于表示游程节点的灰度值。Gray value: used to represent the gray value of the run node.

步骤S103,用于根据所述游程节点的游程信息和预设的连通识别关系识别相邻两行的目标游程节点是否连通,其中,ThisRow表示本行图像,LastRow表示上一行图像。Step S103, for identifying whether the target run nodes in two adjacent rows are connected according to the run information of the run nodes and the preset connection identification relationship, where ThisRow represents the image of the current row, and LastRow represents the image of the previous row.

在本发明实施例中,识别系统在获取了游程节点的游程信息之后,根据该游程信息识别相邻两行的目标游程节点是否连通,其中,所述预设的连通识别关系为:LastRow.srart-1≤ThisRow.end、ThisRow.start-1≤LastRow.end和LastRow.value=ThisRow.value。所述用于根据所述游程节点的游程信息识别相邻两行的目标游程节点是否连通,具体为:In the embodiment of the present invention, after the identification system acquires the run information of the run nodes, it identifies whether the target run nodes in two adjacent rows are connected according to the run information, wherein the preset connected identification relationship is: LastRow.srart -1≤ThisRow.end, ThisRow.start-1≤LastRow.end and LastRow.value=ThisRow.value. The method for identifying whether the target run nodes in two adjacent rows are connected according to the run information of the run nodes is specifically:

(1)、如果Thisrow.start-1>LastRow.end,则相邻两行的目标游程节点不连通。(1) If Thisrow.start-1>LastRow.end, then the target run nodes of two adjacent rows are not connected.

在本发明实施例中,当Thisrow.start-1>LastRow.end时,相邻两行的目标游程节点不满足预设的连通识别关系,目标游程节点的标记信息为:LastRow→index++,即指向LastRow行的下个游程继续判断。如图2a所示为本发明一个实施例提供的相邻两行目标游程节点连通关系示意图,其中白色为目标游程节点,黑色为背景游程节点。In the embodiment of the present invention, when Thisrow.start-1>LastRow.end, the target run-length nodes of two adjacent rows do not meet the preset connected identification relationship, and the tag information of the target run-length node is: LastRow→index++, that is, points to The next run of the LastRow row continues to judge. Figure 2a is a schematic diagram of the connection relationship between two adjacent rows of target run nodes provided by an embodiment of the present invention, wherein white is the target run node, and black is the background run node.

(2)、如果LastRow.end+1≥ThisRow.start≥LastRow.start且ThisRow.end>LastRow.end,则相邻两行的目标游程节点连通。(2) If LastRow.end+1≥ThisRow.start≥LastRow.start and ThisRow.end>LastRow.end, then the target run nodes of two adjacent rows are connected.

在本发明实施例中,当LastRow.end+1≥ThisRow.start≥LastRow.start且ThisRow.end>LastRow.end时,相邻两行的目标游程节点满足预设的连通识别关系,LastRow目标游程节点比ThisRow目标游程节点的起始坐标要小、终止坐标也要小,则执行以下操作:将ThisRow的目标游程节点归入LastRow的目标游程节点,LastRow→index++。如图2b所示为本发明另一实施例提供的相邻两行目标游程节点连通关系示意图,其中白色为目标游程节点,黑色为背景游程节点。In the embodiment of the present invention, when LastRow.end+1≥ThisRow.start≥LastRow.start and ThisRow.end>LastRow.end, the target run nodes of two adjacent rows satisfy the preset connected identification relationship, and the LastRow target run If the start coordinate and end coordinate of the node are smaller than the target run node of ThisRow, the following operations are performed: the target run node of ThisRow is classified into the target run node of LastRow, LastRow→index++. FIG. 2b is a schematic diagram of the connection relationship between two adjacent rows of target run nodes provided by another embodiment of the present invention, wherein white is the target run nodes, and black is the background run nodes.

(3)、如果ThisRow.start≥LastRow.star且ThisRow.end<LastRow.end,则相邻两行的目标游程节点连通。(3) If ThisRow.start≥LastRow.star and ThisRow.end<LastRow.end, then the target run-length nodes of two adjacent rows are connected.

在本发明实施例中,当ThisRow.start≥LastRow.star且ThisRow.end<LastRow.end时,相邻两行的目标游程节点满足预设的连通识别关系,LastRow目标游程节点比ThisRow目标游程节点的起始坐标要小、但终止坐标要大,则执行以下操作:将ThisRow的目标游程节点归入LastRow的目标游程节点,ThisRow→index++。如图2c所示为本发明再一实施例提供的相邻两行目标游程节点连通关系示意图,其中白色为目标游程节点,黑色为背景游程节点。In the embodiment of the present invention, when ThisRow.start≥LastRow.star and ThisRow.end<LastRow.end, the target run-length nodes of two adjacent rows satisfy the preset connected identification relationship, and the LastRow target run-length node is more than the ThisRow target run-length node The starting coordinate of is smaller but the ending coordinate is larger, then the following operation is performed: the target run node of ThisRow is classified into the target run node of LastRow, ThisRow→index++. FIG. 2c is a schematic diagram of the connection relationship between two adjacent rows of target run nodes provided by another embodiment of the present invention, wherein white is the target run nodes, and black is the background run nodes.

(4)、如果ThisRow.start≥LastRow.star且ThisRow.end=LastRow.end,则相邻两行的目标游程节点连通。(4) If ThisRow.start≥LastRow.star and ThisRow.end=LastRow.end, then the target run nodes of two adjacent rows are connected.

在本发明实施例中,当ThisRow.start≥LastRow.star且ThisRow.end=LastRow.end时,相邻两行的目标游程节点满足预设的连通识别关系,LastRow目标游程节点比ThisRow目标游程节点起始坐标要小、终止坐标相同,则执行以下操作:将ThisRow的目标游程节点归入LastRow的目标游程节点,ThisRow→index++,LastRow→index++。如图2d所示为本发明再一实施例提供的相邻两行目标游程节点连通关系示意图,其中白色为目标游程节点,黑色为背景游程节点。In the embodiment of the present invention, when ThisRow.start≥LastRow.star and ThisRow.end=LastRow.end, the target run-length nodes of two adjacent rows satisfy the preset connected identification relationship, and the LastRow target run-length node is more than the ThisRow target run-length node If the start coordinates are smaller and the end coordinates are the same, the following operations are performed: classify the target run node of ThisRow into the target run node of LastRow, ThisRow→index++, LastRow→index++. FIG. 2d is a schematic diagram of the connection relationship between two adjacent rows of target run nodes provided by another embodiment of the present invention, wherein white is the target run nodes, and black is the background run nodes.

(5)、如果ThisRow.start<LastRow.star且ThisRow.end=LastRow.end,则相邻两行的目标游程节点连通。(5) If ThisRow.start<LastRow.star and ThisRow.end=LastRow.end, then the target run nodes of two adjacent rows are connected.

在本发明实施例中,当ThisRow.start<LastRow.star且ThisRow.end=LastRow.end时,相邻两行的目标游程节点满足预设的连通识别关系,LastRow目标游程节点比ThisRow目标游程节点起始坐标要大,所以ThisRow目标游程节点可能同时与LastRow目标游程节点的前一行目标游程节点连通,即ThisRow目标游程节点可能已经被标记,因此需要进行以下处理:将ThisRow的目标游程节点与LastRow的目标游程节点合并,并进行以下操作:In the embodiment of the present invention, when ThisRow.start<LastRow.star and ThisRow.end=LastRow.end, the target run-length nodes of two adjacent rows satisfy the preset connected identification relationship, and the LastRow target run-length node is more than the ThisRow target run-length node The starting coordinates should be large, so the target run node of ThisRow may be connected with the target run node of the previous line of the LastRow target run node at the same time, that is, the target run node of ThisRow may have been marked, so the following processing is required: connect the target run node of ThisRow with the LastRow The target run nodes of are merged and do the following:

if(T.known==0)          //判断T未被标记if(T.known==0) //judging that T is not marked

    {将ThisRow目标游程节点归入LastRow目标游程节点;}{Classify the ThisRow target run node into the LastRow target run node;}

else                         //T已经被标注else //T has been marked

    {将ThisRow的目标游程节点与LastRow的目标游程节点合并;}{Merge the target run node of ThisRow with the target run node of LastRow;}

LastRow→index++;LastRow→index++;

ThisRow→index++;ThisRow→index++;

如图2e所示为本发明再一实施例提供的相邻两行目标游程节点连通关系示意图,其中白色为目标游程节点,黑色为背景游程节点。FIG. 2e is a schematic diagram of the connection relationship between two adjacent rows of target run nodes provided by another embodiment of the present invention, wherein white is the target run nodes, and black is the background run nodes.

(6)、如果ThisRow.start<LastRow.star且ThisRow.end>LastRow.end,则相邻两行的目标游程节点连通。(6) If ThisRow.start<LastRow.star and ThisRow.end>LastRow.end, then the target run nodes of two adjacent rows are connected.

在本发明实施例中,当ThisRow.start<LastRow.star且ThisRow.end>LastRow.end时,相邻两行的目标游程节点满足预设的连通识别关系,LastRow目标游程节点比ThisRow目标游程节点起始坐标要大,需要判断ThisRow目标游程节点是否被标记,则执行以下操作:In the embodiment of the present invention, when ThisRow.start<LastRow.star and ThisRow.end>LastRow.end, the target run-length nodes of two adjacent rows satisfy the preset connected identification relationship, and the LastRow target run-length node is more than the ThisRow target run-length node The starting coordinates are large, and it is necessary to determine whether the ThisRow target run node is marked, then perform the following operations:

if(ThisRow.known==0)               //判断ThisRow未被标记if(ThisRow.known==0) //Judge ThisRow is not marked

{将ThisRow目标游程节点归入LastRow目标游程节点;}{Associate the ThisRow target run node into the LastRow target run node;}

else                                 //判断ThisRow已经被标记else //Determine that ThisRow has been marked

{将ThisRow的目标游程节点与LastRow的目标游程节点合并;}{Merge the target run node of ThisRow with the target run node of LastRow;}

LastRow→index++。LastRow→index++.

如图2f所示为本发明再一实施例提供的相邻两行目标游程节点连通关系示意图,其中白色为目标游程节点,黑色为背景游程节点。FIG. 2f is a schematic diagram of the connection relationship between two adjacent rows of target run nodes provided by another embodiment of the present invention, wherein white is the target run nodes, and black is the background run nodes.

(7)、如果LastRow.end>ThisRow.end>LasrRow.start-1且ThisRow.start<LastRow.start,则相邻两行的目标游程节点连通。(7) If LastRow.end>ThisRow.end>LasrRow.start-1 and ThisRow.start<LastRow.start, then the target run nodes of two adjacent rows are connected.

在本发明实施例中,当LastRow.end>ThisRow.end>LasrRow.start-1且ThisRow.start<LastRow.start时,相邻两行的目标游程节点满足预设的连通识别关系,LastRow目标游程节点比ThisRow目标游程节点的起始坐标要大、终止目标也要大,需要判断ThisRow目标游程节点是否被标记,则执行以下操作:In the embodiment of the present invention, when LastRow.end>ThisRow.end>LasrRow.start-1 and ThisRow.start<LastRow.start, the target run nodes of two adjacent rows satisfy the preset connected identification relationship, and the LastRow target run The node is larger than the start coordinates of the ThisRow target run node, and the end target is also larger. To determine whether the ThisRow target run node is marked, perform the following operations:

if(ThisRow.known==0)               //判断ThisRow未被标记if(ThisRow.known==0) //Judge ThisRow is not marked

{将ThisRow目标游程节点归入LastRow目标游程节点;}{Associate the ThisRow target run node into the LastRow target run node;}

else                                 //判断ThisRow已经被标记else //Determine that ThisRow has been marked

{将ThisRow的目标游程节点与LastRow的目标游程节点合并;}{Merge the target run node of ThisRow with the target run node of LastRow;}

LastRow→index++。LastRow→index++.

如图2g所示为本发明再一实施例提供的相邻两行目标游程节点连通关系示意图,其中白色为目标游程节点,黑色为背景游程节点。FIG. 2g is a schematic diagram of the connection relationship between two adjacent rows of target run nodes provided by another embodiment of the present invention, wherein white is the target run nodes, and black is the background run nodes.

(8)、如果ThisRow.end<LastRow.start-1,则相邻相邻两行的目标游程节点不连通。(8) If ThisRow.end<LastRow.start-1, the target run nodes of two adjacent adjacent rows are not connected.

在本发明实施例中,当ThisRow.end<LastRow.start-1时,相邻两行的目标游程节点不满足预设的连通识别关系,则执行以下操作:ThisRow→index++,指向ThisRow下个游程判断。如图2h所示为本发明再一实施例提供的相邻两行目标游程节点连通关系示意图,其中白色为目标游程节点,黑色为背景游程节点。In the embodiment of the present invention, when ThisRow.end<LastRow.start-1, the target run-length nodes of two adjacent rows do not meet the preset connected identification relationship, then perform the following operation: ThisRow→index++, pointing to the next run-length of ThisRow judge. FIG. 2h is a schematic diagram of the connectivity relationship between two adjacent rows of target run nodes provided by yet another embodiment of the present invention, wherein white is the target run nodes, and black is the background run nodes.

步骤S104,更新ThisRow目标游程节点的指针,直到最后一行图像处理完成。Step S104, updating the pointer of the ThisRow target run node until the last row of image processing is completed.

本发明实施例,逐行扫描待识别图像,获取待识别图像的每一行图像的游程段,将游程段计入每一行的游程节点,并获取该游程节点的游程信息,根据预设的连通识别关系判断相邻两行图像是否连通,使得法使用游程链表和动态数组的方法,只需扫描图像一次,并且无需建立等价表和进行等价标记合并,解决了现有算法中的标记冗余现象。In the embodiment of the present invention, the image to be recognized is scanned line by line, and the run segment of each line of the image to be recognized is obtained, and the run segment is included in the run node of each line, and the run information of the run node is obtained, and identified according to the preset connectivity The method uses the run-length linked list and the dynamic array method to judge whether two adjacent rows of images are connected, which only needs to scan the image once, and does not need to establish an equivalence table and merge equivalent marks, which solves the mark redundancy in the existing algorithm Phenomenon.

作为本发明的一个可选实施例,在所述用于根据所述游程节点的游程信息和预设的连通识别关系识别相邻两行的目标游程节点是否连通的步骤之前,所述方法还包括以下步骤:As an optional embodiment of the present invention, before the step of identifying whether two adjacent rows of target run nodes are connected according to the run information of the run nodes and the preset connected identification relationship, the method further includes The following steps:

预设所述连通识别关系。The connection identification relationship is preset.

本领域普通技术人员还可以理解,实现上述实施例方法中的全部或部分步骤是可以通过程序来指令相关的硬件来完成,所述的程序可以在存储于一计算机可读取存储介质中,所述的存储介质,包括ROM/RAM、磁盘、光盘等。Those of ordinary skill in the art can also understand that all or part of the steps in the method of the above embodiments can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable storage medium, so The storage medium mentioned above includes ROM/RAM, magnetic disk, optical disk, etc.

以上所述仅为本发明的较佳实施例而已,并不用以限制本发明,凡在本发明的精神和原则之内所作的任何修改、等同替换和改进等,均应包含在本发明的保护范围之内。The above descriptions are only preferred embodiments of the present invention, and are not intended to limit the present invention. Any modifications, equivalent replacements and improvements made within the spirit and principles of the present invention should be included in the protection of the present invention. within range.

Claims (4)

1.一种连通像素块的识别方法,其特征在于,所述方法包括以下步骤:1. A method for identifying connected pixel blocks, characterized in that the method comprises the following steps: 逐行扫描待识别图像,获取所述待识别图像的每一行图像的游程段;Scan the image to be recognized line by line, and obtain the run segment of each row of the image to be recognized; 将所述游程段计入本行图像的游程节点,将所述游程节点分为目标游程节点和背景游程节点,并获取所述游程节点的游程信息,所述游程信息包括:标记信息known、索引信息index、起始坐标start、终止坐标end和灰度值value;Count the run segment into the run node of the row image, divide the run node into a target run node and a background run node, and obtain the run information of the run node. The run information includes: tag information known, index Information index, start coordinate start, end coordinate end and gray value value; 用于根据所述游程节点的游程信息和预设的连通识别关系识别相邻两行的目标游程节点是否连通,其中,ThisRow表示本行图像,LastRow表示上一行图像;It is used to identify whether the target run nodes in two adjacent rows are connected according to the run information of the run nodes and the preset connected identification relationship, wherein, ThisRow represents the image of the current row, and LastRow represents the image of the previous row; 更新ThisRow目标游程节点的指针,直到最后一行图像处理完成。Update the pointer of the ThisRow target run node until the last row image processing is completed. 2.如权利要求1所述的方法,其特征在于,在所述用于根据所述游程节点的游程信息和预设的连通识别关系识别相邻两行的目标游程节点是否连通的步骤之前,所述方法还包括以下步骤:2. The method according to claim 1, wherein, before the step of identifying whether the target run nodes in two adjacent rows are connected according to the run information of the run nodes and the preset connected identification relationship, The method also includes the steps of: 预设所述连通识别关系。The connection identification relationship is preset. 3.如权利要求1所述的方法,其特征在于,所述预设的连通识别关系为:LastRow.srart-1≤ThisRow.end、ThisRow.start-1≤LastRow.end和LastRow.value=ThisRow.value。3. The method according to claim 1, wherein the preset connected identification relationship is: LastRow.srart-1≤ThisRow.end, ThisRow.start-1≤LastRow.end and LastRow.value=ThisRow .value. 4.如权利要求3所述的方法,其特征在于,所述用于根据所述游程节点的游程信息识别相邻两行的目标游程节点是否连通,具体为:4. The method according to claim 3, wherein the step of identifying whether the target run nodes of two adjacent rows are connected according to the run information of the run nodes is specifically: 如果Thisrow.start-1>LastRow.end,则相邻两行的目标游程节点不连通;或者,If Thisrow.start-1>LastRow.end, the target run nodes of two adjacent rows are not connected; or, 如果LastRow.end+1≥ThisRow.start≥LastRow.start且ThisRow.end>LastRow.end,则相邻两行的目标游程节点连通;或者,If LastRow.end+1≥ThisRow.start≥LastRow.start and ThisRow.end>LastRow.end, the target run nodes of two adjacent rows are connected; or, 如果ThisRow.start≥LastRow.star且ThisRow.end<LastRow.end,则相邻两行的目标游程节点连通;或者,If ThisRow.start≥LastRow.star and ThisRow.end<LastRow.end, then the target run nodes of two adjacent rows are connected; or, 如果ThisRow.start≥LastRow.star且ThisRow.end=LastRow.end,则相邻两行的目标游程节点连通;或者,If ThisRow.start≥LastRow.star and ThisRow.end=LastRow.end, then the target run nodes of two adjacent rows are connected; or, 如果ThisRow.start≥LastRow.star且ThisRow.end=LastRow.end,则相邻两行的目标游程节点连通;或者,If ThisRow.start≥LastRow.star and ThisRow.end=LastRow.end, then the target run nodes of two adjacent rows are connected; or, 如果ThisRow.start<LastRow.star且ThisRow.end>LastRow.end,则相邻两行的目标游程节点连通;或者,If ThisRow.start<LastRow.star and ThisRow.end>LastRow.end, then the target run nodes of two adjacent rows are connected; or, 如果ThisRow.start<LastRow.star且ThisRow.end>LastRow.end,则相邻两行的目标游程节点连通;或者,If ThisRow.start<LastRow.star and ThisRow.end>LastRow.end, then the target run nodes of two adjacent rows are connected; or, 如果ThisRow.end<LastRow.start-1,则相邻相邻两行的目标游程节点不连通。If ThisRow.end<LastRow.start-1, the target run nodes of two adjacent adjacent rows are not connected.
CN201410710102.2A 2014-11-28 2014-11-28 Method for identifying connected pixel blocks Pending CN104574448A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410710102.2A CN104574448A (en) 2014-11-28 2014-11-28 Method for identifying connected pixel blocks

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410710102.2A CN104574448A (en) 2014-11-28 2014-11-28 Method for identifying connected pixel blocks

Publications (1)

Publication Number Publication Date
CN104574448A true CN104574448A (en) 2015-04-29

Family

ID=53090415

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410710102.2A Pending CN104574448A (en) 2014-11-28 2014-11-28 Method for identifying connected pixel blocks

Country Status (1)

Country Link
CN (1) CN104574448A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107067400A (en) * 2016-11-30 2017-08-18 南京航空航天大学 A kind of bianry image method for marking connected region based on the distance of swimming
CN109584262A (en) * 2018-12-15 2019-04-05 中国科学院深圳先进技术研究院 Cloud detection method of optic, device and electronic equipment based on remote sensing image
CN110738106A (en) * 2019-09-05 2020-01-31 天津大学 optical remote sensing image ship detection method based on FPGA
CN117152458A (en) * 2023-11-01 2023-12-01 南京盛视工业技术有限公司 Method and system for rapidly extracting connected domain based on travel coding

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040247179A1 (en) * 2003-03-31 2004-12-09 Seiko Epson Corporation Image processing apparatus, image processing method, and image processing program
CN101042734A (en) * 2007-04-17 2007-09-26 华东师范大学 Method for rapid making image connection element
CN101930544A (en) * 2010-09-07 2010-12-29 东南大学 Fast Connected Domain Analysis Method of Music Score Based on Row-length Adjacency List

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040247179A1 (en) * 2003-03-31 2004-12-09 Seiko Epson Corporation Image processing apparatus, image processing method, and image processing program
CN101042734A (en) * 2007-04-17 2007-09-26 华东师范大学 Method for rapid making image connection element
CN101930544A (en) * 2010-09-07 2010-12-29 东南大学 Fast Connected Domain Analysis Method of Music Score Based on Row-length Adjacency List

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
张二虎 等: "Blob分析中基于游程链的连通区域标记", 《应用科学学报》 *
沈乔楠 等: "基于游程递归的连通区域标记算法", 《计算机应用》 *

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107067400A (en) * 2016-11-30 2017-08-18 南京航空航天大学 A kind of bianry image method for marking connected region based on the distance of swimming
CN109584262A (en) * 2018-12-15 2019-04-05 中国科学院深圳先进技术研究院 Cloud detection method of optic, device and electronic equipment based on remote sensing image
CN110738106A (en) * 2019-09-05 2020-01-31 天津大学 optical remote sensing image ship detection method based on FPGA
CN117152458A (en) * 2023-11-01 2023-12-01 南京盛视工业技术有限公司 Method and system for rapidly extracting connected domain based on travel coding
CN117152458B (en) * 2023-11-01 2024-01-30 南京盛视工业技术有限公司 Method and system for rapidly extracting connected domain based on travel coding

Similar Documents

Publication Publication Date Title
US10803338B2 (en) Method and device for recognizing the character area in a image
US10937138B2 (en) Crack information detection device, method of detecting crack information, and crack information detection program
US10942130B2 (en) Damage information processing device and damage information processing method
US11275955B2 (en) Lane line processing method and device
WO2016065701A1 (en) Image text recognition method and device
US9025853B2 (en) Method for determining markings in relief on the outer surface of the sidewall of a tyre
CN104036244B (en) Checkerboard pattern corner point detecting method and device applicable to low-quality images
CN109753953A (en) Method, device, electronic device and storage medium for locating text in image
US20220383608A1 (en) Image processing apparatus, image processing method, and program for detecting defect from image
CN110569774B (en) An Automatic Digitization Method of Line Chart Image Based on Image Processing and Pattern Recognition
CN104574448A (en) Method for identifying connected pixel blocks
CN104680531A (en) Connection flux statistical information extraction method and VLSI structure
CN106373126B (en) Image significance detection method based on fusion class geodesic curve and boundary comparison
CN107341810A (en) A kind of automatic vehicle identification method, apparatus and electronic equipment
CN108647570B (en) Zebra crossing detection method and device and computer readable storage medium
CN106023191B (en) A kind of optics delineation character edge extraction and edge fitting method based on structure feature
CN110232709B (en) Method for extracting line structured light strip center by variable threshold segmentation
JP2021135209A (en) Device and method for determining crack region and program for the same
JP2014044674A (en) Method for counting number of pipes, device for counting number of pipes, and computer program
CN114022856B (en) A method for identifying a drivable area on an unstructured road, an electronic device and a medium
US20140212050A1 (en) Systems and methods for processing an image
US10119111B2 (en) Cell colony area specifying apparatus, cell colony area specifying method, and recording medium
CN109871910B (en) A kind of handwritten character recognition method and device
US8483482B2 (en) Image processing device, image processing method and computer-readable medium
CN105930813A (en) Method for detecting line text under any natural scene

Legal Events

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

Application publication date: 20150429