|
Re: Slicing a volume [message #36890 is a reply to message #36885] |
Wed, 05 November 2003 02:55  |
Nuno Oliveira
Messages: 75 Registered: October 2003
|
Member |
|
|
Where can I get the archives? :)
Nuno.
"David Fanning" <david@dfanning.com> wrote in message
news:MPG.1a118d22fe0bd165989730@news.frii.com...
>
> This is an old (and dear) "feature" of IDL, in which
> the last dimension of a multi-dimensional array is dropped
> if that dimension is 1. This is not the only kind of havoc
> it can cause, as you will learn when you study the archives
> of this newsgroup.
>
|
|
|
Re: Slicing a volume [message #36901 is a reply to message #36890] |
Tue, 04 November 2003 09:15  |
mmiller3
Messages: 81 Registered: January 2002
|
Member |
|
|
>>>> > "Nuno" == Nuno Oliveira <df23775@hotmail.com> writes:
> Anyone had some time the same problem? Is the
> EXTRACT_SLICE the only solution?
One solution is to use reform to remove degenerate indices:
IDL> vol=INTARR(100,100,100)
IDL> sliceX=vol(50,*,*)
IDL> sliceY=vol(*,50,*)
IDL> sliceZ=vol(*,*,50)
IDL> help, sliceX
SLICEX INT = Array[1, 100, 100]
IDL> help, reform(sliceX)
<Expression> INT = Array[100, 100]
Mike
|
|
|
Re: Slicing a volume [message #36902 is a reply to message #36901] |
Tue, 04 November 2003 09:17  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Nuno Oliveira writes:
> Since I began to work with IDL one of the things that makes confuse is when
> I want to make a two-dimension array from a three-dimension array (and I
> often do).
>
> For example I can create de three-dimension array vol
>
> vol=INTARR(100,100,100)
>
> But when I try to extract slices along different axes I get "different"
> variables.
>
> sliceX=vol(50,*,*)
> sliceY=vol(*,50,*)
> sliceZ=vol(*,*,50)
>
> Then, I see that sliceX is an array [1,100,100], and the same with sliceY
> but, sliceZ is an array [100,100]. sliceX and sliceY are what I am tempted
> to call a false 3D array because one of the dimensions can have only one
> value. My question is why they are not equal: all 2D arrays or all 3D
> arrays?
Oh, dear. These new guys always like to pick at
the old wounds, don't they? :-)
This is an old (and dear) "feature" of IDL, in which
the last dimension of a multi-dimensional array is dropped
if that dimension is 1. This is not the only kind of havoc
it can cause, as you will learn when you study the archives
of this newsgroup.
Typically, what is wanted is a 2D array after extraction.
You can get this by, for example, doing this:
IDL> vol = randomu(seed, 50, 50, 50)
IDL> sliceX = Reform(vol[25,*,*])
IDL> help, sliceX
SLICEX FLOAT = Array[50, 50]
> I know this not very important, just bores me that I need to make a specific
> code for the Z direction. I can use the function EXTRACT_SLICE, but it
> really makes me sad that it doesn't work the easy way. Anyone knows why? Am
> I making any mistake? Anyone had some time the same problem? Is the
> EXTRACT_SLICE the only solution?
I think EXTRACT_SLICE is for extracting a slice of a volume
at some arbitrary angles. Orthogonal slices are always (as
far as I know) extracted by array subscripting in the way
you are doing it.
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|