I have 170 slices of 512 x 512 image in binary form (manual segmentation from a data set of medical images). I would like to plot a 3 dimensional visualization/model of the object, by stacking these 170 slices of image together.
I used concatenation function to stack all the 170 images into one matrix, D. My coding as below:
C = cell(1, 170);
for k = 1:170;
% Create a mat filename, and load it into a structure called matData.
matFileName = sprintf('AAAmanual%d.mat', k);
if exist(matFileName, 'file')
load(matFileName);
C{k} = BW;
else
fprintf('File %s does not exist.\n', matFileName);
end
end
D = cat(3, C{:});
I'm not sure whether this is the correct way to do so. So i need your advice and help to proceed from here. How should i write in Matlab code, or what is the function suitable to use to visualize the model?
I got something plotted out using smoothed surface, but got an error mentioning out of memory. The coding for smoothed surface as follow:
patch(isocaps(D,.5),...
'FaceColor','interp','EdgeColor','none');
p1 = patch(isosurface(D,.5),...
'FaceColor','blue','EdgeColor','none');
isonormals(D,p1)
view(3);
axis vis3d tight
camlight left;
colormap jet
lighting gouraud
Result from smooth3 plot:
How should i overcome the out of memory problem? or is there a better way to plot this?