# 2D Spatial - Frequency Domain Results Not matching?

I've got a process I'm performing in the spatial domain as: 1. Create a grid of points, 2. Take a square of some Length and Width and place it on the x-y axis origin 3. Count the number of points contained within the box 4. Move the box down the positive x-axis so that it is just neighboring the previous position (no overlaps/gaps) 5. Repeat 3-4. After doing this for a while I get a nice discrete integer sequence and I can take an FFT of this to determine its frequency components.

Now, as I can see it, this process can be described as a grid of points being convolved with a 2D rect function and then sampled at points x=0, x=L, x=2L, etc... In the frequency domain, this corresponds to a grid of frequency points multipled(weighted) by a 2D sinc function and then sampled( convolved with an impulse train).

So what I have done is written programs in MATLAB to perform this process in the spatial domain AND in the frequency domain and try to compare the results of the spatial domain FFT and what the frequency domain method predicts the spectrum should be.

The thing is, the two show peaks at the same frequency components for various rectangle Length and Widths so that works, but the magnitudes of the two spectrums do NOT match. As an example, the FFT might show a global max at f=0.15 and a slightly smaller peak at f=0.2, while the frequency domain generated spectrum shows a global max at f=0.2 and a slightly smaller peak at f=0.15.

There seems to be no rhyme or reason as to how the magnitudes differ, and I can't find anything wrong with the code, it's especially troubling that the frequency's match but not the magnitudes. I'm using a modulo operator to represent the aliasing/folding in the frequency domain so that only moves the values of the 2D sinc around to different frequencies and doesn't change the magnitudes, so it seems like maybe something is wrong with the 2D sinc but I see nothing unusual..

If anyone sees something wrong with my frequency/spatial domain interpretation or has any ideas what could be wrong, please let me know. Thanks!

-
I think what you mean is that it's a sum of impulses convolved with a rectangle function, which in the frequency domain will be a sum of rectangle functions with varying linear phase multiplied by a sinc function. –  AnonSubmitter85 Jun 23 '13 at 9:04