Movatterモバイル変換


[0]ホーム

URL:


CN109636824B - Multi-target counting method based on image recognition technology - Google Patents

Multi-target counting method based on image recognition technology
Download PDF

Info

Publication number
CN109636824B
CN109636824BCN201811567432.5ACN201811567432ACN109636824BCN 109636824 BCN109636824 BCN 109636824BCN 201811567432 ACN201811567432 ACN 201811567432ACN 109636824 BCN109636824 BCN 109636824B
Authority
CN
China
Prior art keywords
image
adhesion
target
area
method based
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201811567432.5A
Other languages
Chinese (zh)
Other versions
CN109636824A (en
Inventor
高杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Zhiju Network Technology Achievement Transformation Service Co.,Ltd.
Original Assignee
Chaohu 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 Chaohu UniversityfiledCriticalChaohu University
Priority to CN201811567432.5ApriorityCriticalpatent/CN109636824B/en
Publication of CN109636824ApublicationCriticalpatent/CN109636824A/en
Application grantedgrantedCritical
Publication of CN109636824BpublicationCriticalpatent/CN109636824B/en
Activelegal-statusCriticalCurrent
Anticipated expirationlegal-statusCritical

Links

Images

Classifications

Landscapes

Abstract

Translated fromChinese

本发明涉及一种基于图像识别技术的多目标计数方法,包括以下步骤:原始图像的获取,通过对目标图像进行记录进行获取;图像预处理;独立和粘连目前物体的筛选,对二值化图像进行形态学操作,采用边缘检测算法,识别出连续的图像边缘,再根据目标物体的面积参数,对图像进行划分,小于给定面积阈值的边缘即可以认为是独立的目标物体,大于给定阈值的边缘即认为是可能的有粘连的目标物体,从而实现无粘连和有粘连区域的区分、对无粘连区域进行统计、以及强粘连区域的处理。该基于图像识别技术的多目标计数方法,粘连区域划分方法,采用形态学腐蚀操作后的填充操作在母图像中进行,确保面积阈值唯一,大大简化了后续的操作流程。

Figure 201811567432

The invention relates to a multi-target counting method based on image recognition technology, comprising the following steps: acquisition of an original image, acquisition by recording a target image; image preprocessing; Perform morphological operations, use edge detection algorithm to identify continuous image edges, and then divide the image according to the area parameters of the target object. Edges smaller than the given area threshold can be considered as independent target objects, and larger than the given threshold. The edge of , is considered to be a possible target object with adhesion, so as to realize the distinction between non-adhesion and adhesion-prone areas, statistics of non-adhesion areas, and processing of strong adhesion areas. The multi-target counting method based on the image recognition technology, the adhesion area division method, and the filling operation after the morphological corrosion operation are carried out in the parent image, which ensures that the area threshold is unique and greatly simplifies the subsequent operation process.

Figure 201811567432

Description

Translated fromChinese
一种基于图像识别技术的多目标计数方法A Multi-target Counting Method Based on Image Recognition Technology

技术领域technical field

本发明属于图像识别、机器视觉技术领域,具体涉及一种基于图像识别技术的多目标计数方法。The invention belongs to the technical fields of image recognition and machine vision, and in particular relates to a multi-target counting method based on image recognition technology.

背景技术Background technique

随着计算机技术的发展,图像识别技术在生产和生活中得到了大量的应用;第一类是通用场景下的各种图像识别(需识别的目标固定且种类有限),主要对文字、车牌、指纹的识别;另一类是专用场景下的识别,例如:在工业自动化、流水线上产品分拣以及医学影像筛查等领域(需要识别的目标种类不固定)。前者的实现原理:对于第一类通用的应用场景,目前主流的方法,主要采用神经网络算法,对样本进行分类和比对,通过大量样本的特征的提取和训练,可以实现对文字、车牌,指纹等有限目标集合进行高效的识别;对于第二类专有场景下的目标识别,由于需要识别的目标各种各样,通常只能根据实际的应用场景,有针对性对目标进行识别,也一些成功的案例;本发明主要针对第二类应用情况,通过对现场采集的一幅图像或视频,进行一系列操作,主要包括:前处理、边缘提取、ROI划分及填充、目标分类、聚类分析、统计计数,最终实现对多目标物体进行自动分类和计数。With the development of computer technology, image recognition technology has been widely used in production and life; the first category is various image recognition in general scenarios (the targets to be recognized are fixed and the types are limited), mainly for text, license plates, Fingerprint identification; the other is identification in special scenarios, such as: in the fields of industrial automation, product sorting on assembly lines, and medical image screening (the types of targets to be identified are not fixed). The realization principle of the former: For the first type of general application scenarios, the current mainstream methods mainly use neural network algorithms to classify and compare samples. Fingerprints and other limited target sets can be efficiently identified; for target recognition in the second type of proprietary scenarios, due to various targets to be identified, it is usually only possible to identify targets in a targeted manner according to the actual application scenario. Some successful cases; the present invention is mainly aimed at the second type of application, by performing a series of operations on an image or video collected on site, mainly including: pre-processing, edge extraction, ROI division and filling, target classification, clustering Analysis, statistical counting, and finally realize automatic classification and counting of multi-target objects.

针对第二类应用场景,大多集中于单个目标物体特征的提取和识别或缺陷检测,医学细胞的计数等,首先需要对大量样本进行训练,其次,容易出现过拟合情况,及对样本集范围内图像能够进行准确的统计和识别,但对于样本集之外的未知图像,识别错误率较高,无法满足实际应用的需求;另一方面,对于多目标、大批量、有粘连的目标,难以进行准确的识别和计数。For the second type of application scenarios, most of them focus on the extraction and recognition of single target object features or defect detection, the counting of medical cells, etc. First, a large number of samples need to be trained, and secondly, it is prone to overfitting, and the scope of the sample set The internal images can be accurately counted and recognized, but for unknown images outside the sample set, the recognition error rate is high, which cannot meet the needs of practical applications; Perform accurate identification and counting.

发明内容SUMMARY OF THE INVENTION

本发明的目的就在于为了解决上述问题而提供一种结构简单,设计合理的一种基于图像识别技术的多目标计数方法。The purpose of the present invention is to provide a multi-target counting method based on image recognition technology with simple structure and reasonable design in order to solve the above problems.

本发明通过以下技术方案来实现上述目的:The present invention realizes above-mentioned purpose through following technical scheme:

本发明提供了一种基于图像识别技术的多目标计数方法,包括以下步骤:The invention provides a multi-target counting method based on image recognition technology, comprising the following steps:

图像预处理:采集原始图像,对原始图像进行灰度处理,获取灰度图像;采用直方图统计,自动调节灰度阈值,对灰度图像进行二值化,获得二值化图像;Image preprocessing: collect the original image, perform grayscale processing on the original image, and obtain a grayscale image; use histogram statistics, automatically adjust the grayscale threshold, and binarize the grayscale image to obtain a binarized image;

目标物体无粘连和有粘连区域的区分:对二值化图像进行形态学操作,采用边缘检测算法,识别出连续的图像边缘;根据目标物体的面积参数,设定面积阈值,根据面积阈值对图像进行划分,小于面积阈值即认为是独立的目标物体,大于面积阈值即认为是可能的有粘连的目标物体,从而实现无粘连和有粘连区域的区分;Distinguish between non-adhesion and adhesion areas of the target object: perform morphological operations on the binarized image, and use edge detection algorithms to identify continuous image edges; Divide it, if it is smaller than the area threshold, it is considered as an independent target object, and if it is larger than the area threshold, it is considered as a possible target object with adhesion, so as to realize the distinction between non-adhesion and adhesion areas;

对无粘连区域独立目标物体进行统计;Count the independent target objects in the non-adhesion area;

对粘连区域粘连目标物体的处理:在在对于无粘连区域进行标记和统计后,在原二值化图像中进行填充,得到只含有粘连区域目标物体和填充缝隙的二值化图像;再用边缘检测算法,识别图像的边缘,并计算连通区域的面积,得到粘连目标物体的面积序列;采用k均值聚类算法,对面积序列进行分类,由于目标物体个数只可能是整数,故可以通过判断聚类中心(代表一个目标物体、二个目标物体…的面积)是否满足等差数列来进行最优化选择,有效避免了传统k均值算法需要事先指定聚类中心个数的缺点,从而实现有粘连区域的目标物体个数自动统计和计数。Processing of the adhesion target object in the adhesion area: after marking and counting the non-adhesion area, fill in the original binarized image to obtain a binary image that only contains the target object in the adhesion area and the filling gap; then use edge detection Algorithm, identify the edge of the image, and calculate the area of the connected area to obtain the area sequence of the adhering target object; use the k-means clustering algorithm to classify the area sequence, since the number of target objects can only be an integer, it can be determined by judging the clustering. Whether the cluster center (representing the area of one target object, two target objects...) satisfies the arithmetic sequence is used for optimal selection, which effectively avoids the disadvantage of the traditional k-means algorithm that needs to specify the number of cluster centers in advance. The number of target objects is automatically counted and counted.

进一步优选地:Further preferably:

原始图像的获取采用彩色相机或者单色相机对目标图像进采集。The acquisition of the original image uses a color camera or a monochrome camera to collect the target image.

所述形态学操作包括一次或多次的腐蚀和/或膨胀操作。The morphological operations include one or more erosion and/or dilation operations.

形态学操作的腐蚀操作中,根据实际目标物体大小选择合适的算子。In the corrosion operation of the morphological operation, an appropriate operator is selected according to the actual size of the target object.

所述边缘检测算法为利用canny算子、sobel算子或Laplacian算子进行边缘检测。进一步优选地,采用改进的Canny算子边缘检测方法,步骤包括:The edge detection algorithm uses canny operator, sobel operator or Laplacian operator for edge detection. Further preferably, using the improved Canny operator edge detection method, the steps include:

步骤1-1、用均值滤波对处理的二值化图像进行滤波;Step 1-1, filter the processed binarized image with mean filtering;

步骤1-2、用sobel算子模板的一阶微分提取边缘,计算出梯度和梯度幅值;Step 1-2, extract the edge with the first-order differential of the sobel operator template, and calculate the gradient and gradient amplitude;

步骤1-3、根据计算的梯度和梯度幅值进行非极大值抑制;Steps 1-3, perform non-maximum suppression according to the calculated gradient and gradient amplitude;

步骤1-4、自适应选取最高和最低阈值,对图像进行阈值化;Steps 1-4, adaptively select the highest and lowest thresholds, and threshold the image;

步骤1-5、根据高低阈值处理后,进行边缘连接,得到图像中所有闭区域的边界以及最小外接矩形的四个角点。Steps 1-5: After processing according to the high and low thresholds, perform edge connection to obtain the boundaries of all closed regions in the image and the four corners of the minimum circumscribed rectangle.

采用改进的k均值聚类算法,对面积序列进行分类,通过判断聚类中心是否满足等差数列来进行最优化选择,实现有粘连区域的目标物体个数自动统计和计数,包括以下步骤:The improved k-means clustering algorithm is used to classify the area sequence, and the optimal selection is made by judging whether the cluster center satisfies the arithmetic sequence, and the number of target objects in the adhesion area is automatically counted and counted, including the following steps:

步骤2-1、选择初始聚类中心点,包括:Step 2-1. Select the initial cluster center point, including:

①输入面积序列集合{xi},在{xi}中找出最大值xmax和最小值xmin①Enter the area sequence set {xi }, find the maximum value xmax and the minimum value xmin in {xi };

②为了减小k值的搜索范围,确定可能的最大聚类数目

Figure BDA0001913411350000031
式中,Ait为最小面积阈值,ceil代表向上取整;② In order to reduce the search range of the k value, determine the maximum number of possible clusters
Figure BDA0001913411350000031
In the formula, Ait is the minimum area threshold, and ceil represents rounding up;

③确定kmax个初始聚类中心的备选集合(kmax≥2);③ Determine the candidate set of the initial clustering centers of kmmax (kmmax ≥ 2);

Figure BDA0001913411350000041
Figure BDA0001913411350000041

由此给出的初始聚类中心是等间隔的,不同面积序列的聚类之间满足等差数列的关系;The given initial cluster centers are equally spaced, and the clusters of different area sequences satisfy the relationship of arithmetic sequence;

步骤2-2、考虑到器件粘连个数的任意性,从这kmax个备选聚类中心中选择k个值(从k=2开始),作为理论聚类中心,遍历所有可能的取法,共有

Figure BDA0001913411350000042
种;针对每种选取方法,运行标准的K-MEANS算法,并计算Eval(k)的值;Step 2-2. Considering the arbitrariness of the number of device adhesions, select k values (starting from k=2) from the kmax candidate clustering centers as the theoretical clustering centers, and traverse all possible methods. shared
Figure BDA0001913411350000042
For each selection method, run the standard K-MEANS algorithm and calculate the value of Eval(k);

Figure BDA0001913411350000043
Figure BDA0001913411350000043

其中,k为聚类个数,Ci为实际聚类中心,Ii为理论聚类中心,di=|Ci-Ii|为实际聚类中心与理论聚类中心之间的距离,

Figure BDA0001913411350000044
是聚类个数为k时di的平均值;可知,Eval(k)实际上是聚类间距的方差,体现了样本对理论聚类中心的集中程度,Eval(k)的值越小,集中度越好。Among them, k is the number of clusters, Ci is the actual cluster center, Ii is the theoretical cluster center, di =|Ci -Ii | is the distance between the actual cluster center and the theoretical cluster center,
Figure BDA0001913411350000044
is the average value of di when the number of clusters is k; it can be seen that Eval(k) is actually the variance of the cluster spacing, which reflects the concentration of the sample on the theoretical cluster center. The smaller the value of Eval(k), the The better the concentration.

步骤2-3、聚类划分个数k增加1,重复2-2~2-3步骤,直到达到kmax为止;Step 2-3, the number of clustering division k is increased by 1, and steps 2-2 to 2-3 are repeated until the kmax is reached;

步骤2-4、比较kmax个Eval(k)的值,取Eval(k)最小值时,对应的k即是最合理的聚类划分个数;Step 2-4, compare the values of kmax Eval(k), when taking the minimum value of Eval(k), the corresponding k is the most reasonable number of clustering divisions;

步骤2-5、根据聚类划分个数统计获得各粘连目标的聚类个数后,进而计算出粘连目标的物体数目。Step 2-5: After the number of clusters of each adhesion target is obtained according to the statistics of the number of cluster divisions, the number of objects of the adhesion target is then calculated.

本发明的有益效果在于:The beneficial effects of the present invention are:

1)粘连区域划分方法,采用形态学腐蚀操作后的填充操作在母图像中进行,确保面积阈值唯一,大大简化了后续的操作流程;1) Adhesion area division method, the filling operation after morphological corrosion operation is used in the parent image to ensure that the area threshold is unique, which greatly simplifies the subsequent operation process;

