Create an accurate boundary around 2D point cloud horizontal plane

29 Ansichten (letzte 30 Tage)
Alexandru Mihai LAPADAT
Alexandru Mihai LAPADAT am 22 Mär. 2019
Bearbeitet: Bruno Luong am 27 Mär. 2019
Hello everyone,
I am dealing with creating an accurate boundary (concave hull) of a point cloud. I want to create the a polygon around it and compute the center of gravity using centroid function. None of the threshold values (0-1) give me a good result. I add here a resulting boundary colored in blue and the point cloud set colored in red. Is there any better approach using another function rather then boundary+polyshape??
5.JPG
  6 Kommentare
Matt J
Matt J am 26 Mär. 2019
Bearbeitet: Matt J am 26 Mär. 2019
I tryed also TSP and did not work.
Are you going to show us what you did and what you got?
John D'Errico
John D'Errico am 26 Mär. 2019
That it did not work just means you did not properly formulate the Traveling Salesman Problem correctly, or solve it correctly, or correctly interpret the results, because it WILL work.
A better more useful way to approach this would have beento provide your data, show what you tried, then state why it is that you think it did not indeed work.

Melden Sie sich an, um zu kommentieren.

Antworten (4)

Bruno Luong
Bruno Luong am 23 Mär. 2019
You might take a look at traveling saleman problem, there are several efficient implementation in File Exchange
  1 Kommentar
Bruno Luong
Bruno Luong am 27 Mär. 2019
Bearbeitet: Bruno Luong am 27 Mär. 2019
I played with the data you provides (horizontal.txt) and TSP have the hard time to get the correct boundary for many reasons:
  1. There are a too large number of points (> 29000)
  2. Points seem to be inconsistent (double wall) and density varies greatly
  3. The data you provide does not match your plot in the question
I think you might need to preprocess the data to facilitate the TSP algorithm.
For the record here is an old post that show TSP can solve such problem with reasonable data

Melden Sie sich an, um zu kommentieren.


Matt J
Matt J am 22 Mär. 2019
You can use alphaShape.
  9 Kommentare
John D'Errico
John D'Errico am 24 Mär. 2019
A convex hull will fail because the domain is not convex, so the area enclosed will be too large. Note that it was already requested to be able to improve this result to be better than a convex hull.
darova
darova am 24 Mär. 2019
Maybe you can examine each pair of points. If L > some length then create a triangle and see if there are points inside it
Untitled.png

Melden Sie sich an, um zu kommentieren.


John D'Errico
John D'Errico am 23 Mär. 2019
Bearbeitet: John D'Errico am 23 Mär. 2019
As I thought about your problem, there is a simple solution. This is a TSP - a Traveling Salesman Problem. You want a closed solution, so the first and the last points will be the same. What I don't know is if those lines are thinned out. You want single pixels around the perimeter of that boundary, not multi-pixel thick lines. But given that, then just use a TSP solver. There are a few to be found on the File Exchange. Try this one, for example:

Image Analyst
Image Analyst am 23 Mär. 2019
I'm guessing that you generally like the red shape (rather than the black outline shape) but you want the ends of the red pieces to be connected to the closest other piece so that the curve/boundary is closed. So you want "edge linking" (Google it).
One way is to
  1. skeletonize the image with binaryImage = bwmorph(binaryImage, 'skel', inf)
  2. find endpoints with binaryImage = bwmorph(binaryImage, 'endPoints')
  3. label the blobs with labeledImage = bwlabel(binaryImage).
  4. use a for loop to find the closest endpoints that are not on the same labeled blob
  5. connect these endpoints with imline (attached demos might help)
Now all your end points will have a line connecting them to the nearest other piece. Now you can simply use imfill to make the shape solid, then use bwboundaries to get a list of (x,y) coordinates around the entire shape.
binaryImage = imfill(binaryImage, 'holes');
boundaries = bwboundaries(binaryImage);
The only steps that are slightly more than trivial are steps 4 and 5 but I'm sure you're smart enough to handle it. If not, let me know. Steps 1-3 area all one liners that I've already given you.
  7 Kommentare
Alexandru Mihai LAPADAT
Alexandru Mihai LAPADAT am 24 Mär. 2019
Hello Image Anayst
I did not find the solution on my problem with converting back to real point cloud coordinate system. Could you please help me with this. I also tryed to use the point2contour function directly on the x,y point cloud but did not give a great result. I really don't know how to solve it :(
Image Analyst
Image Analyst am 25 Mär. 2019
I thought you had the image in red. It appears now you just have a collection of point locations, not an image. To do anything with my suggestion, you'd have to create an image.
Again, you might want minimum perimeter polygon - I don't know.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by