0

我正在将 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)

或者也许这是最好的方法?当然,如果我想将 fft 光谱的对数转换为 SimpleCV 图像以供以后使用,那是另一个问题......

4

1 回答 1

0

您可以使numpy矩阵重新SimpleCV使用Image()构造函数:

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
于 2014-07-25T14:24:09.633 回答