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未定义。有什么问题?
答案 0 :(得分:1)
您的所有导入变体都没有将名称fftpack
放入模块的命名空间中。这样做:
from scipy import fftpack