MATLAB: Display 3D volumes with different colours in the surface

3d volumesurface different face colours

Dear all,
I'm working with brain MRI images and as a result I obtain statistical maps (values between 0 and 25) which I would like to represent in 3D with a colormap. I have x, y and z coordinates, and stat(the statistical value which I want to represent in color). I used a nice function called PATCH_3Darray, calling patch for each voxel, and I obtained this image:
I would like to smooth the voxels, so they do not seem bricks and don't have corner-edges. How could I smooth all if there are individual patches?
I was considering binarizing my statistical image, get connected voxels, create an isosurface like: BW=statistical_image>0; CC = bwconncomp(BW); L = labelmatrix(CC); color=hsv(15);
for i=1:1:numel(unique(L)) A=(L==i); e = patch(isosurface(A,0.5), … 'FaceColor', color(i,:), 'EdgeColor', 'none'); hold on end
and somehow get in the surface/"face" of each object the real values in the matrix statistical_image (as in the first image), colored with a colormap. How could I do it? Please, could you help me with code?
Thank you very much, All the best,
Úrsula

Best Answer

Hi,
I solved the problem using isosurface and a nice function,"smooth triangulated mesh" https://es.mathworks.com/matlabcentral/fileexchange/26710-smooth-triangulated-mesh:
% dims: image dimensions
axx=1:dims(1); ayy=1:dims(2); azz=1:dims(3); [xgrid,ygrid,zgrid] = meshgrid(axx, ayy, azz);
%statistical_image
%binary_statistical_image: assuming only positive values, put 1s where %statistical_image > 0
[faces,verts,colors] = isosurface(xgrid,ygrid,zgrid,binary_statistical_image,0.99999,statistical_image,'','verbose');
addpath('smoothpatch_version1b') mex smoothpatch_version1b\smoothpatch_curvature_double.c -v
mex smoothpatch_version1b\smoothpatch_inversedistance_double.c -v
mex smoothpatch_version1b\vertex_neighbours_double.c -v
FV.vertices=verts; FV.faces=faces; FV_smoothed=smoothpatch(FV,1,5); hpatch=patch(FV_smoothed, ... 'FaceVertexCData', colors, ... 'FaceColor','interp', ... 'edgecolor', 'interp');
Hope this helps,
All the best, Úrsula