如何实现频域平滑?
我想在频域中对图像进行平滑。当我使用谷歌查看任何文章时,它给出了一些我不需要的 Matlab 代码。我可以对图像进行 FFT,但我不知道如何在频域中实现任何平滑技术(ILPF、BLPF、IHPF、BHPF)。如果您可以在不使用任何图像处理库的情况下为上述任何技术提供任何代码示例,那将非常有帮助,并且首选 C#。
谢谢,
I want to do smoothing to an image in the frequency domain. when i use google to see any articles it gave some Matlab codes which i don't need. i could do FFT to an image but i don't know how to implement any smoothing techniques(ILPF, BLPF, IHPF, BHPF) in frequency domain. if you can provide any code samples for any of the above techniques WITHOUT using any image processing libraries it will be really helpful and C# is preferred.
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您能定义一下“频域平滑”的含义吗?您可以使用 FFT 生成频谱图像,并将图像乘以某个函数以衰减特定频率,然后使用逆 FFT 将频谱转换回图像。然而,对于这种过滤(乘以频率中的某些缩放函数),您可以通过与空间域中的对偶函数进行卷积来更快地获得相同的结果。
无论如何,如果您想自己实现这一点,请阅读 FFT(快速傅立叶变换)和卷积。如果您感兴趣,您还可以查看信号处理教科书,因为离散滤波背后的理论相当深入。如果没有这个理论,这些算法就没有多大意义,尽管你当然可以在不理解它们的情况下应用它们。
如果您想实现自己的 DSP 算法,请在线查看本书。特别是,第 33 章描述了巴特沃斯滤波器设计背后的数学和算法。第 12 章描述如何实现 FFT。
Could you define what you mean by 'smoothing in the frequency domain'? You can generate a spectrum image using FFT and multiply the image by some function to attenuate particular frequencies, then convert the spectrum back to an image using the inverse-FFT. However, for this kind of filtering (multiplication by some scaling function in frequency), you can achieve the same result more quickly by convolving with the dual function in the spatial domain.
In any case, if you wish to implement this yourself, read up on FFT (the fast Fourier transform) and convolution. You might also check out a signal processing textbook, if you're interested, as the theory behind discrete filtering is fairly deep. The algorithms won't make a whole lot of sense without that theory, though you can certainly apply them without understanding them.
If you want to implement your own DSP algorithms, check out this book online. In particular, Ch 33 describes the math and algorithm behind Butterworth filter design. Ch 12 describes how to implement FFT.
Christian Graus 有一个关于代码项目的精彩系列,您可能会发现它很有用,尤其是第 2 部分,其中涉及平滑滤波器:
There is a great series on Code Project by Christian Graus which you might find useful, especially part 2 which deals amongst others with smoothing filters:
克山,很简单。想象一下 FFT 是另外两张图片,其中低频位于中间,高频远离中间。如果像素编号从 -w/2 到 w/2 和 -h/2 到 h/2,您可以简单地测量到中间的距离 a(x,y)=sqrt(x^2+y^2) 。然后采用任意单调递减函数,例如 f(x)=1/(1+x),并将 fft 中的每个点与 f(a(x,y)) 相乘。然后使用 FFT 变换回来。
f(x) 有不同的选择,看起来会有所不同。例如高斯函数或贝塞尔函数或其他函数。我为我的本科生做了这个,非常有趣。如果您给我发邮件,我会将我的程序发送给您:-)。
需要注意的一点是 fft 输出的顺序。它生成的数组可以以奇怪的方式排序。找出哪个数组索引对应于“分析”傅里叶变换中的哪个 x/y 位置非常重要!
Keshan, it is simple. Imagine the FFT is another two pictures where low frequencies lie in the middle and high frequencies away from the middle. If the pixels are numbered from -w/2 to w/2 and -h/2 to h/2 you can simply measure the distance from the middle as a(x,y)=sqrt(x^2+y^2). Then take some arbitrary monotonic decreasing function like f(x)=1/(1+x) and multiply each point in the fft with f(a(x,y)). Then transform back using the FFT.
There are different choices for f(x) which will look different. For example a gaussian function or bessel or whatever. I did this for my undergrad and it was great fun. If you send me a mail I will send you my program :-).
One bit caveat is the ordering in output of the fft. The arrays it generates can be ordered in weird ways. It is important that you find out which array index corresponds to which x/y-position in the "analytical" fourier transform!
对于所有图像/信号处理,我推荐 OpenCV。
它有一个托管的 C# 包装器:Emgu。
http://www.emgu.com/wiki/index.php/Main_Page
For all image/signal processing I recommend OpenCV.
This has a managed C# wrapper: Emgu.
http://www.emgu.com/wiki/index.php/Main_Page