function g=dftfiltTN(f,H)
%DFTFILTTN Performs frequency domain filtering
% G=DFTFILTTN(F,H) filters F in the frequency domain 
% using the filter transfer function H of size P x Q. 
% F has the dimension M x N
% The output G is the filtered image, which has the same
% size as F.
% DFTFILTTN automatically pads F and H to size P x Q.
% DFTFILTTN assumes that F is real, and that H is real,
% uncertered, circulary-symmetric filter function.
[M N]=size(f);
[P Q]=size(H);
F=fft2(f,P,Q);          % Transform image and pad it
G=H.*F;                 % Perform filtering
g=ifft2(G); g=real(g);
g=g(1:M,1:N);           % Change to original size
