看这个例子:
上面的行是:
final List<Line2d> lines = Voronoi.computeVoronoiEdges(java.util.Arrays.asList(centroids), image.getWidth(),
image.getHeight());
我添加了另一行:
final Graph<Point2d, DefaultEdge> graph = Voronoi.computeVoronoiGraph(java.util.Arrays.asList(centroids), image.getWidth(),
image.getHeight());
但这与:
Exception in thread "Thread-0" java.lang.IllegalArgumentException: no such vertex in graph
at org.jgrapht.graph.AbstractGraph.assertVertexExist(Unknown Source)
at org.jgrapht.graph.AbstractBaseGraph.addEdge(Unknown Source)
at org.openimaj.math.geometry.triangulation.Voronoi.computeVoronoiGraph(Voronoi.java:88)
at uk.ac.soton.ecs.comp3204.l2.KMeansDemo.drawVoronoi(KMeansDemo.java:260)
有什么想法为什么会打破?
我的高级目标是从上述任何一种方法(或者如果使用上述方法是错误的方法,则从任何其他方法)的输出中获取多边形(而不是线)。正确的方法是什么?