List of points in the shape of rectangles - which point is the corner?

3 views (last 30 days)
I have thousands of points (x,y,z) that make up 4 distinct rectangles. How can I find the 4 corners of each rectangle?
i.e. x=[]; y=[]; z=[]; & scatter3(x,y,z) shows a couple rectangles (randomly oriented) densely made of points. I want to know the x,y,z of the corners. I attached a screenshot of the graph and the M-File.
These rectangles are not touching, and we don't know what points belong to what rectangle.

Accepted Answer

Image Analyst
Image Analyst on 17 Oct 2016
Do the rectangles overlap?
Do you know which rectangle each point belongs to? Or do we have to figure that out, like via kmeans() or some other clustering method?
You forgot to attach your data file, code to read it in, and a screenshot. Can you do so, to make it easier for people to help you?
Once you know which rectangle the points belong to, then you can John D'Errico's minboundrect() to find the corner points. http://www.mathworks.com/matlabcentral/fileexchange/34767-a-suite-of-minimal-bounding-objects
  4 Comments
Image Analyst
Image Analyst on 17 Oct 2016
See my shape recognition demo, attached. It shows you how you can get the vertices of shapes. I'd do something along those lines. You can do it with points - it doesn't have to be an image - just do the same concept.
Brandon
Brandon on 19 Oct 2016
You are right in these are not all in the exact same plane. The z varies throughout the "cloud" as the rectangle is at a slant. The rectangles are all close to what is seen in the example (they are generated from 3D scanning).
It took a day or so but I used kmeans and John D'Errico's minboundrect() to accomplish this is 2D. I have now translated everything into 3D, except for the minboundrect(). I will tackle that next! If this becomes too daunting I will look into your shape recognition demo. Thanks again Image Analyst.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!