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

Thread Subject:
Reading 3D volumes

Subject: Reading 3D volumes

From: Giannoula

Date: 24 May, 2011 21:32:04

Message: 1 of 5

Hello,

I have difficulty in reading 3D images using each voxel group 2x2x2 for a specific action.
I ve tried nested for loops but i dont think that it is a sufficient way.
P.S : the pictures are in a cell (1x9)

Thanks in advance
Giannoula

Subject: Reading 3D volumes

From: Florin Neacsu

Date: 24 May, 2011 21:44:05

Message: 2 of 5

"Giannoula " <ann7ita@hotmail.com> wrote in message <irh84k$ntq$1@newscl01ah.mathworks.com>...
> Hello,
>
> I have difficulty in reading 3D images using each voxel group 2x2x2 for a specific action.
> I ve tried nested for loops but i dont think that it is a sufficient way.
> P.S : the pictures are in a cell (1x9)
>
> Thanks in advance
> Giannoula

Hi,

Your post is very confusing. Are you trying to read 3D volumes from a file ? You have 3D volumes in matrices and you try to perform an action on a 2x2x2 volume on each? Then you say you have pictures in a cell; so are they pictures (2D) or volumes ?

Please clarify.

I could suggest you(although this might not be helpful, depending on your actual intent) to have a look at convn
>doc convn

Regards,
Florin

Subject: Reading 3D volumes

From: Giannoula

Date: 24 May, 2011 22:34:04

Message: 3 of 5

"Florin Neacsu" wrote in message <irh8r5$pjo$1@newscl01ah.mathworks.com>...
> "Giannoula " <ann7ita@hotmail.com> wrote in message <irh84k$ntq$1@newscl01ah.mathworks.com>...
> > Hello,
> >
> > I have difficulty in reading 3D images using each voxel group 2x2x2 for a specific action.
> > I ve tried nested for loops but i dont think that it is a sufficient way.
> > P.S : the pictures are in a cell (1x9)
> >
> > Thanks in advance
> > Giannoula
>
> Hi,
>
> Your post is very confusing. Are you trying to read 3D volumes from a file ? You have 3D volumes in matrices and you try to perform an action on a 2x2x2 volume on each? Then you say you have pictures in a cell; so are they pictures (2D) or volumes ?
>
> Please clarify.
>
> I could suggest you(although this might not be helpful, depending on your actual intent) to have a look at convn
> >doc convn
>
> Regards,
> Florin

Thank you very much for the quick answer

I have 9 images of same size (for example 20x20x20 each) saved in a cell with the name "collection". I can access each value of the image like this:
collection{1}(i,j,k); for the first image.
I want to gather the 2x2x2 groups of voxels (i mean their values) of the same location of each image.
The first 2x2x2 voxel group of 9 images then..
The second 2x2x2 voxel group of 9 images e.t.c for a specific FUNCTION
It seems it works now with nested for loops. My ultimate goal is to load this FUNCTION as a parallel job but can i use parfor somehow in nested for loops??

I hope i made the problem comprehensive
With regards,
Giannoula

Subject: Reading 3D volumes

From: Florin Neacsu

Date: 24 May, 2011 23:42:02

Message: 4 of 5

"Giannoula " <ann7ita@hotmail.com> wrote in message <irhbos$3h9$1@newscl01ah.mathworks.com>...
> "Florin Neacsu" wrote in message <irh8r5$pjo$1@newscl01ah.mathworks.com>...
> > "Giannoula " <ann7ita@hotmail.com> wrote in message <irh84k$ntq$1@newscl01ah.mathworks.com>...
> > > Hello,
> > >
> > > I have difficulty in reading 3D images using each voxel group 2x2x2 for a specific action.
> > > I ve tried nested for loops but i dont think that it is a sufficient way.
> > > P.S : the pictures are in a cell (1x9)
> > >
> > > Thanks in advance
> > > Giannoula
> >
> > Hi,
> >
> > Your post is very confusing. Are you trying to read 3D volumes from a file ? You have 3D volumes in matrices and you try to perform an action on a 2x2x2 volume on each? Then you say you have pictures in a cell; so are they pictures (2D) or volumes ?
> >
> > Please clarify.
> >
> > I could suggest you(although this might not be helpful, depending on your actual intent) to have a look at convn
> > >doc convn
> >
> > Regards,
> > Florin
>
> Thank you very much for the quick answer
>
> I have 9 images of same size (for example 20x20x20 each) saved in a cell with the name "collection". I can access each value of the image like this:
> collection{1}(i,j,k); for the first image.
> I want to gather the 2x2x2 groups of voxels (i mean their values) of the same location of each image.
> The first 2x2x2 voxel group of 9 images then..
> The second 2x2x2 voxel group of 9 images e.t.c for a specific FUNCTION
> It seems it works now with nested for loops. My ultimate goal is to load this FUNCTION as a parallel job but can i use parfor somehow in nested for loops??
>
> I hope i made the problem comprehensive
> With regards,
> Giannoula