2)利用目标物体的面积作为阈值,同时引入聚类分析方法,对于其他聚类分析方法同样适用;2) Using the area of the target object as a threshold, and introducing a cluster analysis method, it is also applicable to other cluster analysis methods;

3)本发明引入了连通域面积应该近似为等差数列作为最优化聚类分析结果的判断条件,避免了对于k均值聚类分析方法,需要人为事先指定分类个数的问题;3) The present invention introduces the judgment condition that the area of the connected domain should be approximated as an arithmetic sequence as the result of the optimal cluster analysis, and avoids the problem of manually specifying the number of classifications in advance for the k-means cluster analysis method;

4)本发明的适用范围广,对于其他的应用场景,只要是满足:多目标,有粘连,粘连个数不确定的大小相似目标物体,都可以采用本发明的方法进行计算。4) The scope of application of the present invention is wide. For other application scenarios, the method of the present invention can be used for calculation as long as it satisfies: multiple targets, adhesions, and similar-sized target objects with an indeterminate number of adhesions.

附图说明Description of drawings

图1是本发明的主程序算法流程框图;Fig. 1 is the main program algorithm flow chart of the present invention;

图2是本发明的粘连区域算法流程框图;Fig. 2 is the flow chart of the adhesion region algorithm of the present invention;

图3是本发明的获取的灰度图像示意图;Fig. 3 is the grayscale image schematic diagram of the acquisition of the present invention;

