Re: Rotating 3D image [message #53417] |
Fri, 13 April 2007 16:04 |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
StevenM writes:
> I hope somebody can help. I am not very good with IDL (and seem to be
> getting worse!)
>
> I am trying to write a function to store the maximum intensity
> projection of a 3D data set from various angles. So far I have
> managed to figure out (rightly of wrongly?)
>
> using
>
> scale3, xrange,yrange, zrange, ax=0 or 90 etc
>
> mip=voxel_proj(data,/maximum_intensity)
>
> gives me the mip at various rotations on the x-axis depending on the
> ax value. Now what I want to do is use a loop to cycle through
> various ax values and then store them in an array i.e. mip dimensions
> (640x512) and 10 different rotations about the x-axis would give
> newarray(640,512,10). This I could then somehow save as an Mpeg and
> so I would have a rotating movie!
I've never used VOXEL_PROJ, but I have used TRANSFORM_VOLUME
by Martin Downing:
http://www.dfanning.com/math_tips/rotvolume.html
Here is a very nice little program that gives you a MIP
cine using data available in the IDL distribution. I guess
it used TVImage, too, but you could substitute your own
TV command for that.
;---------------------------------------------------------
PRO CINE
; Load the data.
head = BytArr(80,100,57)
file = Filepath(Subdirectory=['examples','data'], 'head.dat')
OpenR, lun, file, /Get_Lun
ReadU, lun, head
Free_Lun, lun
; Set up the animation.
XInterAnimate, Set=[240, 300, 37], /Showload
; Load the animation
FOR j=0,36 DO BEGIN
rotHead = Transform_Volume(head, Missing=0, $
Rotation=[0,0,(j*10) MOD 360])
TVImage, Reform(Max(rotHead, DIMENSION=1))
XInteranimate, Frame=j, Window=!D.Window
ENDFOR
XInterAnimate, 50
END
;---------------------------------------------------------
You can find TVImage here, if you want to use that:
http://www.dfanning.com/programs/tvimage.pro
And, of course, there are MUCH better ways to animate
than MPEG. See this article for suggestions:
http://www.dfanning.com/tips/howmovie.html
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|