Hi,

> I want to gather the 2x2x2 groups of voxels (i mean their values) of the same location of each image.

...would something like this work ?(you should obviously adapt this to your needs and make sanity checks, aptly name variables etc...)

a=ones(20,20,20);
b=2*ones(20,20,20);
c=3*ones(20,20,20);

S={a,b,c};

ii=2;
jj=3;
kk=4;

array = cat(3,S{:});
array2=reshape(array,20,20,20,3);


temp=array2(ii:ii+1,jj:jj+1,kk:kk+1,:)


Regards,
Florin

Subject: Reading 3D volumes

From: Giannoula

Date: 8 Jun, 2011 07:07:20

Message: 5 of 5

Thank you veeery much for the answer..i'll work on it

"Florin Neacsu" wrote in message <irhfoa$cuu$1@newscl01ah.mathworks.com>...
> "Giannoula " <ann7ita@hotmail.com> wrote in message <irhbos$3h9$1@newscl01ah.mathworks.com>...
> > "Florin Neacsu" wrote in message <irh8r5$pjo$1@newscl01ah.mathworks.com>...
> > > "Giannoula " <ann7ita@hotmail.com> wrote in message <irh84k$ntq$1@newscl01ah.mathworks.com>...
> > > > Hello,
> > > >
> > > > I have difficulty in reading 3D images using each voxel group 2x2x2 for a specific action.
> > > > I ve tried nested for loops but i dont think that it is a sufficient way.
> > > > P.S : the pictures are in a cell (1x9)
> > > >
> > > > Thanks in advance
> > > > Giannoula
> > >
> > > Hi,
> > >
> > > Your post is very confusing. Are you trying to read 3D volumes from a file ? You have 3D volumes in matrices and you try to perform an action on a 2x2x2 volume on each? Then you say you have pictures in a cell; so are they pictures (2D) or volumes ?
> > >
> > > Please clarify.
> > >
> > > I could suggest you(although this might not be helpful, depending on your actual intent) to have a look at convn
> > > >doc convn
> > >
> > > Regards,
> > > Florin
> >
> > Thank you very much for the quick answer
> >
> > I have 9 images of same size (for example 20x20x20 each) saved in a cell with the name "collection". I can access each value of the image like this:
> > collection{1}(i,j,k); for the first image.
> > I want to gather the 2x2x2 groups of voxels (i mean their values) of the same location of each image.
> > The first 2x2x2 voxel group of 9 images then..
> > The second 2x2x2 voxel group of 9 images e.t.c for a specific FUNCTION
> > It seems it works now with nested for loops. My ultimate goal is to load this FUNCTION as a parallel job but can i use parfor somehow in nested for loops??
> >
> > I hope i made the problem comprehensive
> > With regards,
> > Giannoula
>
> Hi,
>
> > I want to gather the 2x2x2 groups of voxels (i mean their values) of the same location of each image.
>
> ...would something like this work ?(you should obviously adapt this to your needs and make sanity checks, aptly name variables etc...)
>
> a=ones(20,20,20);
> b=2*ones(20,20,20);
> c=3*ones(20,20,20);
>
> S={a,b,c};
>
> ii=2;
> jj=3;
> kk=4;
>
> array = cat(3,S{:});
> array2=reshape(array,20,20,20,3);
>
>
> temp=array2(ii:ii+1,jj:jj+1,kk:kk+1,:)
>
>
> Regards,
> Florin

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us