[R] 2D fft DC shift

Bill Simpson wsi at gcal.ac.uk
Tue Sep 25 11:19:55 CEST 2001

On Mon, 24 Sep 2001, M. Edward Borasky wrote:

> The simplest way to get the "hot spot" in the middle is to pre-multiply the
> 2D FFT *input* pointwise by a checkerboard pattern of -1s and +1s. For
> example, if your input is
> a b c d
> e f g h
> i j k l
> m n o p
> you would submit
> -a b -c d
> e -f g -h
> -i j -k l
> m -n o -p
> as input to your 2D FFT. This is from memory; someone with access to an
> image processing textbook please correct me if I'm wrong!!!

I looked in Gonzalez & Wintz (1977) Digital Image Processing and found:
p.53 "the origin of the Fourier transform of f(x,y) can be moved to the
centre of the corresponding N x N frequency square simply by multiplying
f(x,y) by -1^(x+y)"

So from the sound of it you do something like (in proper R syntax)
g(x,y)<- f(x,y)* -1^(x+y) 

If you get this to work I would appreciate some simple R code that 
- generates a 2D image (e.g. a square)
- creates 2D centred amplitude or power spectrum


r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list