2

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

Federico
  • 266
  • 1
  • 2
  • 13
  • 2
    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 Sep 11 '15 at 16:33
  • 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 Sep 11 '15 at 18:29

1 Answers1

1

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.

Alea Kootz
  • 913
  • 4
  • 11
  • Thank you for all the descriptions. I will test your solution and inform you about the results. By the way, I tried to give you the score, but the site said, " you cannot do this, because of lacking 15 reputations "! – Federico Sep 11 '15 at 18:33
  • Hi Austin. Thank you again for your help. Regarding your pseudo code, I have some questions: Could you please explain more about the second line of your pseudo code, width_slice_center? In addition, as we transform the image into a 1-dimensional vector in your solution, how can we display those 100-wide edges we extracted their frequency as a gray scale image? Thank you – Federico Sep 12 '15 at 21:09
  • The `width_slice_center` variable is a list of pixel values from a pixel row across the center of the image. – Alea Kootz Sep 14 '15 at 15:13
  • if you want to display edges of a certain width as a greyscale image, look into applying a separable Gaussian kernel as a low pass filter to the image, then applying a separable Difference of Gaussians (high pass) filter. That combination, if adjusted well, should act as a band pass filter to allow you to see only the image edges you are interested in. It would also simply edge detection for the Fourier Transform to some degree. – Alea Kootz Sep 14 '15 at 15:18