How to create a 3D stack using 2D images

5 vues (au cours des 30 derniers jours)
DM
DM le 13 Avr 2021
Modifié(e) : Matt J le 13 Avr 2021
Hi,
I have a 2D binary image with dimensions [145,145] and I would like to create a 3D stack using 10 times the same 2D binary image, i.e. a series of the same 2D images.
I tried the following code but I am ending up with a 2D image instead of 3D.
mask = load_nii('~/mask_2d.nii');
mask_2d = double(mask.img);
mask_3d = zeros(145,145,10);
for i = 1:10
mask_3d(:,:,i) = mask_3d(:,:,i)+mask_2d(:,:);
end
Any help would be much appreciated.

Réponses (1)

Matt J
Matt J le 13 Avr 2021
Modifié(e) : Matt J le 13 Avr 2021
Are you sure you need to do that? It seems like a waste of memory to copy the same image 10 times. If you're sure it's what you want, however,
mask_3d=repmat(mask_2d,1,1,10);

Catégories

En savoir plus sur Image Segmentation and Analysis dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by