MATLAB Answers

maha mohy

how to convert 2D image into 3D ??

Asked by maha mohy
on 8 Mar 2012

Hello everybody,my graduation project is about 3D mri visualization ,I want to convert 2D images into 3D ...could anyone help me plz


thanks all,@ Mr Walter I don't think they are registered cuz I extracted them from reference ,so what will I do to register them

try gray2rgb

@i have a similar project currently i have registered images from DICOM and need an algorithm / code to convert 64 slices into a 3D brain model.. can u plz help me! Walter Roberson


No products are associated with this question.

2 Answers

Answer by Image Analyst
on 8 Mar 2012
 Accepted answer

try cat(3,...)

image3D = cat(3, slice1, slice2, slice3, slice4, slice5);

You could put it into a loop

for slice = 1 : totalNumberOfSlices
  thisSlice = GetSlice();  % Whatever you have to do to get one 2D image.
  if slice == 1
    image3D = thisSlice;
    image3D = cat(3, image3D, thisSlice);


on 28 Nov 2012

How can i use this..? Thanks.

You can use this very well, I would think. Or maybe I should say "you can use it in MATLAB in a script or a function." because I'm not sure what you are asking.

on 5 Jun 2013


Answer by Walter Roberson
on 8 Mar 2012

The problem is not constructing the 3D array: the problem is displaying it. MATLAB does not have good voxel visualization routines. You could try


How did you decide that? Displaying is converting a 3D volumetric image into a 2D projection image - the opposite of what he said.

At my workplace we often build 3D MRI images from 2D MRI slices. MATLAB is okay for displaying the resulting datasets if you just want a planar slice, but it is far far below the 3-space imaging capabilities of some other products.

For example see
and look at the lower-left image in the "screen" in the middle foreground. Textured, shaded, cut-ins, real-time transparency control based upon data ranges so that you can see (e.g.) tumors and peer inside them...

I definitely agree that MATLAB doesn't have anywhere near the power of other programs in doing volumetric visualization.

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!