Reputation: 286
The title may seem a little bit unclear, but I'm going to tell you the whole story and hope to have your comments on it. I'm trying to detect some certain edges, especially those that occurs much more than the others, in a given image. To do this, the best idea is Fourier transform to map the discrete pixel domain into the frequency domain. Before applying the Fourier transform, I have to measure the mean of the distances of some desirable edges, and then use the Fourier transform to find the frequency of them. The problem is that how can I set the mean distance to the FFT algorithm (on Python or Matlab).
Thank you
Upvotes: 2
Views: 1943
Reputation: 919
An FFT will the return the frequency of every repeating element between 1
and number_of_samples/2
.
So, you'll be looking for the frequency peak near image_width/100
.
If your FFT output array is indexed from zero, FFT_array[0]
will be the steady state offset, and FFT_array[image_width/100]
will be the peak you're looking for.
In pseudo code your function will look something like:
image_full = # 2d array of pixel values ex: [[1,2,3],[4,5,6],[7,8,9]]
width_slice_center = image_full[int(len(image_full)/2)]
FFT_slice = FFT(width_slice_center)
#this is where you'll find the values that you are looking for
range = 5 #how far away from exactly 100px you want to look for edges
frequency_100 = int(len(image_full[0])/100) #how many times something 100px wide would appear in image
total_edges_signal = sum(FFT_slice[frequency_100-5:frequency_100+5]) #signal strength of edges in at given width
#then tune the total_edges_signal using an image with known edges
total_edges = int(total_edges_signal*tuning_parameter)
I tried to make the pseudo code as generic as possible, and you should be able to modify the idea to match many data types. I hope this helps.
Upvotes: 1