%% Compute Isosurface End-Cap Geometry 
% This example uses a data set that is a collection of MRI slices of a
% human skull. It illustrates the use of isocaps to draw the end-caps on
% this cutaway volume.
%
% The red isosurface shows the outline of the volume (skull) and the
% end-caps show what is inside of the volume.
%
% The patch created from the end-cap data (|p2|) uses interpolated face
% coloring, which means the gray colormap and the light sources determine
% how it is colored. The isosurface patch (|p1|) used a flat red face color,
% which is affected by the lights, but does not use the colormap.

% Copyright 2015 The MathWorks, Inc.


load mri
D = squeeze(D);
D(:,1:60,:) = [];
p1 = patch(isosurface(D, 5),'FaceColor','red',...
	'EdgeColor','none');
p2 = patch(isocaps(D, 5),'FaceColor','interp',...
	'EdgeColor','none');
view(3)
axis tight
daspect([1,1,.4])
colormap(gray(100))
camlight left
camlight
lighting gouraud
isonormals(D,p1)