Skip to content

Instantly share code, notes, and snippets.

@pepijn-devries
Last active August 29, 2015 14:27

Revisions

  1. peppivankokki revised this gist Aug 11, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions fourier01_02.r
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    #checker board pattern used to center the fourier spectrum:
    #checker board pattern used to centre the Fourier spectrum:
    checkerboard <- (-1)^(row(mat_clown) + col(mat_clown))

    #modify matrix with checker board pattern:
    #modify matrix with checkerboard pattern:
    mat_checker <- mat_clown*checkerboard

    #Discrete fast Fourier transform:
  2. peppivankokki revised this gist Aug 11, 2015. No changes.
  3. peppivankokki revised this gist Aug 10, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions fourier01_02.r
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,8 @@
    #checker board pattern used to center the fourier spectrum:
    checker_board <- (-1)^(row(mat_clown) + col(mat_clown))
    checkerboard <- (-1)^(row(mat_clown) + col(mat_clown))

    #modify matrix with checker board pattern:
    mat_checker <- mat_clown*checker_board
    mat_checker <- mat_clown*checkerboard

    #Discrete fast Fourier transform:
    mat_fft <- fft(mat_checker)
  4. peppivankokki created this gist Aug 10, 2015.
    20 changes: 20 additions & 0 deletions fourier01_02.r
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    #checker board pattern used to center the fourier spectrum:
    checker_board <- (-1)^(row(mat_clown) + col(mat_clown))

    #modify matrix with checker board pattern:
    mat_checker <- mat_clown*checker_board

    #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))