       Re: 2-D Fourier Transform?

• To: mathgroup at smc.vnet.net
• Subject: [mg113784] Re: 2-D Fourier Transform?
• From: "Nasser M. Abbasi" <nma at 12000.org>
• Date: Fri, 12 Nov 2010 05:28:23 -0500 (EST)
• References: <ibgivj\$ea9\$1@smc.vnet.net>
• Reply-to: nma at 12000.org

```On 11/11/2010 3:10 AM, Matthias Odisio wrote:

>
> CenteredFourier[img_] := Module[{data = ImageData[img], dim},
>     dim = Dimensions[data];
>     Fourier[data*(-1)^Table[i + j, {i, First[dim]}, {j, Last[dim]}]]
>     ];
>

Hello Matthias;

I liked your way to center the image more than the way
I did it. Even though it is the same effect, your's is
little bit more clear, and clear code is important for
me.

So, if you do not mind, I borrowed your line above to
center the image, and use it instead of mine.

I also now use Image to display the spectrum, not ArrayPlot.

Here is the updated complete script to the 2D spectrum of an image
(Mathematica 7)

----------Spectrum of 2D image ---------

img=Import["ExampleData/lena.tif"];

data=ImageData[img];  (*get data*)
{nRow,nCol,nChannel}=Dimensions[data]

d=data[[All,All,2]]; (*get channel 2 to FFT but center it first*)
d=d*(-1)^Table[i+j,{i,nRow},{j,nCol}];

(*make FFT, and look at spectrum and phase*)

fw= Fourier[d,FourierParameters->{1,1}];
fudgeFactor=100; (*adjust for better viewing as needed*)
abs=fudgeFactor * Log[1+Abs@fw];
Labeled[Image[abs/Max[abs],ImageSize->500],Style["Magnitude spectrum", 18]]

arg=Arg@fw;
Labeled[Image[arg/Max[arg],ImageSize->500],Style["Phase spectrum", 18]]

-----------------------------------

--Nasser

```

• Prev by Date: Re: Balance point of a solid
• Next by Date: Re: command to save as .m file
• Previous by thread: Re: 2-D Fourier Transform?
• Next by thread: Address to the Mathematica-users Wiki Homepage