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
>
>
|