大家好,我需要3D Shepp Logan Phantom的旋转版本,它是相应的旋转矩阵。现在,我使用一个称为phantom3d的函数来创建3D SLP,该功能允许Euler角度指定旋转。因此:例如:

phi = 45;
theta = 45;
psi = 45;

%just a matrix of inputs to create the shepp logan phantom
e =[  1  .6900  .920  .810      0       0       0      0+phi      0+theta      0+psi
    -.8  .6624  .874  .780      0  -.0184       0      0+phi      0+theta      0+psi
    -.2  .1100  .310  .220    .22       0       0    -18+phi      0+theta     10+psi
    -.2  .1600  .410  .280   -.22       0       0     18+phi      0+theta     10+psi
     .1  .2100  .250  .410      0     .35    -.15      0+phi      0+theta      0+psi
     .1  .0460  .046  .050      0      .1     .25      0+phi      0+theta      0+psi
     .1  .0460  .046  .050      0     -.1     .25      0+phi      0+theta      0+psi
     .1  .0460  .023  .050   -.08   -.605       0      0+phi      0+theta      0+psi
     .1  .0230  .023  .020      0   -.606       0      0+phi      0+theta      0+psi
     .1  .0230  .046  .020    .06   -.605       0      0+phi      0+theta      0+psi   ];

img = phantom3d(e, 50);

现在,根据文献,您可以使用以下方式计算旋转矩阵:

phi = ((phi + 180)/180).*pi;
theta = (theta/180).*pi;
psi = (psi/180).*pi;

cphi = cos(phi);
sphi = sin(phi);
ctheta = cos(theta);
stheta = sin(theta);
cpsi = cos(psi);
spsi = sin(psi);

% Euler rotation matrix
alpha = [cpsi*cphi-ctheta*sphi*spsi   cpsi*sphi+ctheta*cphi*spsi  spsi*stheta;
        -spsi*cphi-ctheta*sphi*cpsi  -spsi*sphi+ctheta*cphi*cpsi cpsi*stheta;
        stheta*sphi  

但是,如果我使用phantom3d与一个应用于非旋转图像上旋转矩阵的函数进行比较我创建的图像,则它们不会以相同的方式旋转。查看此图像的旋转版本的代码是:

img = phantom3d(50);
szout = size(img);
Cf = eye(4);
Cf(1:3, 4) = -szout/2;
Co = Cf;
%previously created alpha
alpha(4,4) = 1;
%Cf & Co are used for translations
Rmatrix = inv(Cf) * alpha * Co;
[x, y, z]=ndgrid(single(1:szout(1)), single(1:szout(2)), single(1:szout(3)));
xyz = [x(:) y(:) z(:) ones(numel(x),1)]*Rmatrix(1:3,:)';
xyz = reshape(xyz,[szout 3]);
img2 = interpn(single(img), xyz(:,:,:,1),xyz(:,:,:,2),xyz(:,:,:,3), 'cubic', 0);

因此,我实际上需要让IMG和IMG2是相同的,但事实并非如此。我发现某种情况下,将PSI,PHI和THETA设置为45,然后在创建IMG2时向Phi添加180,给出相同的结果,因此与之有一定的关系,但我似乎找不到它。

有人有任何想法,建议,帮助吗?

多谢

有帮助吗?

解决方案

问题解决了,显然在X轴上的旋转在此函数中是不同的。通常,当u计算欧拉角的旋转矩阵时,它们是:

d = [cos(phi)sin(phi)0 -sin(phi)cos(phi)0 0 0 1];

c = [1 0 0 0 cos(theta)sin(theta)0 -sin(theta)cos(theta)];

b = [cos(psi)sin(psi)0 -sin(psi)cos(psi)0 0 0 1];

r = b*c*d;

但是,在我的情况下,C是不同的,即在旧Y轴上旋转:

c = [cos(theta)0 -sin(theta)0 1 0 sin(theta)0 cos(theta)];

如果有人遇到类似的问题,则应始终观察每个旋转,并研究欧拉和轴角的单独旋转矩阵,因为并非每个函数都使用相同的x,y,z轴或以标准解释的方式进行旋转。

无论如何,感谢您的观看

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top