Learn R Programming

wvtool (version 1.0)

swap.quad: Swapping Quadrants

Description

A function maybe useful to generates power spectrum from fft output.

Usage

swap.quad(x, disp=FALSE, reverse=FALSE)

Arguments

x
output of Mod(fft(imagefile))
disp
TRUE requests to draw power spectrum
reverse
TRUE should be used when power spectrum of N x M, where one of them is odd number.

Value

See Also

fft, Mod

Examples

Run this code
data(camphora)
data(cryptomeria)
img1 <-camphora
img2 <- rgb2gray(cryptomeria)
par(mfrow=c(2,2))

image(rot90c(img1),col=gray(c(0:255)/255), main="Camphora", asp=1, 
useRaster=TRUE, axes=FALSE)
o.fft <-Mod(fft(img1))
ps <- swap.quad(o.fft)
image(rot90c(log(ps)),col=gray(c(0:255)/255), main="power spectrum", asp=1, 
useRaster=TRUE, axes=FALSE)

image(rot90c(img2),col=gray(c(0:255)/255), main="Cryptomeria", asp=1, 
useRaster=TRUE, axes=FALSE)
image(rot90c(log(swap.quad(Mod(fft(img2))))),col=gray(c(0:255)/255), 
main="power spectrum", asp=1, useRaster=TRUE, axes=FALSE)

Run the code above in your browser using DataLab