0
$\begingroup$

How to find pointwise readouts of the amplitude, frequency and phase of the DFT underpinning the FFT image?


Once an image is FFT-ed in ImageJ, placing the cursor over any points on the FFT plot results in an output of values at the bottom of the main menu, as in this example:

enter image description here

According to the documentation it simply outputs the location of the cursor:

If the mouse is over an active frequency domain (FFT) window, its location is displayed in polar coordinates. The angle is expressed in degrees, while the radius is expressed in pixels per cycle (p/c). The radius is expressed in [units] per cycle (e.g. mm/c) if the spatial scale of the image was defined using Analyze/Set Scale.

I don't know if there is any additional information within this line to link to the actual sine (or cosine) wave at this particular point in the Fourier plot:

r = .18 p/c (644), theta = 55.12 deg, value = 121


Some playing with ImageJ has given me some preliminary intuition of what these numbers signify. Picking up extreme positions of the cursor as it hovers over the FFT image or plot (yellow cross on the following images) makes it easier to interpret. First, placing the cursor very close to the bright dot in the center and along the x axis yields the following read-out:

enter image description here

This is the slowest frequency in the image, and corresponds to 1 cycle from side-to-side. The image is 256 x 256, and hence, the frequency is 256 pixels / cycle.

What happens if we move the cursor a tiny bit further away to the left along the x axis:

enter image description here

Right, now the frequency has doubled to 4 cycles from side-to-side, which corresponds to 64 pixels/cycle, which (given enough patience and skepticism) can be proven by magnifying and counting the pixels:

enter image description here

What happens at the Nyquist limit:

enter image description here

The limit is 2 pixels/cycle for 128 cycles.

The direction, naturally can be at any angle around the clock face:

enter image description here

and if we select a darker pixel (as in this case), the value will consequently be low.

It gets interesting at the corners, where the PT tells us that the maximum number of cycles will be $\frac{\sqrt{256^2+256^2}}{2}=181$:

enter image description here


There ought to be an easier method, but awaiting a formal answer this would possibly get the job done:

enter image description here

The read-out of the information captured on the image may go like this:

At the point with the cross hairs on the frequency space:

$\text{Freq.} = 2.245$ pixels/cycle - on a $256^2$ image, $256/2.245 = 114$ cycles in the direction of...

$\text{Orientation} = \theta = 48.2^\circ$

$\text{Amplitude} = \vert X[k]\vert=\sqrt{X_\text{Re}^2+X_\text{Im}^2}=\sqrt{-244.868^2+456.238^2}=384.95$

$\text{Phase} =\arctan\left(\frac{X_\text{Im}}{X_\text{Re}}\right)=\arctan\left(\frac{456.238}{-244.868}\right)=-61.78^\circ$

whether this is correct, and whether there is an easier way to get this info without having to calculate on the side these values, or having to use several separate, and disjointed (FFT and Complex) output windows, justifies keeping the post open.

$\endgroup$
5
  • $\begingroup$ As you found out, the frequency would be $1/r$ (in cycles/pixels), and the amplitude be directly available in value. The DFT phase seems to be a little harder to get to, requiring you to set the "Complex Fourier Transform" option, reading the value off the real (say $x$) and imaginary (say $y$) components in the resulting stack, then computing the phase using $\tan^{-1}(y/x)$. $\endgroup$
    – SleuthEye
    Commented Mar 30, 2017 at 3:28
  • $\begingroup$ @SleuthEye Thank you! It's hard to keep track of the cursor position when going from the FFT plot where we get frequency and amplitude to the Re/Im plots, isn't it? $\endgroup$ Commented Mar 30, 2017 at 3:41
  • 1
    $\begingroup$ Wrt my earlier comment, you would also need to substract 128 (mid value) to $x$ and $y$. And yes, getting the value for the exact same pixel on the Re/Im is quite something. Perhaps something that could be made easier with a macro or custom plugin. $\endgroup$
    – SleuthEye
    Commented Mar 30, 2017 at 12:13
  • $\begingroup$ @SleuthEye BTW Do you think I'd be better off trying to get a formal answer at SO.SE? $\endgroup$ Commented Mar 30, 2017 at 13:22
  • $\begingroup$ Just reading off values in the tool isn't exactly on topic at SO. However if you are going to look into getting those measurements with macros or custom plugins and need specific programming help while doing so, it would be better suited for SO.SE than DSP.SE. $\endgroup$
    – SleuthEye
    Commented Mar 30, 2017 at 16:06

1 Answer 1

1
$\begingroup$

Here is a very practical illustration. The credit goes to @Herbie and @emartini.

enter image description here

NOTE: The complex window has a slide bar at the bottom, which has to be drawn to the left. Also, it is necessary to click twice on the FFT window without moving the cursor to get the three output values.


The output is concordant with Matlab with adjustments nicely described by @SleuthEye here and here.

Here is an example:

enter image description here

with ImageJ:

Frequency = 10.24 pixels/cycle (25 cycles)
Theta (direction) = 16.26 degrees
Real part = -1.255
Imaginary part = 10.142
Phase = arctan(10.142 / -1.255) = -82.95 degrees
Magnitude = sqrt(10.142^2 + 1.255^2) = 10.2194

and with Matlab:

Im = imread('circ.png');
pkg load image
Im = rgb2gray(Im);

A = fft2(double(Im) / 255);
Ashifted = fftshift(A);
Ashifted(121,153)

i = 121;
j = 153;

center = size(A) / 2 + 1;
dx = (j - center(2)) / size(A,2);
dy = (center(1) - i - 1) / size(A,1);

direction = (atan2(dy, dx))
dir_degrees = direction * (360 / (2*pi)) 
frequency = 1 /sqrt(dx*dx + dy*dy)

The output:

ans =  -1.2553 + 10.1425i
direction =  0.28379
dir_degrees =  16.260
frequency =  10.240
$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.