How to use the GUI slider to scroll through 2D slices that make up a 3D image?
4 views (last 30 days)
Show older comments
I am new to GUI programming. I am trying to do the following: 1. Display an 3-D MRI image (represented as a stack of 2D images). 2. Use a slider to scroll through each image in the stack.
My code is shown below. I have three graphs within my GUI that output the different slices using a for loop and I want the slider to be able to go through each of these slices individually so the user can just slide the slider and see whichever specific slice they desire. I am having a lot of trouble with this and don't really understand how to use the slicer.
Any help would be greatly appreciated!
for Xslice = Xmin:1:Xmax
axis([Xslice,(Xslice+.1),Ymin,Ymax,Zmin,Zmax])
filename = [num2str(PatientID) '_Sagittal_',num2str(Xslice),'mm', '.png']; %look into the resolution necessary for publication
saveas(gcf, filename)
end
sagittal = handles.SagittalSlice;
% Generate Coronal Slices
axes(handles.CoronalSlice), hold;
for i = 1:Numberofclusters
%Plot all nuclei
tri = trisurf(ThalamicNuclei(i).Delaunay, ThalamicNuclei(i).SmallXCoordinates, ThalamicNuclei(i).SmallYCoordinates, ThalamicNuclei(i).SmallZCoordinates);
set(tri, 'FaceColor', ThalamicNuclei(i,1).Color, 'EdgeColor', 'none') %'EdgeColor','none' gets rid of the annoying black lines!
end
%Label the plot
xlabel('X (mm)'), ylabel('Y (mm) '), zlabel('Z (mm)')
view(0,0)
for Yslice = Ymin:1:Ymax
axis([Xmin,Xmax,Yslice,(Yslice+.1),Zmin,Zmax])
filename = [num2str(PatientID) '_Coronal_',num2str(Yslice),'mm', '.png']; %look into the resolution necessary for publication
saveas(gcf, filename)
end
% Generate Axial Slices
axes(handles.AxialSlice), hold;
for i = 1:Numberofclusters
%Plot all nuclei
tri = trisurf(ThalamicNuclei(i).Delaunay, ThalamicNuclei(i).SmallXCoordinates, ThalamicNuclei(i).SmallYCoordinates, ThalamicNuclei(i).SmallZCoordinates);
set(tri, 'FaceColor', ThalamicNuclei(i,1).Color, 'EdgeColor', 'none') %'EdgeColor','none' gets rid of the annoying black lines!
end
%Label the plot
xlabel('X (mm)'), ylabel('Y (mm) '), zlabel('Z (mm)')
view(0,90)
for Zslice = Zmin:1:Zmax
axis([Xmin,Xmax,Ymin,Ymax,Zslice,(Zslice+.1)])
filename = [num2str(PatientID) '_Axial_',num2str(Zslice),'mm', '.png']; %look into the resolution necessary for publication
saveas(gcf, filename)
end
0 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!