function [allFiltered] = applyfilter1(I, dogFilter);
% filter images by a bank of filters
% I: input images
% allFilter: filter bank
numImage = size(I, 2); % number of training images
h = (size(dogFilter, 1)-1)/2;  % half size of filters
allFiltered = cell(numImage, 1);  % filtered images

for (i = 1 : numImage)
   [sx, sy] = size(I{i});  % size of images
   filtered = filter2(dogFilter, I{i}); 
   energy = filtered.*filtered;  % compute the local energy
   energy([1:h sx-h:sx],:) = 0.; energy(:,[1:h sy-h:sy]) = 0.; 
   ave = sum(sum(energy((h+1):(sx-h-1), (h+1):(sy-h-1))))/(sx-2*h-1)/(sy-2*h-1); 
   allFiltered{i} = energy/ave;  % normalizing by whitening
end
    
 
