| MATLAB Function Reference | ![]() |
[Nx,Ny,Nz,Nv] = subvolume(X,Y,Z,V,limits)
[Nx,Ny,Nz,Nv] = subvolume(V,limits)
Nv = subvolume(...)
[Nx,Ny,Nz,Nv] = subvolume(X,Y,Z,V,limits) extracts a subset of the volume data set V using the specified axis-aligned limits. limits = [xmin,xmax,ymin, ymax,zmin,zmax] (Any NaNs in the limits indicate that the volume should not be cropped along that axis.)
The arrays X, Y, and Z define the coordinates for the volume V. The subvolume is returned in NV and the coordinates of the subvolume are given in NX, NY, and NZ.
[Nx,Ny,Nz,Nv] = subvolume(V,limits) assumes the arrays X, Y, and Z are defined as
[X,Y,Z] = meshgrid(1:N,1:M,1:P)
where [M,N,P] = size(V).
Nv = subvolume(...) returns only the subvolume.
This example uses a data set that is a collection of MRI slices of a human skull. The data is processed in a variety of ways:
The 4-D array is squeezed (squeeze) into three dimensions and then a subset of the data is extracted (subvolume).
The outline of the skull is an isosurface generated as a patch (p1) whose vertex normals are recalculated to improve the appearance when lighting is applied (patch, isosurface, isonormals).
A second patch (p2) with interpolated face color draws the end caps (FaceColor, isocaps).
A 100-element grayscale colormap provides coloring for the end caps (colormap).
Adding lights to the right and left of the camera illuminates the object (camlight, lighting).
load mri
D = squeeze(D);
[x,y,z,D] = subvolume(D,[60,80,nan,80,nan,nan]);
p1 = patch(isosurface(x,y,z,D, 5),...
'FaceColor','red','EdgeColor','none');
isonormals(x,y,z,D,p1);
p2 = patch(isocaps(x,y,z,D, 5),...
'FaceColor','interp','EdgeColor','none');
view(3); axis tight; daspect([1,1,.4])
colormap(gray(100))
camlight right; camlight left; lighting gouraud

isocaps, isonormals, isosurface, reducepatch, reducevolume, smooth3
Volume Visualization for related functions
![]() | substruct | sum | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |