I am getting familiarized with Octave and the function fft2()
. In this toy example, I am aiming at producing the 2D DFT of the following 256 x 256 png image:
To be able to understand the output easily, I try to convert this image into a 256 x 256 image, eliminating color information:
Im = imread('circ.png');
pkg load image
Im = rgb2gray(Im);
figure, imshow(Im)
After this bookkeeping preliminaries I run:
A = fft2(double(Im));
OK. Now I take the same image, and analyze it with ImageJ, checking the output at point (157, 96)
, like this:
So the magnitude is going to be sqrt(7.448^2 + 10.458^2) = 12.83
And the phase, arctan(-10.458 / 7.448) = 54.54 degrees
.
The question is, How can I get these values out of the fft2()
output?
In case it makes a difference, this is how I plotted the Octave output 2D DFT:
subplot(132);
h = imshow(abs(fftshift(A)),[24 100000]);
h2 = get(h,'Parent');
set(h2,'YDir','Normal');
axis equal tight;
title("2D FFT Magnitude");
subplot(133);
h = imshow(angle(fftshift(A)),[-pi pi]);
h2 = get(h,'Parent');
set(h2,'YDir','Normal');
axis equal tight;
title("2D FFT Phase");
and this is the process in ImageJ: