# Two point correlation function

1. Oct 5, 2011

### mikeph

Hi

I have two images and I want to compare the "structures" of them at different scales. I remember from cosmology that the two point correlation function was used to extract similar structural information from the CMB, generating a graph of structure Vs scale. Then at certain length scales you have peaks which correspond to physical occurrences.

edit-this is the image I'm talking about.

This is exactly what I'd like to apply to my image, but after searching the internet I can't find much that helps me actually numerically calculate this for an image. Does anyone know any good tutorials for actually doing this?

It's my understanding that this method is favourable to taking a Fourier/cosine transform as these methods are biased towards finding structure along the x-y axes? My image is isotropic so I have no reason to care about one direction more than another.

Any help or pointing me in the right direction would be brilliant, thanks
Mike

2. Oct 6, 2011

### Chalnoth

Yeah, if you want to calculate this sort of thing for a flat, rectangular image, you just take the two-dimensional Fourier transform of the image (this doesn't bias things towards horizontal/vertical modes, by the way....it just as well represents diagonal modes). Then, once that's done, the image above is what is known as a "power spectrum": it is an estimate of the magnitude of modes of each size.

So, if your FFT is defined as $a(k_x, k_y)$, then the power spectrum can be estimated by producing a series of bins where $k_x^2 + k_y^2$ are approximately equal, and averaging $aa^*$ in each bin.

A rather easy way to do the binning would be to, for each $k_x, k_y$ pair, compute $\sqrt{k_x^2 + k_y^2}$, and the bin it goes into is the nearest integer.

3. Oct 6, 2011

### Chronos

Measuring the amplitude and separation between peaks is the important part of this exercise. The first two peaks are solid. It gets squishy after that. You can't ignore data sets because they don't match the model.

4. Oct 6, 2011

### mikeph

Thanks Chalnoth - I already wrote a kind of distance binning algorithm, just didn't know how to use it.

Chronos- I'm not sure I understand your reply, I'm not ignoring any data.

5. Oct 6, 2011

### Chalnoth

No problem! If you have any further questions, feel free to ask. This kind of thing is what I do :)

...and I think he misread you.

6. Oct 7, 2011

### Chronos

Apologies, I never meant to suggest anyone was ignoring data.

7. Oct 7, 2011

### Chronos

Apologies, I never meant to suggest anyone was ignoring data.