#checker board pattern used to centre the Fourier spectrum: checkerboard <- (-1)^(row(mat_clown) + col(mat_clown)) #modify matrix with checkerboard pattern: mat_checker <- mat_clown*checkerboard #Discrete fast Fourier transform: mat_fft <- fft(mat_checker) #magnitude in frequency domain #Modulus = length of the vector of the complex number: magni <- Mod(mat_fft) #phase in the frequency domain #Argument = angle of the vector of the complex number: phase <- Arg(mat_fft) #Show magnitude in frequency domain (= spectrum): par(mar = c(0,0,0,0), oma = c(0,0,0,0)) image(1:nrow(magni), 1:ncol(magni), log(magni + 1), col = grey((0:255)/255))