For my work, I need to perform discrete Fourier transforms (DFTs) on large images. In the current example, I need a 3D FT for a 1921 x 512 x 512 image (along with a 2D FFT of 512 x 512 images). Right now I am using the numpy package and its related function np.fft.fftn () . The example code snippet below shows 2D and 3D FFT times on a grid with a uniform / slightly smaller 2D / 3D size with an arbitrary number as follows:
import sys
import numpy as np
import time
tas = time.time()
a = np.random.rand(512, 512)
tab = time.time()
b = np.random.rand(100, 512, 512)
tbfa = time.time()
fa = np.fft.fft2(a)
tfafb = time.time()
fb = np.fft.fftn(b)
tfbe = time.time()
print "initializing 512 x 512 grid:", tab - tas
print "initializing 100 x 512 x 512 grid:", tbfa - tab
print "2D FFT on 512 x 512 grid:", tfafb - tbfa
print "3D FFT on 100 x 512 x 512 grid:", tfbe - tfafb
Conclusion:
initializing 512 x 512 grid: 0.00305700302124
initializing 100 x 512 x 512 grid: 0.301637887955
2D FFT on 512 x 512 grid: 0.0122730731964
3D FFT on 100 x 512 x 512 grid: 3.88418793678
, , , , . ( , 2 , (- > )), , 3D- ~ 5 ( ). , , , /grid- . 2D .
1921x512x512, np.fft.fftn() ~ 5 . , scipy , , MATLAB FFT ~ 5 , , MATLAB . , , -, MATLAB FFTW, python. , pyFFTW ? , 1921 , 2 (17, 113), , . 512 - . MATLAB 2048?
, ( , !), python, , .