MATLAB回転の問題
-
12-10-2019 - |
質問
ねえ、3D Shepp Logan Phantomの回転バージョンが必要で、それに対応する回転マトリックスが必要です。これがここにあります。Phantom3Dという関数を使用して3D SLPを作成します。この関数により、オイラーの角度が回転を指定できます。したがって、例:
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軸上の回転が異なるようです。通常、ユーラー角の回転マトリックスを計算すると、次のように述べています。
d = [cos(phi)sin(phi)0 -sin(phi)cos(phi)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軸を使用しているわけではないため、標準の回転が説明されているわけではないため、オイラーと軸の角度については、常に各回転を個別に観察し、個別の回転行列を研究する必要があります。
とにかく見てくれてありがとう