图4是本发明的二值化图像示意图;4 is a schematic diagram of a binarized image of the present invention;

图5是本发明的一次腐蚀结果示意图;Fig. 5 is a schematic diagram of a corrosion result of the present invention;

图6是本发明的二次腐蚀结果示意图;Fig. 6 is the schematic diagram of secondary corrosion result of the present invention;

图7是本发明的二次腐蚀后的canny边缘检测结果;Fig. 7 is the canny edge detection result after the secondary corrosion of the present invention;

图8是本发明的母图像填充结果示意图;Fig. 8 is the parent image filling result schematic diagram of the present invention;

图9是本发明的粘连区域的面积分布情况;Fig. 9 is the area distribution situation of the adhesion region of the present invention;

图10是本发明的k均值聚类分析结果。FIG. 10 is the k-means cluster analysis result of the present invention.

具体实施方式Detailed ways

下面结合附图对本申请作进一步详细描述,有必要在此指出的是,以下具体实施方式只用于对本申请进行进一步的说明,不能理解为对本申请保护范围的限制,该领域的技术人员可以根据上述申请内容对本申请作出一些非本质的改进和调整。The application will be described in further detail below in conjunction with the accompanying drawings. It is necessary to point out that the following specific embodiments are only used to further illustrate the application, and should not be construed as limiting the protection scope of the application. Those skilled in the art can The above application content makes some non-essential improvements and adjustments to this application.

实施例1Example 1

