Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
D. Mattes wrote: > > hello idl users: > has anybody out there in idl-land written or seen code to apply arbitrary > rotations to 3-d arrays??? > > thanks in advance! > > david mattes Are you talking about rotating the entire array, as opposed to extracting a 2D slice out of the array? If so, you might want to look into AIR (Automated Image Registration), a package written at UCLA: http://bishopw.loni.ucla.edu/AIR3/ (AIR Automated Image Registration) The C source is available, so if you need to integrate it with IDL you could modify it appropriately. This program was intended for use with medical images, don't know how general it is, but it works well, at least for our brain images. If you don't find what you want, email me offline and I can probably help come up with something. I don't think it would be too difficult. Basically once you've chosen an origin about which to rotate the array, you would generate a 4D fltarr for the volume whose values correspond to the three indices, then compute the affine transformation matrix for (1) translation to the origin; (2) rotations; (3) scale factors if you want; and (4) translate back to the original origin, all using T3D. Then transform the coordinates using: vol_ind(*,*,*j) = vol_ind(*,*,*) # !P.T(*,*,*) (!P.T is computed by T3D). Similar code for the 2D case of extracting a slice from a 3D volume can be seen in $IDL_DIR/lib/extract_slice.pro, but be aware that: 1) You will get incorrect results if any of the rotations results in an exchange-of-axis (near 90 degrees); these must be applied first. 2) This routine does not account for anisotropic voxels. Dave Foster -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~ David S. Foster Univ. of California, San Diego Programmer/Analyst Brain Image Analysis Laboratory foster@bial1.ucsd.edu Department of Psychiatry (619) 622-5892 8950 Via La Jolla Drive, Suite 2240 La Jolla, CA 92037 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~