Python SimpleCV中的FFT?
我正在探索SimpleCV作为Python中的一个图像库,它看起来相当不错。然而,如何在SimpleCV中对图像执行FFT让我感到困惑。看来我必须先转换成numpy阵列,然后使用numpy设施:Python SimpleCV中的FFT?,python,fft,simplecv,Python,Fft,Simplecv,我正在探索SimpleCV作为Python中的一个图像库,它看起来相当不错。然而,如何在SimpleCV中对图像执行FFT让我感到困惑。看来我必须先转换成numpy阵列,然后使用numpy设施: import SimpleCV as SV im = Image('image.png') img = im.getGrayNumpy() imf = np.fft.fftshift(np.fft.fft2(img)) plt.imshow(log(abs(imf)+1),cmap=cm.gray)
import SimpleCV as SV
im = Image('image.png')
img = im.getGrayNumpy()
imf = np.fft.fftshift(np.fft.fft2(img))
plt.imshow(log(abs(imf)+1),cmap=cm.gray)
或者这是最好的方法?当然,如果我想将fft频谱的对数转换为SimpleCV图像以供以后使用,这是另一个问题…您可以使用图像构造函数将numpy矩阵带回SimpleCV:
import scipy
import numpy as np
import SimpleCV as scv
cam = scv.Camera()
disp = scv.Display()
while disp.isNotDone():
current = cam.getImage().resize(w=768)
matrix = current.getGrayNumpy()
spectrum = np.abs(np.log(np.fft.fftshift(np.fft.fft2(matrix))))
spectrum *= 255 / spectrum.max()
scv.Image(spectrum).show()
if disp.mouseLeft:
break
问题是什么?