How to show different views on different axes ?

1 vue (au cours des 30 derniers jours)
yogesh jain
yogesh jain le 26 Fév 2016
Modifié(e) : yogesh jain le 27 Fév 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

Réponse acceptée

Mike Garrity
Mike Garrity le 26 Fév 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 commentaire
yogesh jain
yogesh jain le 27 Fév 2016
Modifié(e) : yogesh jain le 27 Fév 2016
Thank you very much Mr. Mike, it helped me completely . BTW is there any other way also ?

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Lighting, Transparency, and Shading dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by