Code covered by the BSD License  

Highlights from
Active Shape Model (ASM) and Active Appearance Model (AAM)

image thumbnail

Active Shape Model (ASM) and Active Appearance Model (AAM)



16 Feb 2010 (Updated )

Cootes 2D/3D Active Shape & Appearance Model for automatic image object segmentation and recognition

function [Vertices,tform]=ASM_align_data2D(Vertices)
% Aligns the contours positions, center the data and remove rotation

% Center data to remove translation 
offsetv = -mean(Vertices,1);
Vertices(:,1) = Vertices(:,1) + offsetv(1);
Vertices(:,2) = Vertices(:,2) + offsetv(2);

%offsets=mean(sqrt(Vertices(:,1).^2+Vertices(:,2) .^2));

% Correct for rotation
% Calculate angle to center of all points
rot = atan2(Vertices(:,2),Vertices(:,1));
% Subtract the mean angle
rot = rot+offsetr;
% Make the new points, which all have the same rotation
dist = sqrt(Vertices(:,1).^2+Vertices(:,2).^2);
Vertices(:,1) = dist.*cos(rot);
Vertices(:,2) = dist.*sin(rot);

% Store transformation object

Contact us