1. Enter:
heart=read_binary('/usr/local/rsi/idl_5.4/idl_5.4/examples/data/abnorm.dat',$
data_dims=[64,64,16],data_type=1)
2. Load an appropriate color table:
loadct, 3
3. Display the first slice of our 3-D array:
The asterisks (*) in the first two element positions tell IDL to use all of the elements in those positions. Hence, the TV procedure displays a 64 by 64 byte image. The image is rather small.tv,heart[*, *, 0]
4. Now resize each image in the array with bi-linear interpolation by entering:
h=rebin(heart,320,320,16)
5. Then display:
Each image in H is 5 times its previous size. Now a simple FOR statement can be used to animate the images. (A more robust and convenient animation routine, XINTERANIMATE, is described next.)tv,h[*, *, 0]
6. To animate, enter:
for i=0,15 do tvscl,h[*,*,i]

IDL displays the 16 images in the array H sequentially. To repeat the animation, press the up arrow key to recall the command and press enter.
7. Dismiss the window:
wdelete
1. Create a new array to hold the heartbeat data:
s now holds 32 byte by 32 byte versions of the heartbeat images. SURFACE plots are often more legible when made from a resized version of the dataset with fewer data points in it.s=rebin(heart,32,32,16)
2. Display the first image in s, as a wire-mesh surface by entering:
surface,s[*,*,0]

Now create a whole series of SURFACE plots, one for each image in the original dataset.
3. To do this, first create a three-dimensional array to hold all of the images by entering:
The variable frames will hold sixteen, 300 by 300 byte images.frames=bytarr(300,300,16)
4. Now create a 300 by 300 pixel window in which to display the images:
The next command will draw each frame of the animation. A SURFACE plot is drawn in the window and then the TVRD function is used to read the image from the plotting window into the frames array. The FOR loop is used to increment the array indices. The lines which follow are actually a single IDL command. The dollar sign ($) works as a continuation character in IDL and the ampersand (&) allows multiple commands in the same line.window,1,title='IDL Animation',xsize=300,ysize=300
5. Enter:
You should see a series of SURFACE plots being drawn in the animation window, as shown in below. The ZRANGE keyword is used to keep theheight axis the same for each plot.for i=0,15 do begin surface,s[*,*,i],zrange=[0,250]$
& frames[0,0,i]=tvrd()&end
6. Now display the new images in series by entering:
for i=0,15 do tv,frames[*,*,i]

1. Save the first frame of the S dataset in the variable A to simplify the next set of commands:
a=s[*,*,0]
2. Create a window in which to display your surface:
window,0,xsize=300,ysize=300
3. Display a as a wire-mesh surface:
Setting the XSTYLE, YSTYLE, and ZSTYLE keywords equal to 4 turns axis drawing off. Usually, IDL automatically scales the axes of plots to best display all of the data points sent to the plotting routine. However, for this sequence of images, it is best if each SURFACE plot is drawn with the same size axes. The SCALE3 procedure can be used to control various aspects of the three-dimensional transformation used to display plots.surface,a,xstyle=4,ystyle=4,zstyle=4
4. Force the X and Y axis ranges to run from 0 to 32 and the Z axis range to run from 0 to 250:
scale3,xrange=[0,31],yrange=[0,31],zrange=[0,250]
5. Set up the XINTERANIMATE routine to hold 40, 300 by 300 byte images:
xinteranimate,set=[300,300,40],/showload
6. Generate each frame of the animation and store it for the XINTERANIMATE routine. Once a 3-D transformation has been established, most IDL plotting routines can be made to use it by including the T3D keyword. The [XYZ]STYLE keywords are shortened to [XYZ]ST:
for i=0,39 do begin scale3,az= -i * 9 & surface,a, $7. Play images back as an animation after all the images have been saved in the XINTERANIMATE routine:
/t3d,xstyle=4,ystyle=4,zstyle=4 & xinteranimate,$
frame=i,win=0 & end
xinteranimate

The XINTERANIMATE window should appear, as shown above. Tape recorderstyle controls can be used to play the animation forward, play it backward, or stop. Individual frames can also be selected by moving the Animation Frame slider. TheOptions menu controls the style and direction of image playback. Click on End Animation when you are ready to return to the IDL Command Line.
1. Delete both window 0 and window 1 by entering:
wdelete, 0
wdelete, 1
| This information is available in alternative formats upon request by individuals with disabilities. Please send email to alt-format@msi.umn.edu or call 612-624-0528. | ||||||||||||
|
HOME
| QUESTIONS | FEEDBACK
|
||||||||||||
|
||||||||||||