Marc,
Thats a neat way of doing it - just watch out for the effect of wrap-around
if you use translate (caused by the use of SHIFT) on matching two images.
The method I posted actually uses linear interpolation (I misread the help!)
and is a little quicker (20sec c.f. 29sec) for a general rotation on a PIII
800). The rotation orders are not the same but could easily be made so.
cheers
Martin
"Marc Schellens" <m_schellens@hotmail.com> wrote in message
news:3BA7001F.BF7A8DF8@hotmail.com...
> "B.C. Hamans" wrote:
>>
>> 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
>
> If Martin's function does what you want:
>
> I had a similar problem some time ago,
> this solutions seemed to be faster (even with loops), less
> resource-hungry
> and you get an intepolated result.
>
> hope it helps,
> :-) marc
>
>
>
> MRI2 it the bytarr(256,256,256)
> phi fltarr(3) the three angles to rotate (+/- is convention)
> trans intarr(3) the translation (in voxels)
>
> print,'X...'
> if phi[0] ne 0.0 then begin
> for x=0,255 do begin
>
> MRI2[x,*,*]=rot(/INTERP,reform(MRI2[x,*,*],256,256),-phi[0], MISSING=0)
> endfor
> endif
> print,'Y...'
> if phi[1] ne 0.0 then begin
> for y=0,255 do begin
>
> MRI2[*,y,*]=rot(/INTERP,reform(MRI2[*,y,*],256,256),phi[1],M ISSING=0)
> endfor
> endif
> print,'Z...'
> if phi[2] ne 0.0 then begin
> for z=0,255 do begin
> MRI2[*,*,Z]=rot(/INTERP,MRI2[*,*,Z],-phi[2],MISSING=0)
> endfor
> endif
>
> print,'shift...'
> MRI2=shift(MRI2,trans[0],trans[1],trans[2])
|