Thread Subject: A 2D mask for a 3d Matrix

Subject: A 2D mask for a 3d Matrix

From: Arun Ahuja

Date: 30 May, 2008 01:28:20

Message: 1 of 5

I have a 3D matrix of dimensions 140x1040x411, and have a mask ( a
matrix of 1's 0's) of 1040x411. Essentially what I want is the
columns associated with the ! in the mask. I want to you be able to
do something like 3darray(:, mask), should give me something 140xAxB
where A < 1040 and B <411. The standard vector notation does not do
this. Is there any good way, other than manually through a for loop?

Thanks

Subject: A 2D mask for a 3d Matrix

From: ImageAnalyst

Date: 30 May, 2008 03:11:24

Message: 2 of 5

On May 29, 9:28=A0pm, Arun Ahuja <aahuj...@gmail.com> wrote:
> I have a 3D matrix of dimensions 140x1040x411, and have a mask ( a
> matrix of 1's 0's) =A0of 1040x411. =A0Essentially what I want is the
> columns associated with the ! in the mask. =A0I want to you be able to
> do something like 3darray(:, mask), should give me something 140xAxB
> where A < 1040 and B <411. =A0The standard vector notation does not do
> this. =A0Is there any good way, other than manually through a for loop?
>
> Thanks
------------------------------------------------------
Arun:
Can we assume the mask is rectangular (solid 1's) and not some
arbitrary/random placement of 1's and 0's in an array. So you want to
essentially "crop" the larger array to the smaller rectangular mask
array? If so, check out the "subvolume()" function.
Regards,
ImageAnalyst

Subject: A 2D mask for a 3d Matrix

From: Image Analyst

Date: 30 May, 2008 03:15:03

Message: 3 of 5

Arun Ahuja <aahuja11@gmail.com> wrote in message <d63c38fa-
8313-4666-82eb-54791cc2e99a@z66g2000hsc.googlegroups.com>...
> I have a 3D matrix of dimensions 140x1040x411, and have a
mask ( a
> matrix of 1's 0's) of 1040x411. Essentially what I want
is the
> columns associated with the ! in the mask. I want to you
be able to
> do something like 3darray(:, mask), should give me
something 140xAxB
> where A < 1040 and B <411. The standard vector notation
does not do
> this. Is there any good way, other than manually through
a for loop?
>
> Thanks
---------------
I don't know if internally it does a for loop, but there is
a "subvolume()" function that you might want to take a look
at.

Subject: A 2D mask for a 3d Matrix

From: Arun Ahuja

Date: 30 May, 2008 03:48:00

Message: 4 of 5

On May 29, 10:11 pm, ImageAnalyst <imageanal...@mailinator.com> wrote:
> On May 29, 9:28 pm, Arun Ahuja <aahuj...@gmail.com> wrote:> I have a 3D matrix of dimensions 140x1040x411, and have a mask ( a
> > matrix of 1's 0's) of 1040x411. Essentially what I want is the
> > columns associated with the ! in the mask. I want to you be able to
> > do something like 3darray(:, mask), should give me something 140xAxB
> > where A < 1040 and B <411. The standard vector notation does not do
> > this. Is there any good way, other than manually through a for loop?
>
> > Thanks
>
> ------------------------------------------------------
> Arun:
> Can we assume the mask is rectangular (solid 1's) and not some
> arbitrary/random placement of 1's and 0's in an array. So you want to
> essentially "crop" the larger array to the smaller rectangular mask
> array? If so, check out the "subvolume()" function.
> Regards,
> ImageAnalyst

Thanks

But, yes the 1 0's maybe distrubted awkwardly (not necessaiirly a
rectangle). To be more specific the mask is created from inpolygon()
in which a polygon is drawn and a 1 is placed anywhere in the polygon
and a zero outside. Then I want the get the data coresspoding only to
those specfic points from some data cube.

Subject: A 2D mask for a 3d Matrix

From: ImageAnalyst

Date: 30 May, 2008 11:18:54

Message: 5 of 5

On May 29, 11:48=A0pm, Arun Ahuja <aahuj...@gmail.com> wrote:
> On May 29, 10:11 pm, ImageAnalyst <imageanal...@mailinator.com> wrote:
>
>
>
>
>
> > On May 29, 9:28 pm, Arun Ahuja <aahuj...@gmail.com> wrote:> I have a 3D =
matrix of dimensions 140x1040x411, and have a mask ( a
> > > matrix of 1's 0's) =A0of 1040x411. =A0Essentially what I want is the
> > > columns associated with the ! in the mask. =A0I want to you be able to=

> > > do something like 3darray(:, mask), should give me something 140xAxB
> > > where A < 1040 and B <411. =A0The standard vector notation does not do=

> > > this. =A0Is there any good way, other than manually through a for loop=
?
>
> > > Thanks
>
> > ------------------------------------------------------
> > Arun:
> > Can we assume the mask is rectangular (solid 1's) and not some
> > arbitrary/random placement of 1's and 0's in an array. =A0So you want to=

> > essentially "crop" the larger array to the smaller rectangular mask
> > array? =A0If so, check out the "subvolume()" function.
> > Regards,
> > ImageAnalyst
>
> Thanks
>
> But, yes the 1 0's maybe distrubted awkwardly (not necessaiirly a
> rectangle). =A0To be more specific the mask is created from inpolygon()
> in which a polygon is =A0drawn and a 1 is placed anywhere in the polygon
> and a zero outside. =A0Then I want the get the data coresspoding only to
> those specfic points from some data cube.- Hide quoted text -
>
> - Show quoted text -

----------------------------------
Arun:
Well then just use the "find()" command to get the columns of
vectors. But you won't have a 3D array anymore. Let's say your mask
is a torus, and you want just the columns that are 1 and not the
outside 0's nor the inner 0's columns. You'll have a bunch of columns
that correspond to the torus (not it's outside or center) but I'm not
sure how you plan on arranging them. I don't know if it will be some
kinds of cell array or separate vectors or if you'll just string them
all along into one long 1D array and then have do do some bookeeping
to keep track of Z inxeding (how it corresponds to the old Z index in
the 3D array). But again, the find command may do its own for loop
internally so I don't know that you're avoiding any for loop or saving
any time versus your own method.
Regards,
ImageAnalyst

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
subvolume Image Analyst 29 May, 2008 23:20:06
rssFeed for this Thread

Public Submission Policy

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.

Contact us at files@mathworks.com