How does the "boundary" function decide which points to include in its calculation?

35 visualizzazioni (ultimi 30 giorni)
Hi, I'm using the boundary function for an application involving tracing the perimeter of a set of coordinates which correspond to two dimensions of several detailed 3D models. (In short, I'm tracing the front view/top view/side view of the model.) I'm able to draw models in MATLAB correctly using the patch function, but when I use the boundary function to make a trace of the perimeter of the object, I can end up cutting into features of the model or including voids that are surrounded on several sides by model parts. I've confirmed that the boundary function is the source of my problem, so now I'm trying to understand how it works and I'm hoping someone here who's used it before might be able to share some wisdom with me.
I think I can explain what I'm looking for best using the example data from the boundary function's page:
In the example image, the boundary is drawn around the points with a shrink factor (S) of 0.5. If I bump S up to 1, I get:
Now, there's a data point given a x=0.5253, y=0.8889, near the upper middle section of the boundary:
If I remove that point from the data set and redraw the boundary (again, with an S of 1), I get the following:
(I've highlighted an additional point, for reasons I'm about to explain.) With these plots, in mind, I'm trying to figure out the following:
- How does boundary() determine which points in the set to tighten to and which to ignore? I don't understand why it ignored the highlighted point and chose to included the points forming that rectangular void in the bottom right.
- Similarly, is there a threshold for the position of a point which includes or excludes it from the boundary line?
I'm looking at some other solutions for obtaining the traces of these models, but I'm wondering if anyone has run into something similar and managed to tame boundary() or alphaShape(), so I don't have to start over from scratch. Thanks!
  4 Commenti
Stephen23
Stephen23 il 22 Lug 2019
Modificato: Stephen23 il 22 Lug 2019
The function boundary is just a wrapper around the alphaShape class, and makes use of its criticalAlpha method to select the alpha value.
John D'Errico explains the basic concept of alpha-shapes in this answer:
There are many alpha-shape tutorials online.
Bruno Luong
Bruno Luong il 22 Lug 2019
From my experience you'll always get erratic results using alphashape algorithm. The single coefficient is too restricted to control the shape.

Accedi per commentare.

Risposte (1)

Bruno Luong
Bruno Luong il 22 Lug 2019
Modificato: Bruno Luong il 22 Lug 2019
You can look at tthe code to see what it does
edit boundary.m
The relevant part is
Acrit = shp.criticalAlpha('one-region');
spec = shp.alphaSpectrum();
idx = find(spec==Acrit);
subspec = spec(1:idx);
subspec = flipud(subspec);
idx = max(ceil((1-S)*numel(subspec)),1);
alphaval = subspec(idx);
shp.Alpha = alphaval;
So it does some what interpolate the alpha value between 'one-region' and convex shape with the s factor, s given by user (0.5 by default if not provided).
With that good luck to twist boundary.

Categorie

Scopri di più su Bounding Regions in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by