Issue with dispaly of 3D images created from multiple 2D slices
Afficher commentaires plus anciens
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?
Réponse acceptée
Plus de réponses (1)
Mathieu NOE
le 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 commentaires
Mathieu NOE
le 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
le 23 Jan 2025
MechenG
le 23 Jan 2025
MechenG
le 23 Jan 2025
Catégories
En savoir plus sur Convert Image Type dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
