# make a kernel def gaussian2d(grid, s): m = [0., 0.] cov = [[s*s, 0], [0, s*s]] var = multivariate_normal(mean=m, cov=cov) return var.pdf(grid) kernelSize = 15 x = np.arange(-kernelSize+1, kernelSize, 1) y = x.copy() x0, y0 = np.meshgrid(x, y) grid = np.dstack((y0, x0)) # use a kernel for convolution kernel = gaussian2d(grid,s=sig) ndimage.filters.convolve(image, kernel, mode='constant', cval=0)