Why does Fourier give me a different picture than ImagePeriodogram?

I want to take a 2D fourier transform of some data, but when I try this I get unexpected results. When I use ImagePeriodogram I get something that looks like I would expect. First I create some data. In this case a circle with radius 10.

n = 200;
data = Table[
UnitStep[10^2 - (x - n/2)^2 - (y - n/2)^2], {x, 1, n}, {y, 1, n}];
img = Image@data


This gives me the following picture:

When I apply ImagePeriodogram I get something that looks like other examples I found online (like this one)

ImagePeriodogram@img


Now I try to do this using Fourier; notice the corners.

spectrum = Abs[Fourier@data]^2;
Image@spectrum


The specs of ImagePeriodogram state that it is just the absolute magnitude squared of the fourier transform, so this would lead me to the conclusion that my understanding of Fourier[] in Mathematica is wrong. I want to use Fourier in my code so I want to understand why these images differ. ImagePeriodogram is also scaled logarithmically but the pictures are still different nonetheless.

There are two differences between ImagePeriodogram and Fourier. One you have already identified (ImagePeriodogram takes the Log of the Fourier spectrum). Second, the periodogram is shifted so that zero frequency is in the center (with Fourier, zero frequency is in the upper-left corner). Here's a way to shift and compress the output of Fourier to make it look the same:

n = 200;
data = Table[UnitStep[10^2 - (x - n/2)^2 - (y - n/2)^2], {x, 1, n}, {y, 1, n}];
spectrum = Log10[Abs[Fourier@data]^2];
{d1, d2} = Ceiling[Dimensions[data]/2];
xCentered = RotateLeft[spectrum, {d1, d2}];


I guess there's a third difference as well, the periodogram output is scaled to lie between zero and one. This is accomplished above using ImageAdjust.

• Thanks! So the rest of the spectrum was apparently hidden because the magnitude was so low. I was already questioning my knowledge on fourier transforms. – user3502079 Feb 20 at 22:56
• It was hidden because the range of values is large -- log compresses the range. – bill s Feb 20 at 23:14