me again:
sorry, I forgot to say that you have to ADD the values r(phi). So the relevant line below should read: - The (rounded) value phi is the index n in your array rofphi, the value r^2 is the value of your array at index n. Add it to the value that is already there (0 in the beginning) But you would have probably done it anyway. Angelika Hello, Ohkyung Kwon, looking at the image you had attached, the direction you want can easily be seen : it is that streak from the upper left to the lower right. Unfortunately, it is overpowered by a strong horizontal and vertical frequency signal. my suggestion: a) Eliminate the horizontal and vertical lines through the center from the powerspectrum (they are usually artefacts from preprocessing (averaging, compresson (jpg))) b) Make a polar grid (r, phi) with center in the middle (frequency 0,0). c) Add the grayvalues radially as function of phi (r(phi)). Once the horizontal and vertical lines through the center are eliminated, the function r(phi) should have a clear maximum at a phi0, which is the direction you are looking for. ------------------------- Practically, you do not really have to eliminate the pixels and draw a polar grid. Define a one-dimensional array rofphi[n] of the size of the phi-resolution you want. Via r^2=(x-x0)^2+(y-y0)^2 and phi=atan((y-y0)/(x-x0)) (x0 and y0 being the coordinate of the center, i.e. x0=y0=63 or 64 in your sample image) you can calculate the r and phi values. So: - Go through the image in a double loop, increasing x and y. - For each pixel, calculate the phi (watch for division by 0 in the atan) and the r^2 (no need do do a sqare root to calculate r: if r(phi) has a max., r^2(phi) has one too!)) - The (rounded) value phi is the index n in your array rofphi, the value r^2 is the value of your array at index n. - identify the horizontal and vertical lines in your array rofphi and erase the values (and maybe +-1 or 2 values around it) - find the maxima (there should be two, differing by 180 degrees) in the remaining array rofphi and you have your direction. _____________________ I hope I explained it that it can be understood. It is actually not as difficult as my explanation looks Good luck! Angelika Gesendet: Sonntag, 17. März 2013 um 05:31 Uhr Von: Oky <[hidden email]> An: [hidden email], [hidden email] Betreff: Angle measurement by FFT Dear ImageJ users, I have been trying to measure orientation of fine lines in an image utilizing FFT. My idea can be summarized by following steps. 1. select a ROI for angle measurement (MFAmeasurement.jpg) 2. Run FFT (MFA-ROI.tif) 3. Find peak positions from the FFT result 4. Get angle and spacing information from the peak position in the FFT result I have confirmed that it is possible to apply my idea to get angle measurement. It was very encouraging. So I have made a very simple macro to do angle measurement automatically, but I am stuck at step 4 because I don't know how to extract angle and spacing information from the FFT result. I could get intensity information not angle or spacing. In the manual for FFT function in ImageJ I can read the information from the status bar of ImageJ. However, I still could not find how to retrieve the angle and spacing information in a macro. Is there someone already has done this kind of measurement? Any advice would be helpful for me to solve this issue. Thank you very much for your kind advice in advance. [image: Inline image 1] Best regards, Ohkyung Kwon -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |