【发布时间】:2013-09-28 22:19:10
【问题描述】:
我正在寻找一种算法,该算法将从图像中生成凹多边形(具有 N 个点,其中 N > 3 - 用户输入此值)。
我对算法的想法:
// Every pixel in image is checked and a minimal orientated bounding box is generated (transparent pixels are ignored)
boundingBox = createImageBoundingBox(image);
curpoints = 4, A = 0, B = 1, tmppoints = curpoints;
while(curpoints < maxNumberOfPoints)
{
add a new point between point A and point B (A and B are points from the boundingBox)
reposition points so that it will contain the minimal surface
A++; B++;
curpoints++;
if(A == tmppoints)
{ A = 0; B = 1; tmppoints=curpoints; }
}
我面临的问题是我不知道如何以最佳方式重新定位点。这可以通过任何其他方式完成(更好/更快的方式)。如有任何想法,将不胜感激。
谢谢
编辑:
图片必须至少为 10x10。我需要 N 点参数,以便用户可以调节要使用的点数(用于优化)。另一种方法是使用一个因子 (0-1),它告诉您希望多边形具有多少细节(多少点)(0 是 4 个点,> 0 5 个或更多点)。但不确定如何实施。
【问题讨论】:
-
这总是可能的吗?如果我的图像是一个像素高和 200 像素宽怎么办?这种情况似乎会产生一条线。我正在查找“多边形”和“凹多边形”的不同定义,但没有看到这种病态病例的任何定义。
-
图像必须大于 100x100。 mathworld.wolfram.com/ConcavePolygon.html。不确定是否有任何区别,但我发现了一些仅适用于凸多边形的算法。