最快的高斯模糊实现 [英] Fastest Gaussian blur implementation

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

问题描述

如何实施最快的高斯模糊算法?

我将用Java实现它,因此 GPU 解决方案是排除。我的应用程序 planetGenesis 是跨平台的,所以我不想要 JNI

I am going to implement it in Java, so GPU solutions are ruled out. My application, planetGenesis, is cross platform, so I don't want JNI.

推荐答案

你应该使用事实上,高斯核是可分离的,即即你可以将2D卷积表示为两个1D卷积的组合。

You should use the fact that a Gaussian kernel is separable, i. e. you can express a 2D convolution as a combination of two 1D convolutions.

如果滤波器很大,使用空间域中卷积的事实也是有意义的相当于频率(傅立叶)域中的乘法。这意味着您可以对图像和滤波器进行傅里叶变换,将(复数)结果相乘,然后进行逆傅立叶变换。 FFT(快速傅立叶变换)的复杂度是O(n log n),而卷积的复杂度是O(n ^ 2)。此外,如果您需要使用相同的滤镜模糊许多图像,您只需要对滤镜进行一次FFT。

If the filter is large, it may also make sense to use the fact that convolution in the spatial domain is equivalent to multiplication in the frequency (Fourier) domain. 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. The complexity of the FFT (Fast Fourier Transform) is O(n log n), while the complexity of a convolution is O(n^2). Also, if you need to blur many images with the same filter, you would only need to take the FFT of the filter once.

如果您决定使用FFT, FFTW库是一个不错的选择。

If you decide to go with using an FFT, the FFTW library is a good choice.

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

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