# displayTemplate

## PURPOSE

displayTemplate - Display the symbolic template of an active basis template.

## SYNOPSIS

function sym = displayTemplate(selectedRow,selectedCol,selectedO, selectedS,selectedMean,allsymbol,nGaborOri,subsample)

## DESCRIPTION

     displayTemplate - Display the symbolic template of an active basis template.

## CROSS-REFERENCE INFORMATION

This function calls:

- drawGaborSymbol drawGaborSymbol - Display one Gabor symbol on image canvas.

This function is called by:

- LearnS2Template LearnS2Template - Learns an active basis template for Ellipsoid, angle,
- generateTransformedS2Templates generateTransformedS2Templates - Affine transforms of the S2
- generateTransformedTemplates generateTransformedTemplates - Affine transforms of the ellipsoid

## SOURCE CODE

    0001 function sym = displayTemplate(selectedRow,selectedCol,selectedO, selectedS,selectedMean,allsymbol,nGaborOri,subsample)
    0002 % displayTemplate - Display the symbolic template of an active basis template.
    0003
    0004 %% determine the rectangular size of the template
    0005 % Note: The row/column indices are relative to the origin (0,0).
    0006 maxScale = max(selectedS); % starts from 0
    0007 margin = ceil( size(allsymbol{maxScale*nGaborOri+1},1) / 2 ); % to allow enough space for Gabor symbol
    0008 selectedRow = selectedRow * subsample;
    0009 selectedCol = selectedCol * subsample;
    0010 selectedS = selectedS + 1; % now starts from 1
    0011 top = min(selectedRow);
    0012 down = max(selectedRow);
    0013 left = min(selectedCol);
    0014 right = max(selectedCol);
    0015 height = down - top + 2 * margin;
    0016 width = right - left + 2 * margin;
    0017 % make it square:
    0018 if height > width
    0019     width = height;
    0020 else
    0021     height = width;
    0022 end
    0023
    0024 %% display Gabor symbols one by one
    0025 nGaborScale = numel(allsymbol) / nGaborOri;
    0026 sym = zeros(height,width);
    0027 for k = 1:length(selectedRow)
    0028     scale = selectedS(k);
    0029     ori = selectedO(k) + 1;
    0030     col = selectedCol(k) + floor(width/2);
    0031     row = selectedRow(k) + floor(height/2);
    0032     if scale < 1 || scale > nGaborScale
    0033         continue;
    0034     end
    0035     sym = drawGaborSymbol( sym, allsymbol, row, col, ori, nGaborOri, scale, sqrt(selectedMean(k)) );
    0036 end
    0037 sym = uint8(255 * (sym-min(sym(:)))/(max(sym(:))-min(sym(:))));
    0038
    0039