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

Home » Public Forums » archive » Re: Simple question on Arrays
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Simple question on Arrays [message #29140] Mon, 04 February 2002 02:37 Go to previous message
Bhautik Jitendra Josh is currently offline  Bhautik Jitendra Josh
Messages: 3
Registered: November 2001
Junior Member
Hi,

Your code should be something like:

FUNCTION multfile

;get list of filenames
result = Dialog_Pickfile(/Multiple_Files)

;get number of slices
n_slices = n_elements(result)

;create an empty image of size 512x512xn_slices
img = BYTARR(512,512,n_slices)

;for each slice in the selection
for i = 0, n_slices-1 do begin

;get filename
filename = result[i]

;create empty slice
image = bytarr(512,512)

;open file and fill in slice
OpenR, lun, filename, /Get_lun
ReadU, lun, image
Free_lun, lun

;store slice in volume
img[*,*,i]=image
endfor

;return image
return, img

END

You would use this function like:

volume=multifile()

where volume is the final volume of slices you'd like to access.

If you'd like to read DICOM data, then you should replace the three file
I/O lines (OPENR, READU, FREE_LUN etc.) with the appropriate lines for
reading DICOM data.

Hope this helps.

Cheers,
Bhautik

ps. if you are feeling like a bit of a n00b* with IDL, I do suggest you
spend some quality time with the IDL online help, and, when you really
want to get into it, <plug> read David Fannings ' IDL Programming
Techniques, 2nd Edition,' (www.dfanning.com) </plug> :)

*go see: http://www.bosskey.net/quake/glossary.html

> hi Dr.Joshi,
>
> here is the code that i wrote to change 2D array into
> a 3D form. I can now see there are as many images as i
> pick. but i want to get them in a variable which will
> be in an array form, that i can index the array for
> the particular slice like a[*,*,10]
>
> i don't know how to save the image in an array form.
>
> Please tell me how to achieve that...
>
> Thanking you,
> Sincerely,
> Akhila.
>
> PRO multfile
>
> result = Dialog_Pickfile(/Multiple_Files)
> help, result
> a = size(result)
> b = a[3]
>
> for i = 0, b-1 do begin
> filename = result[i]
> image = bytarr(512,512)
> OpenR, lun, filename, /Get_lun
> ReadU, lun, image
> Free_lun, lun
> help, image
>
> endfor
>
> END




________________________________________________________
/ \
|bjoshi@geocities.com | phone: 0404032617 |
|ICQ #: 2464537 | http://cow.mooh.org |
\~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(__)~~~~~~~/
(__) |..|--\
/--|^^| moo | |--|
|--| | \OO/||^
^||\oo/ moo
[Message index]
 
Read Message
Read Message
Previous Topic: Simple question on Arrays
Next Topic: representive digits

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

Current Time: Fri Oct 10 07:23:20 PDT 2025

Total time taken to generate the page: 1.92384 seconds