Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
2-d FFT and Hanning window

Subject: 2-d FFT and Hanning window

From: Suresh Narayanan

Date: 23 May, 2002 15:48:49

Message: 1 of 3

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

Subject: 2-d FFT and Hanning window

From: allnor@tele.ntnu.no (Rune Allnor)

Date: 24 May, 2002 01:52:32

Message: 2 of 3

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" <sureshn@aps.anl.gov> wrote in message news:<eeae196.-1@WebX.raydaftYaTP>...
> 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

Subject: 2-d FFT and Hanning window

From: Jordan Rosenthal

Date: 24 May, 2002 08:28:49

Message: 3 of 3

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


Rune Allnor wrote:

> 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" <sureshn@aps.anl.gov> wrote in message news:<eeae196.-1@WebX.raydaftYaTP>...
> > 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

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us