tic;

nScaleGabor=length(GaborScaleListLastIteration);
nScaleDoG=length(DoGScaleListLastIteration);
numFilter = nScaleGabor*2*numOrient+ nScaleDoG;  % sin and cosin separately
numSketch= numSketchListLastIteration;

filters=[];
% Gabor filters [sin cos sin cos ......]
for iScale=1:nScaleGabor
    f = MakeFilter(GaborScaleListLastIteration(iScale),numOrient);
    for i=1:numOrient
     f_r{i} =real(f{i});
     f_i{i} =imag(f{i});
    end
    
    filters = [filters f_r f_i];
end
% DoG filter
for iScale=1:nScaleDoG
    f0 = single(dog(DoGScaleListLastIteration(iScale),0));
    filters = [filters f0];
end

halfFilterSizes = zeros(size(filters));
for iF = 1:numFilter
    filters{iF} = single(filters{iF});
    halfFilterSizes(iF)=(size(filters{iF},1)-1)/2;
end

Corr = CorrFilterFrame(filters); %calculate correlation among filters

[allFilterR, allFilterI, allSymbol] = MakeFilterBank(GaborScaleListLastIteration, DoGScaleListLastIteration, numOrient);
[Crr, Cri, Cir, Cii] = CorrFilter(allFilterR, allFilterI); %calculate correlation among filters

half = zeros(1, numOrient*nScaleGabor+nScaleDoG); 
for (i=1:numOrient*nScaleGabor+nScaleDoG)
    half(i) = (size(allFilterR{1, i}, 1)-1)/2;
end

 % all necessary variables for filter selection will be stored in structure variable "FitersInformation", which will be sent into the filter selection function
FiltersInformation.allFilterR = allFilterR;  
FiltersInformation.allFilterI = allFilterI;
FiltersInformation.allSymbol = allSymbol;
FiltersInformation.Crr = Crr;
FiltersInformation.Cri = Cri;
FiltersInformation.Cir = Cir;
FiltersInformation.Cii = Cii;
FiltersInformation.half = half;
disp(['finished adding DoG to filter bank: ' num2str(toc) ' seconds']);

SUM1mapLearn = cell(numImage,numFilter);
MAX1mapLearn = cell(numImage,numFilter);

