【问题标题】:3D body plot in matlab ( volume visualization )matlab中的3D人体图(体积可视化)
【发布时间】:2012-01-26 13:25:33
【问题描述】:

我对 MATLAB 中的体积数据几乎没有经验, 我需要完成下一个任务: 我有 3 个向量(行):

x_ = vector(1:smpl:max_row,1);

y_ = vector(1:smpl:max_row,2);

z_ = vector(1:smpl:max_row,3);

是来自高度为 max_row 的大型 3 列数组向量的样本。 x_ , y_ , z_ 是 3D 图形的点 - 图形的表面点(体积)。它们代表应该在 matlab 中绘制的 3D 物体。

我创建了线性网格:

%linear grid

a = -1.1:step:(-1.1+step*(length(x_)-1));

b = -1.1:step:(-1.1+step*(length(y_)-1));

c = -1.1:step:(-1.1+step*(length(z_)-1));


[x,y,z] = meshgrid(-1.1:step:(-1.1+step*(length(x_)-1)));

我还创建了数组 v length(x_)*length(x_)*length(x_),其中包含 3D 身体表示功能点的单元格中的“1”和另一个“0”。

我试着做插值:

vi = interp3(x,y,z,v,x,y,z,'nearest');

但是我已经创建了 vi = v。

现在我需要在 3D 上绘制 v 数组并像在

中那样形成 3D 体

http://www.mathworks.com/help/techdoc/ref/isonormals.html

例如。

接下来我会这样做:

%plotting:

figure

p = patch(isosurface(x,y,z,v,1e-5,'verbose'),'FaceColor','green','EdgeColor','none');

grid on;

isonormals(v,p);

daspect([1 1 1])

view(3); 

axis tight;

camproj perspective;

camlight

lighting gouraud

colormap(hsv)

但是我得到的只是小矩形来代替函数“1”,这些矩形没有像附加的图片中那样连接。 我希望绘制由该点包围的实体。

有谁知道问题出在哪里,如何从 x,y,z,v 数组中绘制 3D 身体?

提前致谢。

图片:

http://imgur.com/Ulegj

【问题讨论】:

    标签: matlab


    【解决方案1】:

    试试这个,这将是一个不错的情节(虽然它插值了一点):

    x = vector(1:smpl:max_row,1);
    y = vector(1:smpl:max_row,2);
    z = vector(1:smpl:max_row,3);
    
    % Settings
    displaySurface = 1;
    displayPoints = 0;
    xres = 800; % Resolution, the higher, the smoother
    yres = 800;         
    cm = 'default'; % Colormap
    
    % Axes Limits
    xmin = min(x); 
    ymin = min(y);
    xmax = max(x); 
    ymax = max(y); 
    xi = linspace(xmin, xmax, xres);
    yi = linspace(ymin, ymax, yres);
    
    % Figure
    myfig = figure('Position', [200 200 800 600]);
    
    rotate3d off
    [XI, YI] = meshgrid(xi, yi);
    ZI = griddata(x, y, z, XI, YI, 'cubic');
    mesh(XI,YI,ZI);
    colormap(cm)
    
    if(displaySurface == 1)
        hold on;
        surf(XI, YI, ZI, 'EdgeColor', 'none');
    end
    hold on;
    xlabel('x');
    ylabel('y'); 
    zlabel('z'); 
    title('Title', 'FontWeight', 'bold');
    xlim([xmin xmax])
    ylim([ymin ymax])
    grid off;
    
    if(displayPoints == 1)
        hold on
        plot3(x, y, z,'marker','p','markerfacecolor','w','linestyle','none')
        hidden off 
    end
    

    【讨论】:

    • 嗨 Col Heather,感谢您提出解决方案。我试过你的代码,看看我得到的当前数据:fileslap.com/94t/forum_plot;我需要另一个东西——由点 X,Y,Z 包围的实体。看看这个:(到底应该画什么):fileslap.com/94s/plot_。我正在继续解决这个问题。我希望你能帮助...
    • 好问题,我认为您应该只绘制“真实”主体的点,而不需要所有那些高级曲线(可以使用contour 创建)。如果你的身体主要部分有足够的积分,这真的应该有效:)
    • 嗨,是的,问题是如何绘制由点包围的主体(平滑),如图所示,但您的代码绘制得很好,平滑但表面,而不是 3D 封闭体积。我认为应该考虑三角测量。我最近尝试了 delaunay,它非常接近但并不平滑。如何从这些点而不是表面绘制体积?