# drawGaborSymbol

## PURPOSE

drawGaborSymbol - Render one Gabor symbol on image.

## SYNOPSIS

function im = drawGaborSymbol(im, allsymbol, row, col, orientationIndex, intensity)

## DESCRIPTION

     drawGaborSymbol - Render one Gabor symbol on image.

## CROSS-REFERENCE INFORMATION

This function calls:

This function is called by:

- displaySelectedFilters displaySelectedFilters - For display of selected weak classifiers by adaboost.

## SOURCE CODE

    0001 function im = drawGaborSymbol(im, allsymbol, row, col, orientationIndex, intensity)
    0002 % drawGaborSymbol - Render one Gabor symbol on image.
    0003
    0004 if abs(intensity) < 1e-3
    0005     return;
    0006 end
    0007
    0008 nRow = size(im,1);
    0009 nCol = size(im,2);
    0010 h = (size(allsymbol{1}, 1)-1)/2;  % half size of Gabor
    0011
    0012 % position in image
    0013 top = row-h;
    0014 down = row+h;
    0015 left = col-h;
    0016 right = col+h;
    0017
    0018 % top2, down2, ... is the position in filter
    0019
    0020 % deal with out-of-boundary cases
    0021 if top < 1
    0022     top2 = 1-top + 1;
    0023     top = 1;
    0024 else
    0025     top2 = 1;
    0026 end
    0027
    0028 if down > nRow
    0029     down2 = size(allsymbol{1},1)-(down-nRow);
    0030     down = nRow;
    0031 else
    0032     down2 = size(allsymbol{1},1);
    0033 end
    0034
    0035 if left < 1
    0036     left2 = 1-left + 1;
    0037     left = 1;
    0038 else
    0039     left2 = 1;
    0040 end
    0041
    0042 if right > nCol
    0043     right2 = size(allsymbol{1},2)- (right-nCol);
    0044     right = nCol;
    0045 else
    0046     right2 = size(allsymbol{1},1);
    0047 end
    0048
    0049
    0050 to_draw = allsymbol{orientationIndex} * intensity;
    0051 if down-top ~= down2-top2 || right-left~= right2-left2
    0052     disp(sprintf('%d %d %d %d, %d %d %d %d',top,down,left,right,top2,down2,left2,right2));
    0053 end
    0054 mask = im(top:down,left:right) + 1e-6 >= to_draw(top2:down2,left2:right2);
    0055 im(top:down,left:right) = (1-mask).*to_draw(top2:down2,left2:right2) + mask.*im(top:down,left:right);
    0056