source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/vlutil/toolbox/tps.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

  • Property svn:executable set to *
File size: 1.9 KB
Line 
1function [phi,S] = tps(x1,x2,Y)
2% TPS  Compute the thin-plate spline basis
3%   PHI=TPS(X1,X2,Y) returns the basis PHI of a thin-plate spline
4%   (TPS) defined on the domain X1,X2 with control points Y.
5%
6%   X1 and X2 are MxN matrices specifying the grid vertices.  When
7%   warping images, these usually correspond to image pixels.
8%
9%   Y is a 2xK matrix specifying the control points, one per
10%   column. Ofthen Y is a subset of the domain X1,X2, but this is not
11%   required.
12%
13%   PHI is a (K+3)xNxM matrix, with one layer per basis element. Each
14%   basis element is a function of the domain X1,X2.
15%
16%   [PHI,S] = TPS(X1,X2,Y) additionally returns the stiffness matrix S
17%   of the TPS.
18%
19%   See also WTPS.
20
21% AUTORIGHTS
22% Copyright (C) 2006 Andrea Vedaldi
23%       
24% This file is part of VLUtil.
25%
26% VLUtil is free software; you can redistribute it and/or modify
27% it under the terms of the GNU General Public License as published by
28% the Free Software Foundation; either version 2, or (at your option)
29% any later version.
30%
31% This program is distributed in the hope that it will be useful,
32% but WITHOUT ANY WARRANTY; without even the implied warranty of
33% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
34% GNU General Public License for more details.
35%
36% You should have received a copy of the GNU General Public License
37% along with this program; if not, write to the Free Software Foundation,
38% Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
39
40X = [x1(:)';x2(:)'] ;
41
42K = size(Y,2) ;
43Q = size(X,2) ;
44U = tpsu(Y,Y) ;
45L = [[ones(1,K); Y], zeros(3) ; U, ones(K,1), Y'] ;
46invL = inv(L) ;
47
48tmp = tpsu(Y,X) ;
49phi = invL * [ ones(1,Q) ; X(1,:) ; X(2,:) ; tmp ] ;
50
51[M,N] = size(x1) ;
52phi = reshape(phi,K+3,M,N) ;
53
54if nargout > 1
55  % See Bookstein; note that here the terms are re-arranged a bit
56  invLn = invL(1:K, end-K+1:end) ;
57  S = invLn * U * invLn ;               
58end
Note: See TracBrowser for help on using the repository browser.