Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

2-d FFT and Hanning window

1,996 views
Skip to first unread message

Suresh Narayanan

unread,
May 23, 2002, 3:48:49 PM5/23/02
to
Hi,


I need to take 2-d fft of an image. I dont hae any toolbox.
I want to use hamming or some other window function.
I can generate a 1-d vector coefficients of hamming window by using
the form for that. I know how to do it for 1-d fft.


But for 2-d matrix, how would one form the matrix which is the
product of original matrix and window function?


Suresh

Rune Allnor

unread,
May 24, 2002, 4:52:32 AM5/24/02
to
Computing the 2D DFT of an image involves applying 1D FFTs first
to each column in the image, and then to each row. What you could
do, then, is to apply your window function to all rows and columns:

% w - Window function, N x 1
% d - Image N x N

m = zeros(N,N); % Initialize space for mask

% Initialize windows along column direction
for n=1:N
m(:,n)=w;
end

% Apply windows along rows
m=m.*m';

% Compute windowed 2D DFT
D=fft2(d.*m);

HTH
Rune


"Suresh Narayanan" <sur...@aps.anl.gov> wrote in message news:<eeae1...@WebX.raydaftYaTP>...

Jordan Rosenthal

unread,
May 24, 2002, 8:28:49 AM5/24/02
to
Hi,

If you go with Rune's method, it would be faster to use:

%---
m = w(:)*w(:).'; % Create 2D window
D = fft2(d.*m);
%---

This is called an outer product window, because it is created from a 1D window using the outer
product. One can also create a 2D window from a 1D window with what is called the rotational
method. In this method, you rotate the 1D window to create the 2D window (which involves
interpolation):

%---------
% Assume w symmetric so that rotation makes sense
% The image data is NxN.
%------
M = (N-1) / 2;
n = 2 / M * (-M:M);
[x,y] = meshgrid(n);
r = sqrt( x.^2 + y.^2 );
w_2D = zeros(N);
w_2D(:) = interp1(n, w, r(:));
w_2D(isnan(w_2D)) = 0;
%-----------

Almost any image processing book should cover this stuff. Here are two references which cover it
pretty well:

1) Two-Dimensional Signal and Image Processing, Jae S. Lim.
2) Multidimensional Digital Signal Processing, Dan Dudgeon and Russell Mersereau.

Hope that helped,

Jordan

0 new messages