How to show different views on different axes ?

1 visualización (últimos 30 días)
yogesh jain
yogesh jain el 26 de Feb. de 2016
Editada: yogesh jain el 27 de Feb. de 2016
Hello all, I have code to generate 3D volume , which is -
load mri.mat;
K = squeeze(D);
K = padarray(K,[10 10 10],'both');
Ds = smooth3(K);
i_surface = isosurface(Ds,5);
hold all
hiso = patch('Vertices', i_surface.vertices,...
'Faces', i_surface.faces,...
'FaceColor', [.2,.8,.9],...
'FaceAlpha',0.5,'EdgeColor', 'none','EdgeAlpha',0.9);
axis tight
daspect([1,1,0.4])
lightangle(-40,30); lightangle(90,0); lightangle(-180,0);
set(gcf,'Renderer','zbuffer'); lighting phong
isonormals(Ds,hiso)
set(hiso, 'SpecularColorReflectance', 0, 'SpecularExponent', 50)
view(-16,90);
Now I want to show three views (axial,sagittal and coronal) on different axes in GUI, how should I program that according to "axes handle" (axes(handles.axes))? Thank you

Respuesta aceptada

Mike Garrity
Mike Garrity el 26 de Feb. de 2016
The simplest is to just create 4 copies of the scene you've made:
set(gcf,'Renderer','zbuffer');
load mri.mat;
K = squeeze(D);
K = padarray(K,[10 10 10],'both');
Ds = smooth3(K);
a1 = subplot(2,2,1);
i_surface = isosurface(Ds,5);
hold all
hiso = patch('Vertices', i_surface.vertices,...
'Faces', i_surface.faces,...
'FaceColor', [.2,.8,.9],...
'FaceAlpha',0.5,'EdgeColor', 'none','EdgeAlpha',0.9);
isonormals(Ds,hiso)
set(hiso, 'SpecularColorReflectance', 0, 'SpecularExponent', 50)
lightangle(-40,30);
lightangle(90,0);
lightangle(-180,0);
axis tight
daspect([1,1,0.4])
lighting phong
set(a1,'CameraPosition',[0 0 10]+get(a1,'CameraTarget'))
a2 = subplot(2,2,2);
copyobj(get(a1,'Children'),a2)
axis tight
daspect([1,1,0.4])
lighting phong
set(a2,'CameraPosition',[0 10 0]+get(a2,'CameraTarget'))
a3 = subplot(2,2,3);
copyobj(get(a1,'Children'),a3)
axis tight
daspect([1,1,0.4])
lighting phong
set(a3,'CameraPosition',[10 0 0]+get(a3,'CameraTarget'))
a4 = subplot(2,2,4);
copyobj(a1.Children,a4)
axis tight
daspect([1,1,0.4])
lighting phong
view(3)
In addition to copying the contents of the first axes into the others, you also need to set the properties like DataAspectRatio on each of the axes.
  1 comentario
yogesh jain
yogesh jain el 27 de Feb. de 2016
Editada: yogesh jain el 27 de Feb. de 2016
Thank you very much Mr. Mike, it helped me completely . BTW is there any other way also ?

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by