affine transform matrix from given point set

6 次查看(过去 30 天)
** same questionswere uploaded in researchgate
I am trying to make general affine 3d transform matrix from 4 point set to another 4-point pointset (actually, it is rigid transformation- rotation + translation) for using with 'imwarp'
e.g pointset (x1 y1 z1)->(X1 Y1 Z1), (x2 y2 z2)->(X2 Y2 Z2),(x3 y3 z3)->(X3 Y3 Z3), (x4 y4 z4)->(X4 Y4 Z4)
However, I found some nice tutorial about affine transform.
From this workbook, the SAM (Simplex Affine Map) is the general affine mapping function from one point to another. In addition, they showed the way to convert this SAM form to canonical form;
where A: rotation matrix, T: translation matrix
I think I can modify this matrix 'A' and 'T' to an affine matrix that compatible with ‘imwarp’in MATLAB.
However, I could not find a nice way to express this Matrix expression in MATLAB unless expand all this cofactor with hand. Can someone suggest an efficient way of expressing this matrix in MATLAB style? or even without this method, could you suggest the way how to generate the transform matrix from give 4 point set?
Regards,
ps. all pictures were from the workbook

回答(1 个)

Yong Guk Kang
Yong Guk Kang 2019-11-5
I just found the answer on my own. It's so funny that I didn't think this way.
I will leave an answer here for people like me 4 hours ago...
%R=A*T where R= reference points, T= target points
% 4 pointset of reference
r1 =[1 0 0]
r2 =[1 1 0]
r3 =[2 0 0]
r4 =[1 0 1]
% 4 pointset of target
t1 =[0 0 0]
t2 =[0 2 0]
t3 =[2 0 0]
t4 =[0 0 2]
%homogenous coordinate
R=[r1,1; r2,1; r3,1; r4,1]';
T=[t1,1; t2,1; t3,1; t4,1]';
%since R=A*T, A= R*inv(T) or just A=R/T (in MATLAB)
A=R/T
% Result :
% A =
%
% 0.5000 0 0 1.0000
% 0 0.5000 0 0
% 0 0 0.5000 0
% 0 0 0 1.0000
% computes twofold scaled, translated matrix well

类别

Help CenterFile Exchange 中查找有关 Agriculture 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by