Extract low-frequency coefficients of Fourier transformation

I'm new to Matlab and to FFT. I have applied the Fourier transformation on an image like so:
I = imread('img.jpg');
img = fftshift(I);
F = fft2(img);
magnitude = mat2gray(100*log(1+abs(fftshift(F)))); % Magnitude spectrum
phase = mat2gray( (angle(F)) ); % Phase spectrum
Using the energy compaction property of the Discrete Fourier Transform how can I extract a 21x21 matrix of the low-frequency value coefficients of the Fourier transformation?
Thanks in advance!

 Accepted Answer

If you shift the 2-D DFT, then the low frequency components will be in the center of the image: center along the row and column dimensions of the matrix
X = ones(128,128);
Xdft = fftshift(fft2(X));
surf(abs(Xdft));
view(-16,10)
Note that the DC shift is evident in the middle of the image.
The value of Xdft(65,65) is 2^14 as expected. So to extra the low-frequency components, just extract a submatrix around the center of your original matrix.
If you have a simple 2-D complex exponential
x = 0:159;
y = 0:159;
[X,Y] = meshgrid(x,y);
Z = exp(1i*pi/4*(X+Y));
Z = real(Z);
imagesc(Z);
Then note that with a matrix of 160x160, we would expect pi/4 to be shifted from the center (80,80) to (101,101) and (61,61)
Zdft = fftshift(fft2(Z));
imagesc(abs(Zdft))
Zdft(101,101)
Zdft(61,61)
Note they are complex conjugates of each other as expected.

3 Comments

Thanks a million for the answer! It works. I'm very much ashamed for asking, but how can I extract the central submatrix of the resulted matrix?
yeah, I've noticed. But how does that help me with the central matrix? (sorry I do not understand, or is this not related to my latest comment?)
I've managed to figure it out, thanks for all your help!!!

Sign in to comment.

More Answers (0)

Asked:

on 10 Oct 2013

Commented:

on 10 Oct 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!