How to draw polygon having set of unordered points?

8 ビュー (過去 30 日間)
Abinaya
Abinaya 2014 年 3 月 17 日
コメント済み: Image Analyst 2018 年 11 月 14 日
How to draw polygon having set of unordered points in binary image.I want approximately all the points to be connected in the polygon which function would help?

回答 (1 件)

Image Analyst
Image Analyst 2014 年 3 月 17 日
There are multiple polygons that could be drawn this way. You must describe some algorithm for how to order them, such as the angle to the next point must always be clockwise (or counterclockwise) or something like that. You could find the centroid (average of x and y) then calculate angles of all points, and then sort based on angles. Is that what you want to do?
Here's some untested code:
meanx = mean(x);
meany = mean(y);
angles = atan( (y-ymean) ./ (x-xmean));
[sortedAngles, sortIndices] = sort(angles);
reorderedx = x(sortIndices);
reorderedy = y(sortIndices);
plot(reorderedx, reorderedy, 'bo-');
  7 件のコメント
Wen Fang
Wen Fang 2018 年 11 月 14 日
Image Analyst
Image Analyst 2018 年 11 月 14 日
Try delaunayn()
T = delaunayn(X) computes a set of simplices such that no data points of X are contained in any circumspheres of the simplices. The set of simplices forms the Delaunay triangulation. X is an m-by-n array representing m points in n-dimensional space. T is a numt-by-(n+1) array where each row contains the indices into X of the vertices of the corresponding simplex.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDelaunay Triangulation についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by