I am using R Studio in sake of doing my tasks in Image Processing. I am currently using the 'EBImage, fftw, ...' libraries. I have a question about fourier analysis and power spectrum.
1) I have 2D matrix, which is an image. This image consist on horizontal lines, black and white. I want to make Fourier Transformation and show its magnitude by ploting. Since the black lines in image are horizontal, the power spectrum will have an vertical line. I couldn't find a way to achieve it.
Now I am using this image for test: Square
When it is true, this image has some periodic frequencies on both horizontal and vertical axis. Then. the FFT Spectrum should look like a "+". But what I found is something way different.
Here is my code:
setwd(".../Project/R/Workspace/Task1")
library("EBImage" , lib.loc="~/R/win-library/3.2")
library("fftwtools", lib.loc="~/R/win-library/3.2")
library("fftw", lib.loc="~/R/win-library/3.2")
# Image Acquisition
img <- readImage(".../Project/Beispielbilder/drmcircle.jpg")
display(img, title='Image')
# Grayscaled
img_gray<-channel(img,"gray")
# FFT
img_ff <- fft(img_gray) #fftw2d
magntd <- sqrt(Re(img_ff)^2+Im(img_ff)^2)
phase <- atan(Im(img_ff)/Re(img_ff))
plot(log(magntd),main="FFT")
As a result, this is what I have: FFT Spectrum
Here are my questoions:
1) How can I get a correct spectrum image? 2) How can I see it as an image, not a plot? (See Example Link on top.)
Thank you for your help in advance.