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

Home » Public Forums » archive » Re: Rotate volumes
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: Rotate volumes [message #26704 is a reply to message #26703] Sun, 16 September 2001 17:09 Go to previous message
Martin Downing is currently offline  Martin Downing
Messages: 136
Registered: September 1998
Senior Member
Hi Bob,
Is this code any help or have I missed the point?

===========================================
function transform_image3d, im, rotation = rot,
scale=scale,translate=translate, centre_rot=centre_rot
; translate an image volume using interplote
s = size(im)
; for clarity:
sx=s(1)
sy=s(2)
sz=s(3)
if undefined(rot) then rot =[0,0,0]
if undefined(centre_rot) then centre_rot =[(sx-1)/2.0,(sy-1)/2.0,(sz-1)/2.0]
if undefined(translate) then translate =[0,0,0]
if undefined(scale) then scale =[1,1,1]
;generate image coordinates
i = lindgen(sx*sy*sz) ; temp array = vector indices
coords = [ [i mod sx],[(i / sx) mod (sy)],[i /
(sx*sy)],[replicate(1,sx*sy*sz)]]
; generate transform (or add your own)
t3d, /reset
t3d,trans= -centre_rot
t3d, rot=rot
t3d, trans= centre_rot + translate
t3d, scale=scale
; calc new sample positions of voxels
coords = coords#!p.t
; use these to interpolate voxels (note this is only SAMPLED)
imageT = reform( interpolate(im, coords(*,0), coords(*,1), coords(*,2),
missing=0),sx,sy,sz)
return, imageT
end

pro test,s, rot=rot
; tests the above
if undefined(s) then s = 32
if undefined(rot) then rot = [0,10,45]
vol = rebin(bytscl(dist(s,s)),s,s,s, /sample)
vol = transform_image3d(vol, rot = rot)
; Display volume:
XVOLUME, vol
end
===============================
you could easinly add your own transform as an input arg
cheers

Martin
--
----------------------------------------
Martin Downing,
Clinical Research Physicist,
Orthopaedic RSA Research Centre,
Woodend Hospital, Aberdeen, AB15 6LS.
Tel. 01224 556055 / 07903901612
Fax. 01224 556662

m.downing@abdn.ac.uk

"B.C. Hamans" <s448443@stud.tue.nl> wrote in message
news:9o2j63$44e$1@news.tue.nl...
> Hi,
>
> I'm still working on my volumes (see previous posting) and trying to
rotate
> and translate them to match each other. It would be very nice if I could
use
> something like XVOLUME_ROTATE, /T3D or /MATRIX=!P.T. (Of course this isn't
> possible). I also thought about using CONVERT_COORD but this is no
solution
> either (i think). The 2 volumes are described by a matrix of dimension
> 256x256x256 containing gray values between 0 and 255. I obtain a
translation
> matrix to fit the 2 images from an external program. In the future i hope
to
> do this by using MIM or MIM2 (http://www.nuclear.uhrad.com/mim2.htm). The
> translation matrix is of the form !P.T (4x4).
>
> I already made some nice projections of the volumes using PROJECT_VOL in 3
> directions and would like to add some sliders to define rotation,
> translation and skew factors. To align the volumes before further
processing
> them.
>
> Anybody?
>
> Bob
>
>
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Variable undefined after while-cycle?
Next Topic: significance probability when using CORRELATE?

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

Current Time: Thu Oct 09 22:33:56 PDT 2025

Total time taken to generate the page: 0.32038 seconds