views:

710

answers:

2

I have 25 2D images (of equal size), each image represents one layer equally spaced. Each image is in grayscale and black color (or values equal 0 in data matrix after importing it) is the background that needs to be removed.

And my questions are:

  • How to combine these 25 images to one 3D image? How to draw each one with some space between?

  • How to remove the background color? Is it possible to create some kind of colorscale where values equal 0 will be transparent?

A little additional data:

  • These images are in DCM format (DICOM images) and I import them using dicomread function.

  • Each image (320x320 px) represents one layer that is 4 mm thick and spacing between layers is 1,2 mm. We can assume, that width of each image is about 120-125 mm

+2  A: 

2D into 3D matrix:

>> a = magic(3)

a =

     8     1     6
     3     5     7
     4     9     2

>> b = ones(3)

b =

     1     1     1
     1     1     1
     1     1     1

>> c = zeros(3)

c =

     0     0     0
     0     0     0
     0     0     0

>> d(:,:,1)= a

d =

     8     1     6
     3     5     7
     4     9     2

>> d(:,:,2)= b

d(:,:,1) =

     8     1     6
     3     5     7
     4     9     2


d(:,:,2) =

     1     1     1
     1     1     1
     1     1     1

>> d(:,:,3)= c

d(:,:,1) =

     8     1     6
     3     5     7
     4     9     2


d(:,:,2) =

     1     1     1
     1     1     1
     1     1     1


d(:,:,3) =

     0     0     0
     0     0     0
     0     0     0

Transparency:

Set the transparent voxels to a value of NaN. Most graphics just leave NaN as empty space.

Related projects

You are likely to be interested in SliceOMatic

My first project at The MathWorks was a demo similar to yours. It was reconstruction of a 3-D solid from planar slices (unregistered). Most of the work was in the registration.

This is a related project also that might be of interest.

MatlabDoug
Thanks, not exactly what I need, but helped me a lot. SliceOMatic is great, unfortunately very slow :/
Gacek
@Gacek how big is your dataset? I would not expect it to be slow for most datasets.If I did not answer your question, please elaborate this one, or open new ones as appropriate. One question per post works best (this had two or more!)
MatlabDoug
What I meant it is not exactly what I thought about at the first time, but it seems to be even better solution. I have 25 images 320x320 pixels... not so much, but it's almost killing my Matlab. I don't know why :/
Gacek
A: 

How do you view that 3D created image?

See this slice-o-matic that Doug was writing about.
Gacek