procrustesAnalysis - val = ( x(:,1,i) - xm ) .^2 + ( x...

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

View Full Document Right Arrow Icon
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);
Background image of page 1

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

View Full DocumentRight Arrow Icon
Background image of page 2
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

This note was uploaded on 11/06/2010 for the course CSE 527 taught by Professor Ab during the Fall '09 term at Cornell University (Engineering School).

Page1 / 2

procrustesAnalysis - val = ( x(:,1,i) - xm ) .^2 + ( x...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online