comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: extracting subarray (*,*,index) gives (1,1,index). WHY ???
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: extracting subarray (*,*,index) gives (1,1,index). WHY ??? [message #6868] Fri, 23 August 1996 00:00
lmudge is currently offline  lmudge
Messages: 9
Registered: October 1994
Junior Member
In article <3219CC9A.53D7@neurologie.uni-duesseldorf.de>,
knorr@neurologie.uni-duesseldorf.de says...
> i want to extract a line from a 3D image by doing
> line = image(*,*,z)
> i expect line to be a 1d vector with dimension dim(z)
> or to be more IDLish, i expect the following to hold
> size(line) == (z)
> but instead I get
> size(line) == (1,1,z)

Try line = reform(image(*,*,z))
this should work.

Leith.

------------------------------------------------------------ ----------------
_/ _/_/_/_/ _/ _/_/_/_/_/ _/ _/ Leith Mudge
_/ _/ _/ _/ _/ _/ lmudge@awadi.com.au
_/ _/ _/ _/ _/ _/ 10 Bristol Terrace
_/ _/_/_/_/ _/ _/ _/_/_/_/_/ Oakden SA 5086
_/ _/ _/ _/ _/ _/ Australia
_/ _/ _/ _/ _/ _/ Phone: +61 8 8266 4862
_/_/_/_/ _/_/_/_/ _/ _/ _/ _/

The victors called the revolution a triumph of liberty; but now and then
liberty, in the slogans of the strong, means freedom from restraint in the
exploitation of the weak. -Will Durant
------------------------------------------------------------ ----------------
Re: extracting subarray (*,*,index) gives (1,1,index). WHY ??? [message #6870 is a reply to message #6868] Thu, 22 August 1996 00:00 Go to previous message
Graeme K Harkness is currently offline  Graeme K Harkness
Messages: 3
Registered: August 1996
Junior Member
Uwe Knorr wrote:
>
> Dear reader,
>
> i want to extract a line from a 3D image by doing
> line = image(*,*,z)
> i expect line to be a 1d vector with dimension dim(z)
> or to be more IDLish, i expect the following to hold
> size(line) == (z)
> but instead I get
> size(line) == (1,1,z)
> I hope you know what I mean.
>
> Thanx for giving me some of your time,
>
> Uwe Knorr.
>

I think I know what you mean. You should use the

REFORM

function to convert the 1x1xz sized array into a 1-d one of size z

Graeme

-----------------------------------------------
| Graeme K Harkness |
| Department of Physics & Applied Physics |
| University of Strathclyde |
| GLASGOW G4 0NG UK |
| Tel: +44-141-552 4400 x3354 |
| Fax: +44-141-552 2891 |
| graeme@phys.strath.ac.uk |
-----------------------------------------------
Re: extracting subarray (*,*,index) gives (1,1,index). WHY ??? [message #6881 is a reply to message #6870] Wed, 21 August 1996 00:00 Go to previous message
peter is currently offline  peter
Messages: 80
Registered: February 1994
Member
Uwe Knorr (knorr@neurologie.uni-duesseldorf.de) wrote:
: Dear reader,

: i want to extract a line from a 3D image by doing
: line = image(*,*,z)
: i expect line to be a 1d vector with dimension dim(z)
: or to be more IDLish, i expect the following to hold
: size(line) == (z)
: but instead I get
: size(line) == (1,1,z)
: I hope you know what I mean.

Bit confusing here, line=image(*,*,z) will give you a (nx,ny,1) result.
You probably meant you do line=image(x,y,*), which gives a (1,1,nz)
result. If you want a (nz) result, do line=reform(image(x,y,*)).
Reform, used like this, strips collapses leading dimensions of length 1.

Peter
Re: extracting subarray (*,*,index) gives (1,1,index). WHY ??? [message #6887 is a reply to message #6881] Tue, 20 August 1996 00:00 Go to previous message
a2652099 is currently offline  a2652099
Messages: 10
Registered: August 1996
Junior Member
In article <3219CC9A.53D7@neurologie.uni-duesseldorf.de>
knorr@neurologie.uni-duesseldorf.de (Uwe Knorr) wrote:

> i want to extract a line from a 3D image by doing
> line = image(*,*,z)

A line? Wouldn't that rather be image(a,b,*) ?

> i expect line to be a 1d vector with dimension dim(z)
> or to be more IDLish, i expect the following to hold
> size(line) == (z)
> but instead I get
> size(line) == (1,1,z)
> I hope you know what I mean.

If I do, I think using the REFORM command would help you, eg.
line = REFORM( image(a,b,*), z ),
where z is the 3rd dimension of your array. This converts your (1,1,z)
array into the (z) array.

Alex
Re: extracting subarray (*,*,index) gives (1,1,index). WHY ??? [message #6888 is a reply to message #6887] Tue, 20 August 1996 00:00 Go to previous message
Thomas A. McGlynn is currently offline  Thomas A. McGlynn
Messages: 23
Registered: March 1996
Junior Member
Uwe Knorr wrote:
>
> Dear reader,
>
> i want to extract a line from a 3D image by doing
> line = image(*,*,z)
> i expect line to be a 1d vector with dimension dim(z)
> or to be more IDLish, i expect the following to hold
> size(line) == (z)
> but instead I get
> size(line) == (1,1,z)
> I hope you know what I mean.
>
> Thanx for giving me some of your time,
>
> Uwe Knorr.
>

I'm a little confused by your message. I'm guessing
what you want is something like:

x = fltarr(30,30,30)
y = x(1,1,*)

where you'd like y to be a one dimensional vector of length 30.
If so then you need to rewrite the second statement as

y = reform(x(1,1,*))

while will get rid of the extra leading dimensions.

What you describe though is:

y = x(*,*,1)

which will return y as a two-dimensional array and suppress
the third dimension automatically. I.e., we'd have

size(y) == (2,30,30,4,900)

Hope this helps,

Tom McGlynn
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Help on CGM Device
Next Topic: I had to try it!

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Thu Oct 09 13:17:30 PDT 2025

Total time taken to generate the page: 0.96120 seconds