FFT and IFFT on 3D matrix (Matlab)
Posted
by
SteffenDM
on Stack Overflow
See other posts from Stack Overflow
or by SteffenDM
Published on 2012-06-09T15:58:34Z
Indexed on
2012/06/09
16:40 UTC
Read the original article
Hit count: 237
I have a movie with 70 grayscale frames in MATLAB. I have put them in a 3-D matrix, so the dimensions are X, Y and time.
I want to determine the frequencies in the time dimension, so I have to calculate the FFT for every point in the 3rd dimension. This is not a problem but I have to return the images to the original form with ifft
.
In a normal situation this would be true: X = ifft(fft(X))
, but this is not the case it seems in MATLAB when you work with multidimensional data.
This is the code I use:
for i = 1:length
y(:, :, i) = [img1{i, level}]; %# take each picture from an cell array and put it
end %# and put it in 3D array
y2 = ifft(fft(y, NFFT,3), NFFT, 3); %# NFFT = 128, the 3 is the dimension in which i want
%# to calculate the FFT and IFFT
y
is 480x640x70, so there are 70 images of 640x480 pixels.
If I use only fft
, y2
is 480x640x128 (this is normal because we want 128 points with NFFT
).
If I use fft
and ifft
, y2
is 480x640x128 pixels. This is not normal, the 128 should be 70 again.
I tried to do it in just one dimension by using 2 for
loops and this works fine. The for loops take to much time, though.
© Stack Overflow or respective owner