How to get dominent frequency from intensity along a curve in an image?

2 views (last 30 days)
I want to find the dominant frequency. I used fft in this way
yf3 = fftshift(fft2(intensity_profile));
and I got, again for example, this:
First, is it correct? I do not know hot to get the dominant frequency? For now I have plotted the intensity distribution along the circle points. How can I plot it against the frequency?
What I want finally is the main frequency and then wavelength of the profile.
Thanks so much.
Steven

Accepted Answer

Walter Roberson
Walter Roberson on 27 Jan 2014
It appears to be plausible. Your dominant frequency is 0, the DC component.
To get a better idea, you might want to subtract off the mean from the data before fft'ing it.
Note: I would have expected fft() instead of fft2(). Perhaps I am misreading the profile.
  4 Comments
Steven
Steven on 28 Jan 2014
Thanks! I am using cartesian coordinates for pixels, But what do you mean by converting cartesian coordinates?
Sorry for such a trivial question, but how do I get the frequency from x or y values? I do not have time scales here, right? I have just x and y values of the pixels and their corresponding gray scale.
Thanks!
Steven
Walter Roberson
Walter Roberson on 29 Jan 2014
cart2pol() converts (x,y) to (theta, r). If you get the ordering wrong, you can sort() the two based upon theta. Then if you diff() the theta you will see that they have not been uniformly sampled. You should be using a Non-Uniform FFT to handle that situation.
But... instead you can cheat some.
Suppose you have the N x 3 array xyv where the first column is x, the second y, the third the associated value. Then
[theta, r] = cart2pol(xyv(:,1), xyv(:,2));
min_theta = min(theta);
max_theta = max(theta);
even_theta = linspace(min(theta), max(theta), length(theta));
[sort_theta, sortidx] = sort(theta);
ordered_v = xyv(sortidx, 3);
even_v = interp1(sort_theta, ordered_v, even_theta);
centered_even_v = evan_v = mean(evan_v);
Now you can
v_fft = fft(centered_even_v);
In this, the (linear) interpolation of (hopefully nearby) points should fudge for the theta not originally being evenly distributed. The subtraction of the mean is to avoid the big spike in the first bin of the fft.
The first output bin would be the DC component, the mean times the number of points -- which should be 0 if you used centered_even_v as the mean was already subtracted off.
The second output bin would be one cycle per period (2*Pi radians), the third output bin would be two cycles per period, the fourth would be three cycles per period, and so on to the centre, the N'th bin being (N-1) cycles per period.

Sign in to comment.

More Answers (0)

Categories

Find more on Fourier Analysis and Filtering in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!