Issue with dispaly of 3D images created from multiple 2D slices
Show older comments
Hi,
I have multiple 2D grayscale image slices (all of them are of same dimensions). I need to stack them to dispaly 3D image. I tried cat function and then implay. But this just plays video, I am not able to see 3D image.
I came across many threads relevant to this. But I am not sure which one will serve the purpose.
I have attached few 2D grayscale slices here. Could someone please suggest the possible method to get 3D reconstruction from these images?
Accepted Answer
More Answers (1)
Mathieu NOE
on 22 Jan 2025
For a 3D rendering (like MRI) I suggest you try this : vol3d v2 - File Exchange - MATLAB Central
%% create a 3D rendering
out = [];
for k=1:5
img = rgb2gray(imread(['0' num2str(k) '.png']));
out = cat(3,out,img);
end
h = vol3d('cdata',out,'texture','3D');
view(3);
axis tight; daspect([1 1 .4])
alphamap('rampup');
alphamap(.06 .* alphamap);
5 Comments
Mathieu NOE
on 22 Jan 2025
if you just want to stack figures , you can do this

%% create stacked images (I am simply repeating the same image 5 times)
% plot each slice as a texture-mapped surface (stacked along the Z-dimension)
figure
hold on
for k=1:5
img = imread(['0' num2str(k) '.png']);
[X,Y] = meshgrid(1:size(img,2), 1:size(img,1));
Z = ones(size(img,1),size(img,2));
surface('XData',X-0.5, 'YData',Y-0.5, 'ZData',Z.*k, ...
'CData',img, 'CDataMapping','direct', ...
'EdgeColor','none', 'FaceColor','texturemap')
end
view(3), box on, axis tight square
set(gca, 'YDir','reverse', 'ZLim',[1 k])
hold off
MechenG
on 23 Jan 2025
MechenG
on 23 Jan 2025
MechenG
on 23 Jan 2025
Categories
Find more on Lighting, Transparency, and Shading in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!