title: Frequency domain filtering with scipy.fftpack, ifft2 does not give the desired result
body: <p>I am trying to simply apply a Gaussian filter on a gray-scale input lena image in frequency domain with the following code and here is the wrong output I am getting:</p>
  
  <p><a href="https://i.stack.imgur.com/D3qTu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/D3qTu.png" alt="enter image description here"></a></p>
  
  <pre><code>from scipy import signal
  from skimage.io import imread
  import scipy.fftpack as fp
  import matplotlib.pyplot as plt
  
  im = imread('lena.jpg') # read lena gray-scale image
  # create a 2D-gaussian kernel with the same size of the image
  kernel = np.outer(signal.gaussian(im.shape[0], 5), signal.gaussian(im.shape[1], 5))
  
  freq = fp.fftshift(fp.fft2(im))
  freq_kernel = fp.fftshift(fp.fft2(kernel))
  convolved = freq*freq_kernel # simply multiply in the frequency domain
  im_out = fp.ifft2(fp.ifftshift(convolved)).real # output blurred image
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/Ks2mr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ks2mr.png" alt="enter image description here"></a></p>
  
  <p>However, if I do the same but use <code>signal.fftconvolve</code> I get the desired blurred image output as shown below:</p>
  
  <pre><code>im_out = signal.fftconvolve(im, kernel, mode='same')  # output blurred image
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/ZfOUU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZfOUU.png" alt="enter image description here"></a></p>
  
  <p>My input image is 220x220, is there any padding issue? if so, how to solve it and make the first code (without <code>fftconvolve</code>) work? any help will be highly appreciated.</p>