two_point_correlation#

Calculates the two-point correlation function using Fourier transforms.

import inspect

import matplotlib.pyplot as plt
import numpy as np

import porespy as ps

inspect.signature(ps.metrics.two_point_correlation)
<Signature (im, voxel_size=1, bins=100)>

im#

The input binary image of the porous material with void space voxels labeled with 1(True) and solid phase labeled with 0(False).

np.random.seed(10)
im = ps.generators.blobs(shape=[100, 100, 100])
fig, ax = plt.subplots(1, 1, figsize=[6, 6])
ax.imshow(im[:, :, 6], origin='lower', interpolation='none')
ax.axis(False);
../../../_images/f0d73f0bb43bdcb362306fcef16ac901a123c9a5a581ea62527e3173eee3dda8.png

The two_point_correlation returns a custom object containing the distance and probability data. We can then plot the two point correlation function:

data = ps.metrics.two_point_correlation(im)
fig, ax = plt.subplots(1, 1, figsize=[6, 6])
ax.plot(data.distance, data.probability, 'r.')
ax.set_xlabel("distance")
ax.set_ylabel("two point correlation function");
../../../_images/13af94fb50f94c6770c8684577505fed5d733f44ccb3c8030dafb4edf200c880.png