This is a static copy of a profile reportHome
maketform (8605 calls, 7.540 sec)
Generated 05-Nov-2014 07:52:59 using cpu time.
function in file /usr1/opt/matlab/7.13/toolbox/images/images/maketform.m
Copy to new window for comparing multiple runs
Parents (calling functions)
Lines where the most time was spent
Line Number | Code | Calls | Total Time | % Time | Time Plot |
131 | t = feval(fcn,varargin{2:end})... | 8605 | 3.605 s | 47.8% |  |
114 | transform_type = getTransformT... | 8605 | 3.124 s | 41.4% |  |
109 | msgstruct = nargchk(1,Inf,narg... | 8605 | 0.190 s | 2.5% |  |
110 | if ~isempty(msgstruct) | 8605 | 0.120 s | 1.6% |  |
118 | fcn = @affine; | 1721 | 0.060 s | 0.8% |  |
All other lines | | | 0.441 s | 5.8% |  |
Totals | | | 7.540 s | 100% | |
Children (called functions)
Code Analyzer results
Line number | Message |
109 | NARGCHK will be removed in a future release. Use NARGINCHK instead. |
Coverage results
[ Show coverage for parent directory ]
Total lines in function | 131 |
Non-code lines (comments, blank lines) | 111 |
Code lines (lines that can run) | 20 |
Code lines that did run | 14 |
Code lines that did not run | 6 |
Coverage (did run/can run) | 70.00 % |
Function listing
time calls line
1 function t = maketform( varargin )
2 % MAKETFORM Create spatial transformation structure (TFORM).
3 % T = MAKETFORM(TRANSFORMTYPE,...) creates a multidimensional spatial
4 % transformation structure (a 'TFORM struct') that can be used with
5 % TFORMFWD, TFORMINV, FLIPTFORM, IMTRANSFORM, or TFORMARRAY.
6 % TRANSFORMTYPE can be 'affine', 'projective', 'custom', 'box', or
7 % 'composite'. Spatial transformations are also called geometric
8 % transformations.
9 %
10 % T = MAKETFORM('affine',A) builds a TFORM struct for an N-dimensional
11 % affine transformation. A is a nonsingular real (N+1)-by-(N+1) or
12 % (N+1)-by-N matrix. If A is (N+1)-by-(N+1), then the last column
13 % of A must be [zeros(N,1); 1]. Otherwise, A is augmented automatically
14 % such that its last column is [zeros(N,1); 1]. A defines a forward
15 % transformation such that TFORMFWD(U,T), where U is a 1-by-N vector,
16 % returns a 1-by-N vector X such that X = U * A(1:N,1:N) + A(N+1,1:N).
17 % T has both forward and inverse transformations.
18 %
19 % T = MAKETFORM('projective',A) builds a TFORM struct for an N-dimensional
20 % projective transformation. A is a nonsingular real (N+1)-by-(N+1)
21 % matrix. A(N+1,N+1) cannot be 0. A defines a forward transformation
22 % such that TFORMFWD(U,T), where U is a 1-by-N vector, returns a 1-by-N
23 % vector X such that X = W(1:N)/W(N+1), where W = [U 1] * A. T has
24 % both forward and inverse transformations.
25 %
26 % T = MAKETFORM('affine',U,X) builds a TFORM struct for a
27 % two-dimensional affine transformation that maps each row of U
28 % to the corresponding row of X. U and X are each 3-by-2 and
29 % define the corners of input and output triangles. The corners
30 % may not be collinear.
31 %
32 % T = MAKETFORM('projective',U,X) builds a TFORM struct for a
33 % two-dimensional projective transformation that maps each row of U
34 % to the corresponding row of X. U and X are each 4-by-2 and
35 % define the corners of input and output quadrilaterals. No three
36 % corners may be collinear.
37 %
38 % T = MAKETFORM('custom',NDIMS_IN,NDIMS_OUT,FORWARD_FCN,INVERSE_FCN,
39 % TDATA) builds a custom TFORM struct based on user-provided function
40 % handles and parameters. NDIMS_IN and NDIMS_OUT are the numbers of
41 % input and output dimensions. FORWARD_FCN and INVERSE_FCN are
42 % function handles to forward and inverse functions. Those functions
43 % must support the syntaxes X = FORWARD_FCN(U,T) and U =
44 % INVERSE_FCN(X,T), where U is a P-by-NDIMS_IN matrix whose rows are
45 % points in the transformation's input space, and X is a
46 % P-by-NDIMS_OUT matrix whose rows are points in the transformation's
47 % output space. TDATA can be any MATLAB array and is typically used to
48 % store parameters of the custom transformation. It is accessible to
49 % FORWARD_FCN and INVERSE_FNC via the "tdata" field of T. Either
50 % FORWARD_FCN or INVERSE_FCN can be empty, although at least
51 % INVERSE_FCN must be defined to use T with TFORMARRAY or IMTRANSFORM.
52 %
53 % T = MAKETFORM('composite',T1,T2,...,TL) or T = MAKETFORM('composite',
54 % [T1 T2 ... TL]) builds a TFORM whose forward and inverse functions are
55 % the functional compositions of the forward and inverse functions of the
56 % T1, T2, ..., TL. Note that the inputs T1, T2, ..., TL are ordered just
57 % as they would be when using the standard notation for function
58 % composition:
59 %
60 % T = T1 o T2 o ... o TL
61 %
62 % and note also that composition is associative, but not commutative.
63 % This means that in order to apply T to the input U, one must apply TL
64 % first and T1 last. Thus if L = 3, for example, then TFORMFWD(U,T) is
65 % the same as TFORMFWD(TFORMFWD(TFORMFWD(U,T3),T2),T1). The components
66 % T1 through TL must be compatible in terms of the numbers of input and
67 % output dimensions. T has a defined forward transform function only if
68 % all of the component transforms have defined forward transform
69 % functions. T has a defined inverse transform function only if all of
70 % the component functions have defined inverse transform functions.
71 %
72 % T = MAKETFORM('box',TSIZE,LOW,HIGH) or T = MAKETFORM('box',INBOUNDS,
73 % OUTBOUNDS) builds an N-dimensional affine TFORM struct, T. TSIZE is
74 % an N-element vector of positive integers, and LOW and HIGH are also
75 % N-element vectors. The transformation maps an input "box" defined
76 % by the opposite corners ONES(1,N) and TSIZE or, alternatively, by
77 % corners INBOUNDS(1,:) and INBOUND(2,:) to an output box defined by
78 % the opposite corners LOW and HIGH or OUTBOUNDS(1,:) and OUTBOUNDS(2,:).
79 % LOW(K) and HIGH(K) must be different unless TSIZE(K) is 1, in which
80 % case the affine scale factor along the K-th dimension is assumed to be
81 % 1.0. Similarly, INBOUNDS(1,K) and INBOUNDS(2,K) must be different
82 % unless OUTBOUNDS(1,K) and OUTBOUNDS(1,K) are the same, and vice versa.
83 % The 'box' TFORM is typically used to register the row and column
84 % subscripts of an image or array to some "world" coordinate system.
85 %
86 % Example
87 % -------
88 % Make and apply an affine transformation.
89 %
90 % T = maketform('affine',[.5 0 0; .5 2 0; 0 0 1]);
91 % tformfwd([10 20],T);
92 % I = imread('cameraman.tif');
93 % transformedI = imtransform(I,T);
94 % figure, imshow(I), figure, imshow(transformedI)
95 %
96 % See also FLIPTFORM, IMTRANSFORM, TFORMARRAY, TFORMFWD, TFORMINV.
97
98 % Copyright 1993-2010 The MathWorks, Inc.
99 % $Revision: 1.10.4.15.2.1 $ $Date: 2011/07/18 00:34:40 $
100
101 % Testing notes
102 % Syntaxes
103 %---------
104 % T = MAKETFORM( 'affine', A )
105 %
106 % A: Numeric, non-singular, real square matrix (no Infs or Nans).
107 % Last column must be zero except for a one in the lower right corner.
108
0.19 8605 109 msgstruct = nargchk(1,Inf,nargin,'struct'); %#ok<NCHK>
0.12 8605 110 if ~isempty(msgstruct)
111 error(message('images:maketform:invalidNumInputs', msgstruct.message));
112 end
113
3.12 8605 114 transform_type = getTransformType(varargin{1});
115
0.05 8605 116 switch transform_type
0.05 8605 117 case 'affine'
0.06 1721 118 fcn = @affine;
0.02 6884 119 case 'projective'
120 fcn = @projective;
6884 121 case 'composite'
1721 122 fcn = @composite;
0.01 5163 123 case 'custom'
0.04 1721 124 fcn = @custom;
0.02 3442 125 case 'box'
0.04 3442 126 fcn = @box;
127 otherwise
128 error(message('images:maketform:unknownTransformType', varargin{ 1 }))
129 end
130
3.60 8605 131 t = feval(fcn,varargin{2:end});
Other subfunctions in this file are not included in this listing.