function invf = invertFilter(f, s)
% invert a convolution filter, using FFT/IFFT
% troncate the result if below threshold
% s is the size of the FFT support


bf = zeros([1 s]);
bf(round(s/2-length(f)/2+1):round(s/2+length(f)/2)) = f;


fftf = fft(bf);
fftfminus1 = 1./real(fftf);
%plot(abs(fftf));
%figure;
%plot(abs(fftfminus1));

invf = real(ifft(fftfminus1));

thres = 1e-9;
[val, ind] = find([abs(invf) > thres]); 
minind = min(ind);
maxind = max(ind);

invf = invf(minind:maxind);
   
   
   