2
votes

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

1
So given the locations of some desirable edges, you want to extract edges that are within a radius of 100 pixels around this desired edge? You don't need the Fourier Transform at all. Just use an edge detection and extract out a radius of pixels given the desired edge point as the centre. Please confirm if this is what you want. If it is, I'll write an answer (both Python and MATLAB). For Python, please specify what image package you're using.rayryeng
Thank you for the response. Generally, defining a radius alone cannot solve the problem for me. In my method, I first perform an edge detection algorithm on a given image, and then analyze this in the frequency domain. This is part of my thesis and I hope to get acceptable results for object extraction.Federico

1 Answers

1
votes

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.