Why does the internal structure of the "tform" structure array returned by CP2TFORM change during execution for Image Processing Toolbox 5.0.1 (R14SP1)?

1 view (last 30 days)
When I execute the following script taken from the documentation for the CP2TFORM function in Image Processing Toolbox 5.0.1 (R14SP1):
base_points = [11 11; 41 71];
input_points = [14 44; 70 81] + 1e8;
tform = cp2tform(input_points,base_points,'linear conformal');
ss = tform.tdata.Tinv(2,1);
sc = tform.tdata.Tinv(1,1);
angle = atan2(ss,sc)*180/pi
scale = sqrt(ss*ss + sc*sc)
I observe the following error:
??? Reference to non-existent field 'Tinv'.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
This change has been incorporated into the documentation in Release 14 Service Pack 3 (R14SP3). For previous releases, read below for any additional information:
This issue is a known error in the documentation for Image Processing Toolbox 5.0.1 (R14SP1). CP2TFORM was enhanced for this version in order to handle ill-conditioned matrices. As a consequence, the internal structure of the "tform" structure array returned by CP2TFORM can change during execution for such cases.
You should refrain from accessing the internal structures of the "tform" array returned by the CP2TFORM function. Alternatives include using "method functions" such as TFORMFWD, TFORMINV, IMTRANSFORM, and TFORMARRAY to suit your needs.
As an example, for the script mentioned above, replace the following:
ss = tform.tdata.Tinv(2,1);
sc = tform.tdata.Tinv(1,1);
angle = atan2(ss,sc)*180/pi
scale = sqrt(ss*ss + sc*sc)
with
u = [0 1];
v = [0 0];
[x, y] = tformfwd(tform, 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)

More Answers (0)

Products


Release

R14SP1

Community Treasure Hunt

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

Start Hunting!