3D Rotation around generic axis

조회 수: 2 (최근 30일)
Andrea
Andrea 2013년 11월 21일
답변: Matt J 2013년 11월 26일
I want to rotate an image around a the y axis using Matlab, I expect to have a 3 dimensional matrix as output and each plane of the matrix should contain a small strip of the image.
I insert my image in a 3D array and then I apply the transformation matrix using affine3d and imwarp commands.
This is an example:
c = cos(theta); s=sin(theta);
ux =0; uy=1; uz=0;
tx =0; ty=0; tz=0;
tt = [(1-c)*ux^2+c (1-c)*ux*uy-s*uz (1-c)*ux*uz+s*uy tx;...
(1-c)*ux*uy+s*uz (1-c)*uy^2+c (1-c)*uy*uz-s*ux ty;...
(1-c)*ux*uz-s*uy (1-c)*uy*uz+s*ux (1-c)*uz^2+c tz; 0 0 0 1];
tform = affine3d(tt);
R = imref3d(size(image));
imrot = imwarp(image,R,tform);
In this way I get a rotation around the origin axis, but I want the rotation around the centre of the image so I change the value of ty.
ty=128
But affine3d wants only [0 0 0 1] as last column. Is there a way to rotate using these commands or do I have to find another way?

답변 (2개)

Alex Taylor
Alex Taylor 2013년 11월 26일
The Image Processing Toolbox uses a different convention for the transformation matrix than the one you are expecting. This is discussed here:
The form used by IPT is:
[A B C 0;...
D E F 0;...
G H I 0;...
Tx Ty Tz 1];
In other words, its the transpose of what you are expecting.

Matt J
Matt J 2013년 11월 26일
In addition to what Alex said, changing the translation parameters to the location of the image center is not equivalent to making that the center of rotation. You can use this tool
to get the R,t data for a rotation about the axis you want. Then feed [R,t].' to maketform.

카테고리

Help CenterFile Exchange에서 Geometric Transformation and Image Registration에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by