# LearnActiveBasisTemplate

## PURPOSE

LearnActiveBasisTemplate - Learns an active basis template.

## SYNOPSIS

function LearnActiveBasisTemplate(category)

## DESCRIPTION

     LearnActiveBasisTemplate - Learns an active basis template.

## CROSS-REFERENCE INFORMATION

This function calls:

- ABlearn ABlearn - Learns an active basis template from images.

This function is called by:

- StartFromHere StartFromHere - The entry point of this project.

## SOURCE CODE

    0001 function LearnActiveBasisTemplate(category)
    0002 % LearnActiveBasisTemplate - Learns an active basis template.
    0003 %
    0004
    0005 rootFolder = pwd;
    0006 imageNames = [];
    0007 imageNames = [imageNames; dir(sprintf('%s/image/%s/*.jpg',rootFolder,category))];
    0008 imageNames = [imageNames; dir(sprintf('%s/image/%s/*.bmp',rootFolder,category))];
    0009 imageNames = [imageNames; dir(sprintf('%s/image/%s/*.png',rootFolder,category))];
    0010 n = numel(imageNames);
    0011 imagepaths = cell(n,1);
    0012 for i = 1:n
    0013     imagepaths{i} = sprintf('%s/image/%s/%s', rootFolder, category, imageNames(i).name);
    0014 end
    0015
    0016 % find the corresponding template parameter
    0017 load template_params
    0018 nT = length(templateParameters);
    0019 for iT = 1:nT
    0020     if strcmp(templateParameters(iT).category,category) == 1
    0021         templateSize = templateParameters(iT).templateSize;
    0022         nsketch = templateParameters(iT).nElement_activebasis;
    0023         GaborScale = templateParameters(iT).GaborScale;
    0024         break;
    0025     end
    0026 end
    0027
    0028 cd activebasis
    0029 ABlearn(category, imagepaths, nsketch, templateSize, GaborScale);
    0030 cd ..
    0031
    0032