首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >FFTPACK Scipy全局名称未正确定义。如何修复?

FFTPACK Scipy全局名称未正确定义。如何修复?
EN

Stack Overflow用户
提问于 2013-08-22 00:34:54
回答 1查看 1.8K关注 0票数 0
代码语言:javascript
复制
import scipy
from scipy import*
from scipy.fftpack import*
from scipy.fftpack import fft, ifft, fft2


def fouriertransform(self):     #function for Fourier transform computation
    for filename in glob.iglob ('*.tif'):
      imgfourier = scipy.misc.imread(filename) #read the image
      arrayfourier = numpy.array([imgfourier])#make an array 
    # Take the fourier transform of the image.
      fone = fftpack.fft(arrayfourier)
    # Now shift so that low spatial frequencies are in the center.
      ftwo = fftpack.fftshift(fone)
    # the 2D power spectrum is:
      psd2D = np.abs(ftwo)**2
      L = psd2D
      np.set_printoptions(threshold=3)
    #np.set_printoptions(precision = 3, threshold = None, edgeitems = None, linewidth = 3, suppress = True, nanstr = None, infstr = None, formatter = None)
    for subarray in L:
        for array in subarray:
            for array in subarray:
                for elem in array:
                    print '%3.10f\n' % elem  

我收到全局名称fftpack未定义。怎么啦?

EN

回答 1

Stack Overflow用户

发布于 2013-08-22 01:27:55

您的导入变体都没有将名称fftpack放入模块的名称空间中。这样做:

代码语言:javascript
复制
from scipy import fftpack
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18363023

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档