[R] 2D fft DC shift
Bill Simpson
wsi at gcal.ac.uk
Wed Sep 26 11:48:18 CEST 2001
Here is an example that
--creates an image of a bright square on a dark background
--centres the spectrum using Gonzalez and Wintz method
--creates image plots of uncentred and centred amplitude spectra
#example of 2D amplitude spectrum
# sample image:
w<-5 #width of central square
xn<- 128; yn<- 128
im<- matrix(0,nrow=yn,ncol=xn)
xc<-floor(xn/2)+1; yc<- floor(yn/2)+1 # centers of the image
im[(-m:m)+xc,(-m:m)+yc]<- 1
fftim<-fft(im)
im2<- matrix(0,nrow=yn,ncol=xn)
#centres spectrum: Gonzalez & Wintz (1977) Digital Image Processing p.53
im2<-im * (-1)^(row(im) + col(im))
fftim2<-fft(im2)
par(mfrow=c(2,2),pty='s')
image(im); title('im=Original image')
image(Mod(fftim)); title('Mod(fft(im))')
image(Mod(fftim2)) ; title('Centred Mod(fft(im))')
Bill
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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