[37] | 1 | function [xp1,xp2]=wtps(phi,Yp) |
---|
| 2 | % WTPS Thin-plate spline warping |
---|
| 3 | % [XP1,XP2]=WTPS(PHI,YP) computes the thin-plate spline (TPS) |
---|
| 4 | % specified by the basis PHI and the warped control point Yp. |
---|
| 5 | % |
---|
| 6 | % Yp is a 2xK matrix with one column per control point and the basis |
---|
| 7 | % PHI is calculated by means of the TPS function. |
---|
| 8 | % |
---|
| 9 | % The thin-palte spline is defined on a domain X1,X2 and specified |
---|
| 10 | % by a set of points Y and their warp YP. The spline passes |
---|
| 11 | % interpolates exaclty the control points. |
---|
| 12 | % |
---|
| 13 | % The parameters X1,X2 and Y are used to compute the basis PHI. This |
---|
| 14 | % operation is fairily slow, but computing the spline for a given Yp |
---|
| 15 | % is then very quick, as the operation is just a linear combination |
---|
| 16 | % of the basis. |
---|
| 17 | % |
---|
| 18 | % Examples: [xp1,xp2]=WTPS(TPS(x1,x2,Y),Yp). |
---|
| 19 | % |
---|
| 20 | % See also TPS. |
---|
| 21 | |
---|
| 22 | % AUTORIGHTS |
---|
| 23 | % Copyright (C) 2006 Andrea Vedaldi |
---|
| 24 | % |
---|
| 25 | % This file is part of VLUtil. |
---|
| 26 | % |
---|
| 27 | % VLUtil is free software; you can redistribute it and/or modify |
---|
| 28 | % it under the terms of the GNU General Public License as published by |
---|
| 29 | % the Free Software Foundation; either version 2, or (at your option) |
---|
| 30 | % any later version. |
---|
| 31 | % |
---|
| 32 | % This program is distributed in the hope that it will be useful, |
---|
| 33 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 34 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 35 | % GNU General Public License for more details. |
---|
| 36 | % |
---|
| 37 | % You should have received a copy of the GNU General Public License |
---|
| 38 | % along with this program; if not, write to the Free Software Foundation, |
---|
| 39 | % Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 40 | |
---|
| 41 | [K,M,N] = size(phi) ; |
---|
| 42 | |
---|
| 43 | Xp=[Yp, zeros(2,3)]*reshape(phi,K,M*N) ; |
---|
| 44 | |
---|
| 45 | xp1 = reshape(Xp(1,:),M,N) ; |
---|
| 46 | xp2 = reshape(Xp(2,:),M,N) ; |
---|