exponenta event banner

Визуализация данных тома

В этом примере показано несколько методов визуализации данных тома в MATLAB ®.

Показать изо-поверхность

Изоповерхность - это поверхность, на которой все точки в объеме пространства имеют постоянное значение. Используйте isosurface для создания граней и вершин для внешней поверхности и isocaps для создания граней и вершин для концевых крышек объема. Используйте patch для рисования объема и его концевых крышек.

load mri D                                     % load data
D = squeeze(D);                                % remove singleton dimension
limits = [NaN NaN NaN NaN NaN 10];
[x, y, z, D] = subvolume(D, limits);           % extract a subset of the volume data

[fo,vo] = isosurface(x,y,z,D,5);               % isosurface for the outside of the volume
[fe,ve,ce] = isocaps(x,y,z,D,5);               % isocaps for the end caps of the volume

figure
p1 = patch('Faces', fo, 'Vertices', vo);       % draw the outside of the volume
p1.FaceColor = 'red';
p1.EdgeColor = 'none';

p2 = patch('Faces', fe, 'Vertices', ve, ...    % draw the end caps of the volume
   'FaceVertexCData', ce);
p2.FaceColor = 'interp';
p2.EdgeColor = 'none';

view(-40,24)
daspect([1 1 0.3])                             % set the axes aspect ratio
colormap(gray(100))
box on

camlight(40,40)                                % create two lights 
camlight(-20,-10)
lighting gouraud

Figure contains an axes. The axes contains 2 objects of type patch.

Создать конусный график

coneplot команда отображает векторы скорости в виде конусов в точках x, y, z в объеме. Конусы представляют величину и направление векторного поля в каждой точке.

cla                                            % clear the current axes
load wind u v w x y z                          % load data 

[m,n,p] = size(u);
[Cx, Cy, Cz] = meshgrid(1:4:m,1:4:n,1:4:p);    % calculate the location of the cones

h = coneplot(u,v,w,Cx,Cy,Cz,y,4);              % draw the cone plot
set(h,'EdgeColor', 'none')

axis tight equal
view(37,32)
box on
colormap(hsv)
light

Figure contains an axes. The axes contains an object of type patch.

Оптимизация графика

streamline функция строит графики для вектора скорости в точках x, y, z в объеме, чтобы проиллюстрировать поток 3-D векторного поля.

cla

[m,n,p] = size(u);
[Sx, Sy, Sz] = meshgrid(1,1:5:n,1:5:p);    % calculate the starting points of the streamlines

streamline(u,v,w,Sx,Sy,Sz)                 % draw the streamlines

axis tight equal
view(37,32)
box on

Figure contains an axes. The axes contains 21 objects of type line.

Печать потоков

streamtube функция строит график потоков для вектора скорости в точках x, y, z в объеме. Ширина трубки пропорциональна нормированной дивергенции векторного поля в каждой точке.

cla

[m,n,p] = size(u);
[Sx, Sy, Sz] = meshgrid(1,1:5:n,1:5:p);    % calculate the starting points of the streamlines

h = streamtube(u,v,w,Sx,Sy,Sz);            % draw the streamtubes and return an array of surfaces
set(h, 'FaceColor', 'cyan')                % use 'set' to change properties for an array of objects
set(h, 'EdgeColor', 'none')

axis tight equal
view(37,32)
box on
light

Figure contains an axes. The axes contains 13 objects of type surface.

Объединение визуализаций объемов

Объединение визуализации объема в одном графике для получения более полной картины поля скорости в объеме.

cla
spd = sqrt(u.*u + v.*v + w.*w);                          % wind speed at each point in the volume

[fo,vo] = isosurface(x,y,z,spd,40);                      % isosurface for the outside of the volume
[fe,ve,ce] = isocaps(x,y,z,spd,40);                      % isocaps for the end caps of the volume

p1 = patch('Faces', fo, 'Vertices', vo);                 % draw the isosurface for the volume
p1.FaceColor = 'red';
p1.EdgeColor = 'none';

p2 = patch('Faces', fe, 'Vertices', ve, ...              % draw the end caps of the volume
   'FaceVertexCData', ce);
p2.FaceColor = 'interp';
p2.EdgeColor = 'none' ;

[fc, vc] = isosurface(x, y, z, spd, 30);                 % isosurface for the cones
[fc, vc] = reducepatch(fc, vc, 0.2);                     % reduce the number of faces and vertices
h1 = coneplot(x,y,z,u,v,w,vc(:,1),vc(:,2),vc(:,3),3);    % draw the coneplot
h1.FaceColor = 'cyan';
h1.EdgeColor = 'none';

[sx, sy, sz] = meshgrid(80, 20:10:50, 0:5:15);           % starting points for streamline
h2 = streamline(x,y,z,u,v,w,sx,sy,sz);                   % draw the streamlines
set(h2, 'Color', [.4 1 .4])

axis tight equal
view(37,32)
box on
light

Figure contains an axes. The axes contains 19 objects of type patch, line.