高斯模糊与FFT [英] gaussian blur with FFT

查看:180
本文介绍了高斯模糊与FFT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用FFT实现高斯模糊,可以在这里找到以下配方。

im trying to implement a gaussian blur with the use of FFT and could find here the following recipe.


这意味着你可以采用图像的
傅立叶变换和
滤波器,乘以(复数)
结果,然后采用逆
傅立叶变换。

This means that you can take the Fourier transform of the image and the filter, multiply the (complex) results, and then take the inverse Fourier transform.

我有一个内核K,一个7x7 Matrix
和一个Image I,一个512x512矩阵。

I've got a kernel K, a 7x7 Matrix and a Image I, a 512x512 Matrix.

我不明白如何将K乘以I.
唯一的方法是通过使K与我一样大(512x512)?

I do not understand how to multiply K by I. Is the only way to do that by making K as big as I (512x512) ?

推荐答案

是的,你需要通过用零填充来使K与我一样大。此外,在填充之后,但在进行内核的FFT之前,需要使用环绕转换它,使得内核的中心(高斯的峰值)处于(0,0)。否则,您的过滤图像将被翻译。或者,您可以在完成后翻译生成的过滤后的图像。

Yes, you do need to make K as big as I by padding it with zeros. Also, after padding, but before you take the FFT of the kernel, you need to translate it with wraparound, such that the center of the kernel (the peak of the Gaussian) is at (0,0). Otherwise, your filtered image will be translated. Alternatively, you can translate the resulting filtered image once you are done.

另一点:对于不使用FFT的小内核实际上可能更快。 2D高斯内核是可分离的,这意味着您可以将其分为x和y的两个1D内核。然后,您可以在空间域中的x和y方向上进行两次1D卷积,而不是2D卷积。对于较小的内核,最终可能比使用FFT在频域中进行卷积更快。

Another point: for small kernels not using the FFT may actually be faster. A 2D Gaussian kernel is separable, meaning that you can separate it into two 1D kernels for x and y. Then instead of a 2D convolution, you can do two 1D convolutions in x and y directions in the spatial domain. For smaller kernels that may end up being faster than doing the convolution in the frequency domain using the FFT.

这篇关于高斯模糊与FFT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