% For display of selected weak classifiers by adaboost
function toDisplay = displaySelectedFilters(lambdas,selectedXs,selectedYs,selectedOs,patch_size)

scale = .7;  % scale of Gabors
norient = 15;  % number of orientations
[allfilter, allsymbol] = makefilter(scale, norient);  % generate Gabor filters 

imPos = zeros(patch_size); % show basis where lambdas are positive
imNeg = zeros(patch_size);
imAll = zeros(patch_size);

maxLambda = max(abs(lambdas));
lambdas = floor(lambdas / maxLambda * 254);

for k = 1:length(selectedXs)
    orientationIndex = selectedOs(k) + 1; % starts from 1
    col = selectedYs(k)+1;
    row = selectedXs(k)+1;
    if lambdas(k) >= 0
        imPos = drawGaborSymbol(imPos, allsymbol, row, col, orientationIndex, lambdas(k));
        imAll = drawGaborSymbol(imAll, allsymbol, row, col, orientationIndex, lambdas(k));
    else
        imNeg = drawGaborSymbol(imNeg, allsymbol, row, col, orientationIndex, -1*lambdas(k));
        imAll = drawGaborSymbol(imAll, allsymbol, row, col, orientationIndex, -1*lambdas(k));
    end
end

toDisplay = uint8(zeros(patch_size(1),patch_size(2),3));
toDisplay(:,:,2) = uint8(255-imPos);
toDisplay(:,:,1) = uint8(255-imNeg);
toDisplay(:,:,3) = 255;