Extract Gridded Data from Isosurface

5 ビュー (過去 30 日間)
Paul Safier
Paul Safier 2021 年 3 月 25 日
コメント済み: darova 2021 年 3 月 25 日
I want to get the x, y and z data of a surface that I extract from a volume via isosurface. I am doing it in the following way, but I suspect that it's horribly inefficient (because I cannot believe there isn't a more straightforward way) and possibly inaccurate because of some of the results I have been getting. Can anyone suggest a simplier way?
I want the data at points given by (just an example):
[x,y] = meshgrid(linspace(0,10,30),linspace(0,10,30))
The data is available from this:
[faces,verts] = isosurface(Xa, Ya, Za, data, 0);
Then I am doing this to get the surface on the coordinates I want (x,y):
[X1,Y1,Z1] = xyz2grid(verts(:,1),verts(:,2),verts(:,3));
MySurface = interp2(X1,Y1,Z1,x,y);
NaNres = sum(isnan(MySurface(:)));
if NaNres > 0
MySurface = inpaint_nans(MySurface,3);
end
  2 件のコメント
darova
darova 2021 年 3 月 25 日
Everything looks ok. What is wrong?
Paul Safier
Paul Safier 2021 年 3 月 25 日
編集済み: Paul Safier 2021 年 3 月 25 日
The results are the problem. It seems to work OK sometimes and awfully others. See example data and images of good surface (plotted by isosurface) and bad surface (plotted by surf after the interpolation). The raw data is attached that apply like this:
xx and yy are the results of meshgrid--they are where I want the z values.
[faces,verts] = isosurface(mesh_xs{:}, mesh_data, 0);
[X1,Y1,Z1] = xyz2grid(verts(:,2),verts(:,1),verts(:,3));
MySurface = interp2(X1,Y1,Z1,xx,yy);
NaNres = sum(isnan(MySurface(:)));
if NaNres > 0
MySurface=inpaint_nans(MySurface,3);
end
% Compare
figure; surf(xx,yy,MySurface)
figure; isosurface(mesh_xs{:}, mesh_data, 0);
Plotting with isosurface looks great (bottom figure). Plotting my interpolated result is bad (top figure).

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

採用された回答

darova
darova 2021 年 3 月 25 日
What about standard functions?
[faces,verts] = isosurface(mesh_xs{:}, mesh_data, 0);
zz = griddata(verts(:,2),verts(:,1),verts(:,3),xx,yy);
surf(xx,yy,zz)
Are you sure that the order xx and yy is correct?
  2 件のコメント
Paul Safier
Paul Safier 2021 年 3 月 25 日
That seems to work for the situation where the other method failed. Thanks for the suggestion!
darova
darova 2021 年 3 月 25 日
my plesure

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeScalar Volume Data についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by