
load ('volume_filled');
mand_vol = reducevolume(mand_vol_fixed,[3 3 3]);
mand_iso = isosurface(mand_vol);


tri_b=mand_iso.faces;
coord_b=mand_iso.vertices;
nb_vertex=size(coord_b,1)
nb_tri=size(tri_b,1)

coord_b=coord_b-kron(ones(nb_vertex,1),mean(coord_b));
figure;trisurf(tri_b,coord_b(:,1),coord_b(:,2),coord_b(:,3));colorbar    

%mesh subsampling to make smaller mesh
small= reducepatch(mand_iso,0.2);

tri=small.faces;
coord=small.vertices;

n_vertex = size(coord,1)
n_tri = size(tri,1)

figure;trimesh(tri,coord(:,1),coord(:,2),coord(:,3));colorbar    

% surface rendering
figure
p=patch('Faces',tri_b,'Vertices',coord_b);
set(p,'FaceColor','yellow','EdgeColor','none');
daspect([1 1 1])
view(3); axis tight
camlight 
lighting gouraud
alpha(0.5)


