function [ handles ] = filtUpdate( handles, oldXSize,oldYSize )
% Must be called with the updated values in handles, and the old values
% supplied.

oldFiltSize = length(handles.filtVal);

for k=oldFiltSize:handles.numFiltersD
    handles.filtColor{k} = [0 0 0];
end

for k = 1:handles.numFiltersD
    newFiltVal = zeros(handles.ySizeD,handles.xSizeD);
    if k <= oldFiltSize
        tempFiltVal = handles.filtVal{k};
        if handles.xSizeD >= oldXSize
            if handles.ySizeD >= oldYSize
                newFiltVal(1:oldYSize,1:oldXSize) = tempFiltVal(1:oldYSize,1:oldXSize);
            else
                newFiltVal(1:handles.ySizeD,1:oldXSize) = tempFiltVal(1:handles.ySizeD,1:oldXSize);
            end
        else
            if handles.ySizeD >= oldYSize
                newFiltVal(1:oldYSize,1:handles.xSizeD) = tempFiltVal(1:oldYSize,1:handles.xSizeD);
            else
                newFiltVal(1:handles.ySizeD,1:handles.xSizeD) = tempFiltVal(1:handles.ySizeD,1:handles.xSizeD);
            end
        end    
    else
        if (k <= handles.ySizeD*handles.xSizeD)
            newFiltVal(k) = 1; 
        else
            newFiltVal(handles.ySizeD*handles.xSizeD) = 1; 
        end
    end 
    filtVal{k} = newFiltVal;
end
handles.filtVal = filtVal;

