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 = (N1) / 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) TwoDimensional 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 2d fft of an image. I dont hae any toolbox.
> > I want to use hamming or some other window function.
> > I can generate a 1d vector coefficients of hamming window by using
> > the form for that. I know how to do it for 1d fft.
> >
> >
> > But for 2d matrix, how would one form the matrix which is the
> > product of original matrix and window function?
> >
> >
> > Suresh
