{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

procrustesAnalysis

# procrustesAnalysis - val = x,1,i xm.^2 x,2,i ym.^2 val =...

This preview shows pages 1–2. Sign up to view the full content.

function [ z ] = procrustesAnalysis( x ) %PROCRUSTESANALYSIS aligns a set of 2D points % [z] = procrustesAnalysis(x) % % Input: % x: M-by-2-by-N array where M is the number of points in a shape, N is % the number of data % Output: % z: M-by-2-by-N array where M is the number of points in a shape, N is % the number of data % % % TODO: implement procrustes analysis % You may add more output arguments as needed %%% Computec the center of the X G = []; X = x; PMS= []; for i = 1: 40 srval = zeros (64); n = size(x(:,:,i)); xi = sum( x(:,1,i)); yi = sum( x(:,2,i)); xm = xi / n(1); ym = yi / n(1);

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: val = ( x(:,1,i) - xm ) .^2 + ( x (:,2,i) - ym ) .^2 ; val = sum (val); srval = sqrt(val); G = cat (1, G , srval); xj = ( x(:,1,i) - xm ) ./ srval; yj = ( x(:,2,i) - ym ) ./ srval; x(:,1,i) = xj; x(:,2,i) = yj; end for k =1:40 z = corr( x(:,:,1), x(:,:,k)); [U S V] = svd (z); R = V*U'; if (k == 2) R end M = sum( diag(S) ); ScF = M * G(1) / G(k); if (k ==2) ScF end T = mean(x(:,:,1)) - ScF * mean(x(:,:,k)) * R; if (k == 2) T end PM = ScF * x(:,:,k) * R ; for i = 1:64 PM(i,:) = PM(i,:) +T; end PMS = cat(3, PMS , PM); end z =PMS; end...
View Full Document

{[ snackBarMessage ]}

### Page1 / 2

procrustesAnalysis - val = x,1,i xm.^2 x,2,i ym.^2 val =...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online