Last change
on this file since 246 was
246,
checked in by sommeria, 13 years ago

thin plate shell (patch) introduced

File size:
893 bytes

Line  

1  % DM: MxN matrix whose i,j position contains the Euclidean 

2  % distance between the ith data site and jth center 

3  function EM = tps_eval(dsites,ctrs) 

4  [M,s] = size(dsites); [N,s] = size(ctrs); 

5  EM = zeros(M,N); 

6  

7  % calculate distance matrix: accumulate sum of squares of coordinate differences 

8  % The ndgrid command produces two MxN matrices: 

9  % Dsite, consisting of N identical columns (each containing 

10  % the dth coordinate of the M data sites) 

11  % Ctrs, consisting of M identical rows (each containing 

12  % the dth coordinate of the N centers) 

13  for d=1:s 

14  [Dsites,Ctrs] = ndgrid(dsites(:,d),ctrs(:,d)); 

15  EM = EM + (DsitesCtrs).^2;%EM=square of distance matrices 

16  end 

17  

18  % calculate tps 

19  np=find(EM~=0); 

20  EM(np) = EM(np).*log(EM(np))/2;%= tps formula r^2 log(r) (EM=r^2) 

21  

22  % add linear gradient part: 

23  EM = [EM ones(M,1) dsites]; 

Note: See
TracBrowser
for help on using the repository browser.