简体   繁体   English

二进制图像,带有OpenCV的白点浓度

[英]Binary Image, Concentrations of White Dots with OpenCV

Given a binary image of black, with a few sporadic white dots, I'm looking for a way to "lasso" a majority of the white dots inside a bounding rectangle. 给定黑色的二进制图像,并带有一些零星的白色点,我正在寻找一种方法来“套索”边界矩形内的大部分白色点。 Consider this image: 考虑这张图片:

在此处输入图片说明

See how not all of the dots are enclosed, but just the clusters (or set of clusters) where there are clearly more white dots than anywhere else? 看到不是所有的点都被包围,而是白点(或簇集)的白点明显比其他地方多吗?

I already know how to put a bounding box around all of the white dots with OpenCV. 我已经知道如何使用OpenCV 在所有白点周围放置边框 Can anyone direct me as to how I can analyze this image for one big concentration of dots , ignoring any peripheral dots which are not really part of a group? 谁能指导我如何分析图像中的大量点 ,而忽略不属于组的任何外围点?

NB: This bounding box doesn't have to be skew. 注意:此边界框不必倾斜。 Even a convex hull would be nice as output. 即使是凸包,也可以作为输出。

I can adjust the size, color, alpha, location, density, etc. of these dots. 我可以调整这些点的大小,颜色,alpha,位置,密度等。 So if your thoughts involve doing something with these dots in order to process them, that might work. 因此,如果您的想法涉及对这些点进行处理以进行处理,则可能会起作用。

What you need is sort of a 1-cluster detection algorithm, where outlier detection is important. 您需要一种1-cluster检测算法,其中离群值检测很重要。 Clustering algorithms in general are designed and tuned to produce more than one cluster; 通常,对聚类算法进行设计和调整,以产生多个集群。 a portion of them (k-means for example) do not even handle outliers. 其中的一部分(例如k均值)甚至不处理异常值。 If you decide to use a real clustering algorithm, try DBSCAN and set it to detect 1 cluster - it has outlier detection ability. 如果决定使用真正的群集算法,请尝试DBSCAN并将其设置为检测1个群集-它具有异常检测能力。

Otherwise, you can consider your problem as a metric maximization problem. 否则,您可以将您的问题视为度量最大化问题。

You want a metric that is rewarded for data density, but also rewarded for box size (so you don't end up with a 1x1 box). 您想要一个既可以提高数据密度又可以提高包装盒尺寸的度量标准(因此最终不会得到1x1的包装盒)。 I propose something along the lines of: 我提出以下建议:

metric_to_maximize = White_Dot_Density * Area^x , where x is calibrated ad hoc. metric_to_maximize = White_Dot_Density * Area^x ,其中x是临时校准的。

Another idea that may work is to divide the image into mxn box-rectangles. 可行的另一个想法是将图像划分为mxn矩形框。 Calculate each box's average density. 计算每个盒子的平均密度。 Pick the top x% (or all rectangles that have density>threshold ). 选择顶部的x%(或所有具有density>threshold矩形)。 Create a bounding box around these "good boxes" without including too much additional area. 围绕这些“好盒子”创建一个边界框,而不会包含过多的额外区域。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM