How can I convert a surf plot into a binary volume mask?

4 ビュー (過去 30 日間)
Alexander Dumont
Alexander Dumont 2019 年 5 月 15 日
コメント済み: darova 2019 年 5 月 15 日
I am trying to recreat a shape in MATLAB, specificaly, a capsule. I use MATLAB's piecewise function to produce a line that I want, and then I pass that line to the cylinder method of MATLAB. The resultant looks ike this:
And this is exactly the shape I want. However, I need to convert this surf plot with 2-dimensonal data for X,Y and Z into a volume plot, which I can then convert into a mask. I've tried surf2solid, which works but gets me no nearer to my answer, and I've tried polygon2voxel, which fails because when I use the patch function it returns different size vertices and faces. Any help would be greatly appreciated!
  1 件のコメント
darova
darova 2019 年 5 月 15 日
What kind of data do you have and what do you expect to reach?
Can't you just scale your data?
img.png

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

採用された回答

Alexander Dumont
Alexander Dumont 2019 年 5 月 15 日
THe best I've gotten so far is I linearize my meshgrid:
P = [X(:) Y(:) Z(:)]
I then do a delaunay triangulation followed by a convexhull
DT = delaunayTriangulation(P);
[C,v] = convexHull(DT);
And then use John D'Errico's function inhull to sample acrss points:
x = linspace(min(X(:)), max(X(:)), 50);
y = linspace(min(Y(:)), max(Y(:)), 50);
z = linspace(min(Z(:)), max(Z(:)), 50);
P = combvec(x,y,z)';
in = inhull(P,DT.Points);
To find points that are in or out of my cylinder
And I display them with
k = find(in==1);
plot3(P(k,1),P(k,2),P(k,3))
Doesn't seem great though.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by