绘制图像的2D FFT [英] Plot the 2D FFT of an image

查看:61
本文介绍了绘制图像的2D FFT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试绘制图像的 2D FFT:

I'm trying to plot the 2D FFT of an image:

from scipy import fftpack, ndimage
import matplotlib.pyplot as plt

image = ndimage.imread('image2.jpg', flatten=True)     # flatten=True gives a greyscale image
fft2 = fftpack.fft2(image)

plt.imshow(fft2)
plt.show()

但是我得到了 TypeError:图像数据无法转换为浮点数.

如何绘制图像的2D FFT?

推荐答案

任何 fft 的结果一般都是由复数组成.这就是为什么你不能以这种方式绘制它.根据您要查找的内容,您可以先查看绝对值

The result of any fft is generally composed of complex numbers. That is why you can't plot it this way. Depending on what you're looking for you can start with looking at the absolute value

plt.imshow(abs(fft2))

这篇关于绘制图像的2D FFT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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