how to join these random points in a desired rectangle shape automatically by programming..

3 次查看(过去 30 天)
i am able to join these points in rectangle by manually arrange in order..but i want to arrange automatically in programming by image processing techniques... i also checked chaincode method in image processing..this is beneficial for 8-connected points but my points are not adjacent neighbors.. I have two vectors f1 in x-axis and f2 in y-axis..
f1 = [25.0 25.0 25.0 25.0 25.0 26.8 27.4 29.8 30.2 32.2 33.6 33.9 35 35 35 35]
f2 = [-3.5 -4.9 0.9 -5.3 -0.4 1.9 -5.3 1.6 -5.3 1.7 -5.3 1.8 -5.5 -4.9 -3.1 0]
points are like:
(25.0, -3.5)
(25.0, -4.9)
(25.0, 0.9)
(25.0, -5.3)
(25.0, -0.4)
(26.8, 1.9)
(27.4, -5.3)
(29.8, 1.6)
(30.2, -5.3)
(32.2, 1.7)
(33.6, -5.3)
(33.9, 1.8)
(35, -5.5)
(35, -4.9)
(35, -3.1)
(35, 0)

采纳的回答

Walter Roberson
Walter Roberson 2019-5-1
k = boundary(f1(:), f2(:), 0.5);
plot(f1(k), f2(k));
The 0.5 parameter can be adjusted. The largest that works is about 0.777
  4 个评论
Walter Roberson
Walter Roberson 2019-5-1
Yes. You can use discretize the coordinates and write to locations at the appropriate offsets, using a double array (or at least not a logical array.) Then you can regionprops() that array; regionprops will see that the array is not logical and will treat the values as label numbers, and since the labels are all the same, will treat everything as belonging to one object (that happens to have a lot of holes in it.) The 'boundingbox' property will then tell you where the lower left corner is of a box that includes all of the points, together with the height and the width.
This is an "image processing" approach to the problem.
It is also wasteful. If all you care about is the bounding box, just take min() and max() of the X and Y coordinates.

请先登录,再进行评论。

更多回答(1 个)

VANDANA GUPTA
VANDANA GUPTA 2019-5-8
sir, i have an one more query. i made a 2-d figure 'c.png' in matlab by using r and theta and with the help of boundary function as u helped..now i want to make a figure 'p.png' from previous figure..i made it manually but i want to make it automatically by programming ..may you help me?

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by