# How to create 3D from 2D slices?

**URL:** <https://discourse.slicer.org/t/how-to-create-3d-from-2d-slices/16320>\
**Category:** Support\
**Created:** [March 3, 2021, 5:06am UTC](https://discourse.slicer.org/t/how-to-create-3d-from-2d-slices/16320 "2021-03-03T05:06:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Akeem\_Azeez](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/akeem_azeez/32/10158_2.png) [@Akeem\_Azeez](https://discourse.slicer.org/u/Akeem_Azeez)\
**Post date:** [March 3, 2021, 5:06am UTC](https://discourse.slicer.org/t/how-to-create-3d-from-2d-slices/16320/1 "2021-03-03T05:06:29Z")

</div>

Operating system: MacOS  
Slicer version:4.11.20210226  
Expected behavior:  
Actual behavior:  
I want to reconstruct 10 2D images to 3D. I have tried MatLab but I am having difficulties interpolating the gaps in between the adjacent slices. A colleague told me to try Slicer but I don’t know how to navigate the app. Here is the link to the slices:[Dropbox - OCT\_42\_pix - Simplify your life](https://www.dropbox.com/sh/1trxs9fy0btcbsa/AABJ_t-6-JLDXqtAPWU0jBQea?dl=0)  
I want to recreate a solid 3D. Thanks

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [March 3, 2021, 5:11am UTC](https://discourse.slicer.org/t/how-to-create-3d-from-2d-slices/16320/2 "2021-03-03T05:11:17Z")

</div>

To help us understand the context, here are few additional questions:

- How were these images acquired ? ~~Are these “Optical Coherence Tomography” images ?~~
- ~~What should be the spacing in mm between slices ?~~
- Is the plan to use 3d printing ? Do you expect to generate a surface model ?

Edit: It looks like these images where generated using Matlab or similar ? It seems like you could use a different plotting function to generate a 3D representation.

For reference, here is one of the image you shared:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/5/f5bead243f1fa60135df423536a41b772d53c884.jpeg)

---

<div class="post-metadata">

**Author:** ![Akeem\_Azeez](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/akeem_azeez/32/10158_2.png) [@Akeem\_Azeez](https://discourse.slicer.org/u/Akeem_Azeez)\
**Post date:** [March 3, 2021, 1:09pm UTC](https://discourse.slicer.org/t/how-to-create-3d-from-2d-slices/16320/3 "2021-03-03T13:09:45Z")

</div>

Hi,  
The images are acquired from OCT; after image processing, I have 10 (450x600 array) that was plotted on MatLab using the Imagesc function. Each slice represents a cross-section of a sample. My goal is to put the 10 slices together to reconstruct the surface of my sample.  
I want to interpolate one slice into another so as to create a surface model of the sample. I tried Matlab and what I got is in the attachment. Thank you, I appreciate your response.

Akeem

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [March 3, 2021, 2:58pm UTC](https://discourse.slicer.org/t/how-to-create-3d-from-2d-slices/16320/4 "2021-03-03T14:58:30Z")

</div>

You can load a stack of images as described [here](https://slicer.readthedocs.io/en/latest/user_guide/modules/volumes.html#load-a-series-of-png-jpeg-or-tiff-images-as-volume), then remove the Matlab plot axes by using Crop volume.

You can then go to Data module and drag-and-drop the image to a 3D view to see it with volume rendering:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/7/47e7cbdf3b0549b773b088cb894642f02bb463d7.png)

I would recommend to save the image array as nrrd (for example, using [nrrdwrite.m](https://github.com/PerkLab/SlicerMatlabBridge/blob/master/MatlabCommander/commandserver/nrrdwrite.m)) instead of saving resampled, color-mapped screenshots.

---

<div class="post-metadata">

**Author:** ![Akeem\_Azeez](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/akeem_azeez/32/10158_2.png) [@Akeem\_Azeez](https://discourse.slicer.org/u/Akeem_Azeez)\
**Post date:** [March 3, 2021, 6:08pm UTC](https://discourse.slicer.org/t/how-to-create-3d-from-2d-slices/16320/5 "2021-03-03T18:08:32Z")

</div>

Hi,  
I have followed the steps you recommended but how do I use the volume rendering to view the image. Kindly see the attached file for what I got after the drag and drop in the data module. Thanks

Akeem

 ![Screen Shot 2021-03-03 at 12.04.09 PM.jpg](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/9/2/920d578fa3425acfce64acc9b57cda7c7e62caa1.jpeg)

---

<div class="post-metadata">

**Author:** ![Akeem\_Azeez](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/akeem_azeez/32/10158_2.png) [@Akeem\_Azeez](https://discourse.slicer.org/u/Akeem_Azeez)\
**Post date:** [March 3, 2021, 6:48pm UTC](https://discourse.slicer.org/t/how-to-create-3d-from-2d-slices/16320/6 "2021-03-03T18:48:58Z")

</div>

Yes, the images were reconstructed using Matlab. I tried using Matlab to generate a 3D representation but I am not able to view the interested surface. The images represent the cross-sections of a surface, I want to put them together to reconstruct the surface. This is what I got when I tried it on matlab. Surface plot is not working as well. Thanks for the response.

 ![Screen Shot 2021-03-03 at 12.46.56 PM](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/f/4ff056091f063bf99aac9b99a21e52203fedd364.jpeg)

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [March 3, 2021, 7:11pm UTC](https://discourse.slicer.org/t/how-to-create-3d-from-2d-slices/16320/7 "2021-03-03T19:11:11Z")

</div>

You need to follow _all the steps_ described [here](https://slicer.readthedocs.io/en/latest/user_guide/modules/volumes.html#load-a-series-of-png-jpeg-or-tiff-images-as-volume), specifically:

- since you unnecessarily applied a color mapping to the image for plotting it in Matlab, you need to undo that using “Vector to scalar volume” module
- since a bmp stack cannot store the image spacing, you need to specify the spacing between slices (third spacing value)

These steps would not be necessary and all the information in the original images would have been better preserved if you loaded the original image into Slicer (e.g., from DICOM, NRRD, etc.) instead of trying to recover them from Matlab plots.
