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 [gtc,dgtc]=ASM_getProfileAndDerivatives2D(I,P,N,k)
% This function getProfileAndDerivatives, samples the image on lines
% perpendicular to the contour points, which are used to train the
% appearance model, and to find the best location for a contour point later
% on.
% [gt,dgt]=getProfileAndDerivatives(I,P,N,k)
% inputs,
%  I : The image color or greyscale
%  P : The locations of the contour points
%  N : The normals of the contour points
%  k : The length of the sampled line in one normal direction, 
%      total length becomes k*2+1
% outputs,
%  gt : Columns with the sampled lines perpendicular to the contour
%  dgt : The first order derivatives of the sampled lines
% Function written by D.Kroon University of Twente (February 2010)

gtc =zeros((k*2+1)*size(I,3),size(P,1));

for i=1:size(I,3)
    xi(xi<1)=1; xi(xi>size(I,1))=size(I,1);
	yi(yi<1)=1; yi(yi>size(I,2))=size(I,2);

    % Sample on the normal lines
    gt= interp2(I(:,:,i)',xi,yi,'cubic')';
    % Get the derivatives
    % Store the grey profiles and derivatives for the different color
    % channels
    b=(k*2+1)*(i-1)+1; e=b+(k*2+1)-1;
    gtc(b:e,:)=gt; dgtc(b:e,:)=dgt;
% Normalize the derivatives

Contact us