如图1-2所示,一种基于图像识别技术的多目标计数方法,以一副含有多个钽电容的图像为例,按照本专利所述的处理方法(主程序算法流程),具体实施过程如下:As shown in Figure 1-2, a multi-target counting method based on image recognition technology, taking an image containing multiple tantalum capacitors as an example, according to the processing method (main program algorithm flow) described in this patent, the specific implementation The process is as follows:

第一步,图像前处理部分,系统加载一幅含有多个钽电容的数字图像后,对图像进行灰度化操作,得到灰度图像(如图3所示),对灰度图像进行直方图统计,以平均灰度值为阈值,小于阈值像素值为0,大于阈值像素值为255,得到尺寸与原图大小一致的二值化图像,将该图像作为本发明描述的图像处理操作的母图像(目标物体为白色,背景为黑色,二值化过程中也可以进行相反的设定)(如图4所示);The first step is the image preprocessing part. After the system loads a digital image containing multiple tantalum capacitors, it performs a grayscale operation on the image to obtain a grayscale image (as shown in Figure 3), and performs a histogram on the grayscale image. Statistics, take the average gray value as the threshold, the pixel value smaller than the threshold value is 0, and the pixel value greater than the threshold value is 255, to obtain a binarized image with the same size as the original image, and this image is used as the mother of the image processing operation described in the present invention. Image (the target object is white, the background is black, and the opposite setting can also be performed during the binarization process) (as shown in Figure 4);

第二步,单个目标物体轮廓识别,为了对目标物体进行计数,首先对图像进行形态学腐蚀操作,根据实际的目标物体大小,采用合适的腐蚀算子,本例中算子介于20-50之间,也可以将腐蚀算子取较小的值,多次运行腐蚀操作,效果一样,本例演示算子大小为20,运行二次的结果,如图5、图6所示,其中粘连不严重的区域已经完全分立开。通过判断连通域的面积(以像素为单位)与目标物体的面积阈值进行比较,将小于面积阈值的区域认定为单个目标物体,并统计计数。The second step is to identify the contour of a single target object. In order to count the target object, first perform a morphological corrosion operation on the image. According to the actual size of the target object, a suitable corrosion operator is used. In this example, the operator is between 20 and 50 In between, you can also take a smaller value for the corrosion operator, and run the corrosion operation multiple times, the effect is the same. The less serious areas have been completely separated. By comparing the area of the connected domain (in pixels) with the area threshold of the target object, the area smaller than the area threshold is identified as a single target object and counted.

要计算连通域的面积,可以采用传统的边缘检测算法,如Canny算子,sobel算子或Laplacian算子进行边缘检测。由于图像已经进行二值化,且进行了形态学腐蚀操作,对于无粘连或本身就独立的目标,识别起来相对容易。To calculate the area of the connected domain, traditional edge detection algorithms such as Canny operator, sobel operator or Laplacian operator can be used for edge detection. Since the image has been binarized and morphologically corroded, it is relatively easy to identify targets that are non-adhesive or self-contained.

传统的Canny算子的基本思想是先进行高斯滤波,高斯滤波是通过图像卷积进行的,然后通过一阶微分算子对边缘进行提取,然后通过梯度进行非极大值抑制。在一阶微分算子中只采用了水平,竖直放行而没考虑45°和135°方向来提取边缘。高低阈值需要进行自己设置,或者用outs方法进行双阈值的求取。根据高低阈值处理后的图像进行边缘连接。带来的问题:高斯滤波能很好的模糊图像,对边缘保存不是很好,边界模糊效应明显,细节丢失比较严重,对椒盐噪声敏感。The basic idea of the traditional Canny operator is to first perform Gaussian filtering. Gaussian filtering is performed by image convolution, and then the edge is extracted by the first-order differential operator, and then non-maximum suppression is performed by gradient. In the first-order differential operator, only horizontal and vertical passes are used without considering the 45° and 135° directions to extract edges. The high and low thresholds need to be set by themselves, or the outs method can be used to obtain double thresholds. Edge connection is performed according to the high and low thresholded images. Problems brought by: Gaussian filtering can blur images very well, but it is not very good for edge preservation, the boundary blurring effect is obvious, the loss of details is serious, and it is sensitive to salt and pepper noise.

本发明采用改进Canny算子进行边缘检测,具体步骤如下:The present invention adopts the improved Canny operator to perform edge detection, and the specific steps are as follows:

步骤1-1、用均值滤波对处理的二值化图像进行滤波;Step 1-1, filter the processed binarized image with mean filtering;

步骤1-2、用sobel算子模板的一阶微分提取边缘,计算出梯度和梯度幅值;Step 1-2, extract the edge with the first-order differential of the sobel operator template, and calculate the gradient and gradient amplitude;

步骤1-3、根据计算的梯度和梯度幅值进行非极大值抑制;Steps 1-3, perform non-maximum suppression according to the calculated gradient and gradient amplitude;

步骤1-4、自适应选取最高和最低阈值,对图像进行阈值化;Steps 1-4, adaptively select the highest and lowest thresholds, and threshold the image;

步骤1-5、根据高低阈值处理后,进行边缘连接,得到图像中所有闭区域的边界以及最小外接矩形的四个角点。Steps 1-5: After processing according to the high and low thresholds, perform edge connection to obtain the boundaries of all closed regions in the image and the four corners of the minimum circumscribed rectangle.

该改进的检测方法可克服传统的Canny算子边界模糊效应明显,细节丢失比较严重,对椒盐噪声敏感等技术问题,采用改进Canny算子进行边缘检测后得到如图7所示结果。The improved detection method can overcome the traditional Canny operator with obvious boundary blur effect, serious loss of details, and sensitivity to salt and pepper noise.

