You are here : matlabImage Processingcp2tform

cp2tform() - Image Processing

cp2tform is not recommended. Use fitgeotrans instead.


Syntax

TFORM = cp2tform(movingPoints,fixedPoints, transformtype)TFORM = cp2tform(CPSTRUCT, transformtype)[TFORM, movingPoints, fixedPoints]
= cp2tform(CPSTRUCT, ...)TFORM = cp2tform(movingPoints,fixedPoints,
'polynomial', order)TFORM = cp2tform(CPSTRUCT,'polynomial',order)TFORM = cp2tform(movingPoints,fixedPoints,'piecewise
linear')TFORM = cp2tform(CPSTRUCT,'piecewise
linear')TFORM = cp2tform(movingPoints,fixedPoints,'lwm', N)TFORM = cp2tform(CPSTRUCT, 'lwm', N)[TFORM, movingPoints, fixedPoints, movingPoints_bad, fixedPoints_bad]
= cp2tform(movingPoints, fixedPoints, 'piecewise
linear')[TFORM, movingPoints, fixedPoints, movingPoints_bad, fixedPoints_bad]
= cp2tform(CPSTRUCT, 'piecewise linear')


Example

I = checkerboard;
J = imrotate(I,30);
fixedPoints = [11 11; 41 71];
movingPoints = [14 44; 70 81];
cpselect(J,I,movingPoints,fixedPoints);
 
t = cp2tform(movingPoints,fixedPoints,'nonreflective similarity');
 
% 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)


Output / Return Value


Limitations


Alternatives / See Also


Reference