# Measuring distance of periodic structure in biological sample with FFT in MATLAB

I have pictures, taken with a microscope, of biological samples that exhibit a periodic pattern. Previously, I have used ImageJ to manually rotate the image perpendicular to the pattern and plot its grey value profile. Doing FFT in MATLAB I can determine the distance between two peaks of that pattern via its spatial frequency. But this all depends on how (well) I rotate the sample. So my goal is to actually use fft2 in MATLAB to directly transform the image regardless of sample angle. Somewhere I have read about calculating the rotational average (after fftshift) of the resulting spectrum, but I don't know how.

• Is this the right approach anyway?
• Or is there an easier way to calculate the (average) distance between two units of a periodic pattern in an image without having to adjust the angle beforehand?
• Would it be possible to post a representative sample of the image? – A_A Dec 23 '16 at 8:00

## 1 Answer

i am not an image processing guy. but i know what the 2-dimensional Discrete Fourier Transform is.

normally, in two dimensions, the way we measure period is with an operation related to the autocorrelation and you can get to the autocorrelation $R_x[k,\ell]$ with the DFT and magnitude-squaring the result $|X[m,n]|^2$ and inverse DFT to get the autocorrelation. mathematically, you should have half of the 2-dim buffer (like quadrants II and IV) set to zero, to prevent overlap in the correlation, then you have a triangular envelope on the peak values, even if it were a perfectly periodic function.

so, in the $k$ dimension of the result there will be an apparent period, call it $p_k$ and similar for the $\ell$ dimension. the period will be $p = \sqrt{p_k^2 + p_\ell^2}$ . actually, when viewing $R_x[k,\ell]$ as a surface, there should be a circular ridge of radius $p$.