%CDS130, Sample on scalr volume visualization
clear;clf
load mri

D = squeeze(D);

figure(1)
colormap(map)
Ds=smooth3(D);  %smooth the data before finding the isosurface
%use patch to display the irregular isosurface
hiso=patch(isosurface(Ds,5),...
    'FaceColor',[1,0.75,0.65],...
    'EdgeColor','none');

hold on

isonormals(Ds,hiso);  %render the surface using vertex normals

%adding Isocaps showing cutting away surface
%use unsmoothed data to show the detail of the interior
hcap=patch(isocaps(D,5),...
    'FaceColor','interp',...
    'EdgeColor','none');

%define the view
view(35,30)
axis tight
daspect([1,1,0.4])

%adding light
lightangle(45,30);
set(gcf,'Renderer','zbuffer');
lighting phong
set(hcap,'AmbientStrength',0.6)
set(hiso,'SpecularColorReflectance',0,'SpecularExponent',50)


