在 OpenCV 中显示傅里叶变换
我刚刚学习使用 OpenCV,但在使用 DFT 时遇到问题。我已经完成了一门使用 MatLab 的信号处理课程,因此我尝试完成我们在该课程中所做的一些练习。我正在尝试获取并显示图像的 FT,这样我就可以屏蔽一些频率。我希望能够看到《金融时报》,所以我知道要制作多大的面具,但当我尝试时,我得到了这样的图像:
而不是像其中之一
替代文本 http://www.ceremade.dauphine .fr/~peyre/numerical-tour/tours/graphics_synthesis_fourier/index_03.png
我是否在某个地方忘记了一步?我正在加载图像,将其类型转换为 CV_32FC1,获取其矩阵,获取 DFT,然后将生成的矩阵转回图像。我会发布我正在使用的代码是否有任何帮助?
或者是否有人有显示英国《金融时报》示例的链接?我只能找到使用它进行卷积的。
编辑:我得到图像的相位了吗?
I'm just learning to use OpenCV and am having a problem with using DFT. I've done a signal processing class which used MatLab, so I'm trying to go through some of the exercises we did in that class. I'm trying to get and display the FT of an image, so I can mask some of the frequencies. I'd like to be able to see the FT, so I know how big to make the mask, but when I tried, I got an image like this:
rather than like one of these
alt text http://www.ceremade.dauphine.fr/~peyre/numerical-tour/tours/graphics_synthesis_fourier/index_03.png
Am I forgetting a step somewhere? I'm loading the image, converting its type to CV_32FC1, getting the matrix of it, getting the DFT, and then getting turning the resulting matrix back into an image. I'll post the code I'm using if it will be of any help?
Or if someone has a link to an example of displaying the FT? I could only find ones which used it for the convolution.
EDIT: Did I get the Phase of the image?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在尝试使用 OpenCV 可视化图像上的 2D DFT 大小时遇到了类似的麻烦。我终于制作出了一个可行的实现。我不认为它是很棒的代码,而且它只在 256 x 256 8 位(灰度)单通道图像上进行了测试 -lenna.png (可能需要调整以适当填充其他图像尺寸)。输入图像和重建图像之间的均方误差为零,因此它正常工作。需要 OpenCV v2.1。
文件:mstrInclude.h
文件:main.cpp
I have run into similar trouble in trying to visualize the magnitude of a 2D DFT on an image with respect to OpenCV. I finally churned out a working implementation. I wouldn't consider it great code, and it has only been tested on a 256 x 256 8-bit (gray-scale) single-channel image--lenna.png (it may need to be tweaked to appropriately pad for other image dimensions). The mean-squared error between the input image and the reconstructed image is zero, so it is working as it should. OpenCV v2.1 is required.
file: mstrInclude.h
file: main.cpp