why the translation parameters calculated by cp2tform based on point sets are not correct?
Show older comments
I'd like to calculate the affine transformation parameters(translation, scale, rotation) based on two point sets: base_points and input_points. I know in advance that input_points is the result of 30 degree rotation of base_points and there is no scaling or translation between two point sets. So, it's expected that the rotation is 30 degree, the translation is 0, and the scaling is 1. however, i got the no-zero translation value when i run them with cp2tform.
Point sets and scripts are as follows:
base_points [284411.225493012 3410018.84471633; 284411.225493012 3497999.47692107; 400816.369640822 3497999.47692107; 400816.369640822 3410018.84471633]
input_points(as a result of 30degree rotation of base_points)
[284411.225493014 3410018.84471633; 240420.909390644 3486212.30724665; 341230.721353836 3544414.87932055; 385221.037456207 3468221.41679023]
i run point sets with the following script:
base_points;
input_points;
length=size(base_points,2);
t = cp2tform(input_points,base_points,'affine');
% Calculate RMSE
reg_points = tformfwd(input_points, t);
error = (reg_points - base_points);
rmse = sqrt( sum(sum(error.*error))/length /2)
% Recover angle and scale by checking how a unit vector
% parallel to the x-axis is rotated and stretched.
u = [0 1];
v = [0 0];
[x, y] = tformfwd(t, u, v);
dx = x(2) - x(1);
dy = y(2) - y(1);
angle = (180/pi) * atan2(dy, dx)
scale = 1 / sqrt(dx^2 + dy^2)
trans = [x(1) y(1)]
Can anybody tell me how can i get the correct translation parameters (make the trans [x,y] zero)? Thanks a million.
Answers (0)
Categories
Find more on Delaunay Triangulation in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!