聚类像素凝块

计算科学 聚类
2021-12-17 08:37:30

我有:
1) 带有几组高亮度像素的暗图像,周围有一些噪点。
2) 簇数。

示例:
1) 2) 2 个集群
聚类图像

我需要找到明亮像素组的中心。
在这种情况下,中心应该像这样放置:问题:哪种聚类算法适合这项任务?
以图像为中心的聚类

1个回答

如果集群的数量是已知的(像这里)

您可以使用 Lloyd 的聚类 [1]

思路如下:优化一组聚类中心pi

Initialize the p_i's with an initial guess, or randomly

For each iteration:
   Compute the cluster associated with each p_i,
      (the cluster is the set of points nearer to p_i than to the other p_j's)
   Move each p_i to the weighted centroid of its cluster

对于图像,迭代可以如下实现,计算每个簇的质量 m_i 和质心 g_i:

For each i
   m_i = 0
   g_i = (0,0)
For each pixel (x,y) of the image
   let i denote the index of the center p_i nearest to (x,y)
   m_i = m_i + pixel_intensity(x,y)
   g_i = g_i + pixel_intensity(x,y) * (x,y)
For each i
   p_i = (1/m_i)*g_i

由于集群的数量很少,您可以使用简单的循环找到最近的 p_i。如果您有更多的站点,您可以使用 kd-tree,或者计算站点的 Voronoi 图并迭代每个 Voronoi 单元的像素。

我使用该算法对由乐高颜色传感器获取的 rubics 立方体的颜色进行聚类,它工作得相当好,同时非常容易实现 [3]

如果集群的数量未知 ,那么问题就困难得多。

您可以使用“均值偏移聚类”[2],它将对图像应用类似过滤器的操作,并使“模式”出现。它的作用类似于平滑滤波器的逆。

[1] https://en.wikipedia.org/wiki/Lloyd%27s_algorithm

[2] https://en.wikipedia.org/wiki/Mean_shift

[3] http://alice.loria.fr/WIKI/index.php/Graphite/Lego