第三步,粘连区域目标识别,对已经识别出的单个目标进行填充(只留下粘连区域的目标),本例填充操作在母图像中进行,从而确保面积阈值的唯一,得到如图8所示填充后的结果,此图像中,单个目标已全部识别,只留下有粘连的目标物体,以及填充后的缝隙;进入粘连区域处理流程,与主流程一致,对图像进行边缘检测,并计算连通域的面积(以像素为单位),得到有粘连区域的面积序列;The third step, target recognition in the adhesion area, fill in the identified single target (only the target in the adhesion area is left). In this example, the filling operation is performed in the parent image to ensure the uniqueness of the area threshold, as shown in Figure 8 The result after filling is shown. In this image, a single target has been recognized, leaving only the glued target object and the gap after filling; enter the glued area processing flow, which is consistent with the main flow, perform edge detection on the image, and calculate The area of the connected domain (in pixels) to obtain the area sequence of the glued regions;

本例中以填充后的图像为例,得到连通域面积如下所示(共32个连通域),粘连区域连通域面积序列:In this example, taking the filled image as an example, the connected domain area is obtained as follows (32 connected domains in total), and the connected domain area sequence of the adhesion region:

14810、5954、15770、15585、6504、14268、14837、28485、14856、14487、12695、13760、14154、14466、12202、13530、23277、14586、12902、13705、13539、13617、12641、13682、13989、12707、12861、26164、20286、11670、11737、19274;14810、5954、15770、15585、6504、14268、14837、28485、14856、14487、12695、13760、14154、14466、12202、13530、23277、14586、12902、13705、13539、13617、12641、13682、13989、 12707, 12861, 26164, 20286, 11670, 11737, 19274;

面积分布情况如图9所示,对该面积序列采用k均值聚类分析。The area distribution is shown in Figure 9, and k-means cluster analysis is used for the area sequence.

可采用经典的K均值聚类算法(K-MEANS算法)进行分析,但经典的K均值聚类算法存在两个问题:一是,初始聚类中心随机选定,导致聚类划分不稳定,容易出现局部最优解;二是,K均值聚类算法需要人为事先指定聚类划分数K,这大大限制了他的应用范围。因此,本发明采用了改进的k均值聚类算法,目的是解决两个问题:首先,为了确保聚类划分的一致性与合理性,初始聚类中心点距离要尽可能的大;其次,要解决聚类划分数目K的最优化评价。以上两点直接关系计数结果的准确性。The classical K-means clustering algorithm (K-MEANS algorithm) can be used for analysis, but the classical K-means clustering algorithm has two problems: First, the initial clustering center is randomly selected, resulting in unstable clustering and easy There is a local optimal solution; second, the K-means clustering algorithm needs to manually specify the number of clustering divisions K in advance, which greatly limits its application range. Therefore, the present invention adopts an improved k-means clustering algorithm to solve two problems: first, in order to ensure the consistency and rationality of cluster division, the distance between the initial cluster center points should be as large as possible; Solve the optimal evaluation of the number K of cluster divisions. The above two points are directly related to the accuracy of the counting results.

本发明的改进的k均值聚类算法,包括以下步骤:The improved k-means clustering algorithm of the present invention includes the following steps:

步骤2-1、选择初始聚类中心点,包括:Step 2-1. Select the initial cluster center point, including:

①输入面积序列集合{xi},在{xi}中找出最大值xmax和最小值xmin①Enter the area sequence set {xi }, find the maximum value xmax and the minimum value xmin in {xi };

②为了减小k值的搜索范围,确定可能的最大聚类数目

Figure BDA0001913411350000081
式中,Ait为最小面积阈值,ceil代表向上取整;② In order to reduce the search range of the k value, determine the maximum number of possible clusters
Figure BDA0001913411350000081
In the formula, Ait is the minimum area threshold, and ceil represents rounding up;

为了完成图像的分割和计数,需要设定最小面积阈值。因CCD相机镜头焦距以及与目标之间的距离固定,所以目标物体成像后的大小也固定。故不同的系统都可以适当的选取合适的面积阈值,本专利采用的面积阈值为Ait∈(6200,7000)。In order to complete the segmentation and counting of images, a minimum area threshold needs to be set. Because the focal length of the CCD camera lens and the distance from the target are fixed, the size of the target object after imaging is also fixed. Therefore, different systems can appropriately select an appropriate area threshold. The area threshold used in this patent is Ait ∈ (6200,7000).

③确定kmax个初始聚类中心的备选集合(kmax≥2);③ Determine the candidate set of the initial clustering centers of kmmax (kmmax ≥ 2);

Figure BDA0001913411350000091
Figure BDA0001913411350000091

由此给出的初始聚类中心是等间隔的,不同面积序列的聚类之间满足等差数列的关系;The given initial cluster centers are equally spaced, and the clusters of different area sequences satisfy the relationship of arithmetic sequence;

步骤2-2、考虑到器件粘连个数的任意性,从这kmax个备选聚类中心中选择k个值(从k=2开始),作为理论聚类中心,遍历所有可能的取法,共有

Figure BDA0001913411350000092
种;针对每种选取方法,运行标准的K-MEANS算法,并计算Eval(k)的值;Step 2-2. Considering the arbitrariness of the number of device adhesions, select k values (starting from k=2) from the kmax candidate clustering centers as the theoretical clustering centers, and traverse all possible methods. shared
Figure BDA0001913411350000092
For each selection method, run the standard K-MEANS algorithm and calculate the value of Eval(k);

Figure BDA0001913411350000093
Figure BDA0001913411350000093

其中,k为聚类个数,Ci为实际聚类中心,Ii为理论聚类中心,di=|Ci-Ii|为实际聚类中心与理论聚类中心之间的距离,

Figure BDA0001913411350000094
是聚类个数为k时di的平均值;可知,Eval(k)实际上是聚类间距的方差,体现了样本对理论聚类中心的集中程度,Eval(k)的值越小,集中度越好。Among them, k is the number of clusters, Ci is the actual cluster center, Ii is the theoretical cluster center, di =|Ci -Ii | is the distance between the actual cluster center and the theoretical cluster center,
Figure BDA0001913411350000094
is the average value of di when the number of clusters is k; it can be seen that Eval(k) is actually the variance of the cluster spacing, which reflects the concentration of the sample on the theoretical cluster center. The smaller the value of Eval(k), the The better the concentration.

步骤2-3、聚类划分个数k增加1,重复2-2~2-3步骤,直到达到kmax为止;Step 2-3, the number of clustering division k is increased by 1, and steps 2-2 to 2-3 are repeated until the kmax is reached;

步骤2-4、比较kmax个Eval(k)的值,取Eval(k)最小值时,对应的k即是最合理的聚类划分个数;Step 2-4, compare the values of kmax Eval(k), when taking the minimum value of Eval(k), the corresponding k is the most reasonable number of clustering divisions;

结果如图10所示,面积序列被自动分成四类,四个聚类中心值及每个粘连区域对于目标个数如下表所示。The results are shown in Figure 10. The area sequence is automatically divided into four categories. The four cluster center values and the number of targets for each adhesion area are shown in the table below.

聚类中心:Cluster center:

表1强粘连区域面积序列聚类分析结果Table 1 Results of cluster analysis of the area of strong adhesion area

Figure BDA0001913411350000095
Figure BDA0001913411350000095

Figure BDA0001913411350000101
Figure BDA0001913411350000101

步骤2-5、根据上述聚类划分个数统计结果,进而计算出粘连目标的物体数目。Steps 2-5, according to the above-mentioned statistical result of the number of cluster divisions, and then calculate the number of objects of the adhesion target.

至此完成了对一幅含有多个钽电容,有粘连的图像的目标物体统计和计数。So far, the statistics and counting of a target object containing a plurality of tantalum capacitors and an image with adhesion have been completed.

以上所述实施例仅表达了本发明的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对本发明专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本发明构思的前提下,还可以做出若干变形和改进,这些都属于本发明的保护范围。The above-mentioned embodiments only represent several embodiments of the present invention, and the descriptions thereof are specific and detailed, but should not be construed as limiting the scope of the patent of the present invention. It should be noted that, for those skilled in the art, without departing from the concept of the present invention, several modifications and improvements can be made, which all belong to the protection scope of the present invention.

Claims (7)

Translated fromChinese
1.一种基于图像识别技术的多目标计数方法,其特征在于,包括以下步骤:1. a multi-target counting method based on image recognition technology, is characterized in that, comprises the following steps:图像预处理:采集原始图像,对原始图像进行灰度处理,获取灰度图像;采用直方图统计,自动调节灰度阈值,对灰度图像进行二值化,获得二值化图像;Image preprocessing: collect the original image, perform grayscale processing on the original image, and obtain a grayscale image; use histogram statistics, automatically adjust the grayscale threshold, and binarize the grayscale image to obtain a binarized image;目标物体无粘连和有粘连区域的区分:对二值化图像进行形态学操作,采用边缘检测算法,识别出连续的图像边缘;根据目标物体的面积参数,设定面积阈值,根据面积阈值对图像进行划分,小于面积阈值即认为是独立的目标物体,大于面积阈值即认为是可能的有粘连的目标物体,从而实现无粘连和有粘连区域的区分;Distinguish between non-adhesion and adhesion areas of the target object: perform morphological operations on the binarized image, and use edge detection algorithms to identify continuous image edges; Divide it, if it is smaller than the area threshold, it is considered as an independent target object, and if it is larger than the area threshold, it is considered as a possible target object with adhesion, so as to realize the distinction between non-adhesion and adhesion areas;对无粘连区域独立目标物体进行统计;Count the independent target objects in the non-adhesion area;对粘连区域粘连目标物体的处理:在对于无粘连区域进行标记和统计后,在原二值化图像中进行填充,得到只含有粘连区域目标物体和填充缝隙的二值化图像;再用边缘检测算法,识别图像的边缘,并计算连通区域的面积,得到粘连目标物体的面积序列;采用k均值聚类算法,对面积序列进行分类,通过判断聚类中心是否满足等差数列来进行最优化选择,实现有粘连区域的目标物体个数自动统计和计数。Processing of the adhesion target object in the adhesion area: after marking and counting the non-adhesion area, fill in the original binarized image to obtain a binary image that only contains the target object in the adhesion area and the filling gap; then use the edge detection algorithm , identify the edge of the image, and calculate the area of the connected area to obtain the area sequence of the adhering target object; use the k-means clustering algorithm to classify the area sequence, and optimize the selection by judging whether the cluster center satisfies the arithmetic sequence. Realize the automatic counting and counting of the number of target objects with adhesion areas.2.根据权利要求1所述的一种基于图像识别技术的多目标计数方法,其特征在于:原始图像的获取采用彩色相机或者单色相机对目标图像进采集。2 . The multi-target counting method based on image recognition technology according to claim 1 , wherein the acquisition of the original image adopts a color camera or a monochrome camera to collect the target image. 3 .3.根据权利要求1所述的一种基于图像识别技术的多目标计数方法,其特征在于:所述形态学操作包括一次或多次的腐蚀和/或膨胀操作。3 . The multi-target counting method based on image recognition technology according to claim 1 , wherein the morphological operation includes one or more erosion and/or dilation operations. 4 .4.根据权利要求3所述的一种基于图像识别技术的多目标计数方法,其特征在于:形态学操作的腐蚀操作中,根据实际目标物体大小选择合适的算子。4 . The multi-target counting method based on image recognition technology according to claim 3 , wherein: in the corrosion operation of the morphological operation, an appropriate operator is selected according to the size of the actual target object. 5 .5.根据权利要求1所述的一种基于图像识别技术的多目标计数方法,其特征在于,所述边缘检测算法为利用canny算子、sobel算子或Laplacian算子进行边缘检测。5 . A multi-target counting method based on image recognition technology according to claim 1 , wherein the edge detection algorithm uses canny operator, sobel operator or Laplacian operator to perform edge detection. 6 .6.根据权利要求5所述的一种基于图像识别技术的多目标计数方法,其特征在于,所述边缘检测为改进的Canny算子边缘检测方法,步骤包括:6. a kind of multi-target counting method based on image recognition technology according to claim 5, is characterized in that, described edge detection is improved Canny operator edge detection method, and step comprises:步骤1-1、用均值滤波对处理的二值化图像进行滤波;Step 1-1, filter the processed binarized image with mean filtering;步骤1-2、用sobel算子模板的一阶微分提取边缘,计算出梯度和梯度幅值;Step 1-2, extract the edge with the first-order differential of the sobel operator template, and calculate the gradient and gradient amplitude;步骤1-3、根据计算的梯度和梯度幅值进行非极大值抑制;Steps 1-3, perform non-maximum suppression according to the calculated gradient and gradient amplitude;步骤1-4、自适应选取最高和最低阈值,对图像进行阈值化;Steps 1-4, adaptively select the highest and lowest thresholds, and threshold the image;步骤1-5、根据高低阈值处理后,进行边缘连接,得到图像中所有闭区域的边界以及最小外接矩形的四个角点。Steps 1-5: After processing according to the high and low thresholds, perform edge connection to obtain the boundaries of all closed regions in the image and the four corners of the minimum circumscribed rectangle.7.根据权利要求1所述的一种基于图像识别技术的多目标计数方法,其特征在于,采用改进的k均值聚类算法,对面积序列进行分类,通过判断聚类中心是否满足等差数列来进行最优化选择,实现有粘连区域的目标物体个数自动统计和计数,包括以下步骤:7. a kind of multi-target counting method based on image recognition technology according to claim 1, is characterized in that, adopts improved k-means clustering algorithm, classifies the area sequence, by judging whether the cluster center satisfies the arithmetic progression To make the optimal selection, realize the automatic counting and counting of the number of target objects in the adhesion area, including the following steps:步骤2-1、选择初始聚类中心点,包括:Step 2-1. Select the initial cluster center point, including:②输入面积序列集合{xi},在{xi}中找出最大值xmax和最小值xmin②Enter the area sequence set {xi }, find the maximum value xmax and the minimum value xmin in {xi };②为了减小k值的搜索范围,确定可能的最大聚类数目
Figure FDA0001913411340000021
式中,Ait为最小面积阈值,ceil代表向上取整;② In order to reduce the search range of the k value, determine the maximum number of possible clusters
Figure FDA0001913411340000021
In the formula, Ait is the minimum area threshold, and ceil represents rounding up;③确定kmax个初始聚类中心的备选集合(kmax≥2);③ Determine the candidate set of the initial clustering centers of kmmax (kmmax ≥ 2);
Figure FDA0001913411340000022
Figure FDA0001913411340000022
由此给出的初始聚类中心是等间隔的,不同面积序列的聚类之间满足等差数列的关系;The given initial cluster centers are equally spaced, and the relationship between the clusters of different area sequences satisfies the arithmetic sequence relationship;步骤2-2、从这kmax个备选聚类中心中选择k个值(从k=2开始),作为理论聚类中心,遍历所有可能的取法,共有
Figure FDA0001913411340000031
种;针对每种选取方法,运行标准的K-MEANS算法,并计算Eval(k)的值;
Step 2-2. Select k values (starting from k=2) from the kmax candidate cluster centers, as the theoretical cluster centers, traverse all possible methods, and there are a total of
Figure FDA0001913411340000031
For each selection method, run the standard K-MEANS algorithm and calculate the value of Eval(k);
Figure FDA0001913411340000032
Figure FDA0001913411340000032
其中,k为聚类个数,Ci为实际聚类中心,Ii为理论聚类中心,di=|Ci-Ii|为实际聚类中心与理论聚类中心之间的距离,
Figure FDA0001913411340000033
是聚类个数为k时di的平均值;
Among them, k is the number of clusters, Ci is the actual cluster center, Ii is the theoretical cluster center, di =|Ci -Ii | is the distance between the actual cluster center and the theoretical cluster center,
Figure FDA0001913411340000033
is the average value of di when the number of clusters is k;
步骤2-3、聚类划分个数k增加1,重复2-2~2-3步骤,直到达到kmax为止;Step 2-3, the number of clustering division k is increased by 1, and steps 2-2 to 2-3 are repeated until the kmax is reached;步骤2-4、比较kmax个Eval(k)的值,取Eval(k)最小值时,对应的k即是最合理的聚类划分个数;Step 2-4, compare the values of kmax Eval(k), when taking the minimum value of Eval(k), the corresponding k is the most reasonable number of clustering divisions;步骤2-5、根据聚类划分个数统计获得各粘连目标的聚类个数后,进而计算出粘连目标的物体数目。Step 2-5: After the number of clusters of each adhesion target is obtained according to the statistics of the number of cluster divisions, the number of objects of the adhesion target is then calculated.
CN201811567432.5A2018-12-202018-12-20Multi-target counting method based on image recognition technologyActiveCN109636824B (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN201811567432.5ACN109636824B (en)2018-12-202018-12-20Multi-target counting method based on image recognition technology

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN201811567432.5ACN109636824B (en)2018-12-202018-12-20Multi-target counting method based on image recognition technology

Publications (2)

Publication NumberPublication Date
CN109636824A CN109636824A (en)2019-04-16
CN109636824Btrue CN109636824B (en)2022-10-11

Family

ID=66076126

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN201811567432.5AActiveCN109636824B (en)2018-12-202018-12-20Multi-target counting method based on image recognition technology

Country Status (1)

CountryLink
CN (1)CN109636824B (en)

Families Citing this family (14)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN110264463A (en)*2019-06-252019-09-20北京实验工厂有限责任公司A kind of material counting method based on matlab image procossing
CN112307828B (en)*2019-07-312024-09-10梅特勒-托利多(常州)测量技术有限公司Counting verification device, counting system and method
CN112819745B (en)*2019-10-312023-02-28合肥美亚光电技术股份有限公司Nut kernel center worm-eating defect detection method and device
CN111058182A (en)*2019-12-252020-04-24杭州晶一智能科技有限公司Yarn state detection method based on projection area statistics
CN111583255B (en)*2020-05-192023-06-13东莞市瑞图新智科技有限公司Multi-domain-oriented high-adaptability identification and counting method
CN111753851B (en)*2020-07-012022-06-07中国铁路设计集团有限公司Railway snow depth and wind and snow migration track monitoring method and system based on image processing
CN112560787B (en)*2020-12-282024-11-22深研人工智能技术(深圳)有限公司 A method, device and related components for setting boundary threshold of pedestrian re-identification matching
CN113139934B (en)*2021-03-262024-04-30上海师范大学Rice grain counting method
CN113313692B (en)*2021-06-032023-04-25广西大学Automatic banana young plant identification and counting method based on aerial visible light image
CN114565556B (en)*2022-01-142025-03-14西安理工大学 Method for identifying the state of plasma electrolytic oxidation reaction based on image processing
CN114926492A (en)*2022-05-202022-08-19中国建设银行股份有限公司Image data processing method and device and server
CN115345879B (en)*2022-10-182023-03-24济宁康盛彩虹生物科技有限公司Method for analyzing corrosion degree of inner wall of autoclave and predicting service life of autoclave based on image
CN115546462A (en)*2022-12-012022-12-30南京维拓科技股份有限公司Method for extracting shape features of product and counting based on image recognition
CN115619789B (en)*2022-12-202023-03-31山西蒲谷香农业科技有限公司Pill forming control method for production of black sesame pills

Citations (4)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
EP1282076A2 (en)*2001-07-312003-02-05Canon Kabushiki KaishaSelf-adaptive binarization of digital images
CN102043950A (en)*2010-12-302011-05-04南京信息工程大学Vehicle outline recognition method based on canny operator and marginal point statistic
WO2014067296A1 (en)*2012-11-052014-05-08深圳市恩普电子技术有限公司Method for identifying, tracing and measuring internal and external membranes of vessel
CN107895376A (en)*2017-12-112018-04-10福州大学Based on the solar panel recognition methods for improving Canny operators and contour area threshold value

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
EP1282076A2 (en)*2001-07-312003-02-05Canon Kabushiki KaishaSelf-adaptive binarization of digital images
CN102043950A (en)*2010-12-302011-05-04南京信息工程大学Vehicle outline recognition method based on canny operator and marginal point statistic
WO2014067296A1 (en)*2012-11-052014-05-08深圳市恩普电子技术有限公司Method for identifying, tracing and measuring internal and external membranes of vessel
CN107895376A (en)*2017-12-112018-04-10福州大学Based on the solar panel recognition methods for improving Canny operators and contour area threshold value

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
PMMW金属目标图像处理与计数技术实现;林晓敏等;《电光与控制》;20120701(第07期);全文*
基于局部期望阈值分割的图像边缘检测算法;刘占;《计算机与现代化》;20160812(第08期);全文*

Also Published As

Publication numberPublication date
CN109636824A (en)2019-04-16

Similar Documents

PublicationPublication DateTitle
CN109636824B (en)Multi-target counting method based on image recognition technology
CN110286124B (en)Machine vision-based refractory brick measuring system
CN110334706B (en)Image target identification method and device
CN106651846B (en) Segmentation method of retinal blood vessel images
CN110230978A (en)A kind of refractory brick geometric dimension measurement method
Qing et al.Automated detection and identification of white-backed planthoppers in paddy fields using image processing
CN107220649A (en)A kind of plain color cloth defects detection and sorting technique
CN108765465A (en)A kind of unsupervised SAR image change detection
CN111667475B (en)Machine vision-based Chinese date grading detection method
CN111695373B (en)Zebra stripes positioning method, system, medium and equipment
WO2021109697A1 (en)Character segmentation method and apparatus, and computer-readable storage medium
CN110648330B (en)Defect detection method for camera glass
CN115375629B (en)Line defect detection and defect information extraction method for LCD screen
CN103971367B (en)Hydrologic data image segmenting method
CN103489187A (en)Quality test based segmenting method of cell nucleuses in cervical LCT image
CN111476804A (en)Method, device and equipment for efficiently segmenting carrier roller image and storage medium
CN110176020A (en)A kind of bird's nest impurity method for sorting merging 2D and 3D rendering
CN115587966A (en) A method and system for detecting whether parts are missing or not under the condition of uneven illumination
CN106327490A (en)Nucleus segmentation method based on white blood cell detection
CN109101976A (en)A kind of detection method of arc extinguishing grid pieces surface defect
CN113850792A (en)Cell classification counting method and system based on computer vision
CN117036259A (en)Metal plate surface defect detection method based on deep learning
CN119048521B (en) Method, device and computer equipment for counting milk somatic cells
CN110619273B (en)Efficient iris recognition method and recognition device
CN115511814A (en) An image quality assessment method based on fusion of multi-texture features in regions of interest

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination
GR01Patent grant
GR01Patent grant
TR01Transfer of patent right
TR01Transfer of patent right

Effective date of registration:20231008

Address after:Room 13, Building 38, Suning Yaju, No. 258 Baota Road, Chunxi Street, Gaochun District, Nanjing City, Jiangsu Province, 210000

Patentee after:Jiangsu Dingwei Technology Co.,Ltd.

Address before:238000 Hechao Economic Development Zone, Hefei City, Anhui Province

Patentee before:CHAOHU University

TR01Transfer of patent right

Effective date of registration:20250918

Address after:311200 Zhejiang Province, Hangzhou City, Qiantang District, Xiaoshan Street, Yinsha Road 166, Building B, Room 1902-1

Patentee after:Hangzhou Zhiju Network Technology Achievement Transformation Service Co.,Ltd.

Country or region after:China

Address before:Room 13, Building 38, Suning Yaju, No. 258 Baota Road, Chunxi Street, Gaochun District, Nanjing City, Jiangsu Province, 210000

Patentee before:Jiangsu Dingwei Technology Co.,Ltd.

Country or region before:China


[8]ページ先頭

©2009-2025 Movatter.jp