在 MATLAB 中的数据簇上绘制多边形时出现问题

发布于 2024-09-03 09:45:30 字数 503 浏览 4 评论 0原文

我有一些数据点,我用一些聚类算法将它们分成了一些簇,如下图所示:(图像可能需要一些时间才能出现) 替代文本 http://www.freeimagehosting.net/uploads/05a807bc42.png

每个颜色代表不同的簇。我必须在每个簇周围绘制多边形。出于这个原因,我使用 convhull。但正如您所看到的,红色簇的多边形非常大并且覆盖了很多区域,这不是我要寻找的多边形。我需要精确地围绕我的数据集绘制线条(多边形)。例如,在上图中,我想要一个与具有 3 个分支的红色簇完全相同(且围绕)绘制的多边形。换句话说,在这种情况下,我需要一个具有 3 个分支的多边形来覆盖我的红色簇,而不是覆盖整个区域的大多边形。谁能帮我解决这个问题吗? 请注意,解决方案应该是通用的,因为聚类在算法的每次运行中都会发生变化,因此它需要采用通用的方式。

I have some data points which I have devided into them into some clusters with some clustering algorithms as the picture below:(it might takes some time for the image to appear)
alt text http://www.freeimagehosting.net/uploads/05a807bc42.png

Each color represents different cluster. I have to draw polygons around each cluster. I use convhull for this reason. But as you can see the polygon for the red cluster is very big and covers a lot of areas, which is not the one I am looking for. I need to draw lines(ploygons) exactly around my data sets. For example in the picture above I want a polygon that is drawn exactly the same(and around) as the red cluster with the 3 branches. In other words, in this case I need a polygon with 3 branches to cover my red clusters not that big polygon that covers the whole area. Can anyone help me with this?
Please Note that the solution should be general, because the clusters will change in each run of the algorithm, so it needs to be in a way that is general.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

淡看悲欢离合 2024-09-10 09:45:30

我不确定这是一个完全指定的问题。我发现这个问题的这种变体经常出现。

为什么这个问题不能在这里得到真正的答案:想象六个点,三个点在一个等边三角形中,另外三个点在其内部的等边三角形中,方向相同。

正确的船体是什么?它只是凸包吗?它是一个内三角形,有三个线支线从中伸出吗?三角形的相对大小重要吗?那么您是否必须指定该参数?

I am not sure this is a fully specified question. I see this variants on this question come up quite often.

Why this can not really be answered here: Imagine six points, three in an equilateral triangle with another three in an equilateral triangle inside it in the same orientation.

What is the correct hull around this? Is it just the convex hull? Is it the inner triangle with three line spurs coming out from it? Does it matter what the relative sizes of the triangles are? Should you have to specify that parameter then?

萌无敌 2024-09-10 09:45:30

如果您的簇非常紧凑,您可以尝试以下操作:

  1. 创建一个网格,例如间距为 0.1。
  2. 如果至少有一个数据点覆盖网格中的每个像素,则将其设置为 1;如果没有数据点覆盖该像素,则将像素设置为 0。
  3. 您可能需要在蒙版上运行 imclose 来填充由于运气不好而未着色的内部小孔。
  4. 使用例如bwperim 提取边框像素。这是您要寻找的多边形的轮廓。

If your clusters are very compact, you could try the following:

  1. Create a grid, say with a spacing of 0.1.
  2. Set every pixel in the grid to 1 if there's at least one data point covering it, set the pixel to 0 if there is no data point covering the pixel.
  3. You may need to run imclose on your mask in order to fill little holes inside that have not been colored due to sheer bad luck.
  4. Extract the border pixels using, e.g. bwperim. This is the outline of the polygon you're looking for.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文