chord_length_distribution

Import packages

[1]:
import matplotlib.pyplot as plt
import porespy as ps

ps.visualization.set_mpl_style()

Genearate image for testing

Porespy’s apply_chords is used to demonstrate the chords’ distributions on the phase of interest (void space) on a synthetic image. In this example chords are found along x_direction axis=0.

[2]:
im = ps.generators.blobs(shape=[500, 500])
im = ps.filters.apply_chords(im)
fig, ax = plt.subplots()
ax.imshow(im, origin="lower");
../../../_images/examples_metrics_howtos_chord_length_distribution_5_0.svg

Implement chord_length_distribution

This method has default input arguments that can be changed depending on the user’s input values and preference.

Using default input arguments

[3]:
x = ps.metrics.chord_length_distribution(im=im)

Plot results:

[4]:
fig, ax = plt.subplots(1, 3, figsize=[10, 4])
ax[0].plot(x.pdf)
ax[1].plot(x.cdf)
ax[2].bar(x.L, x.cdf, x.bin_widths, edgecolor='k')
ax[0].set_title("Probability Density Function")
ax[1].set_title("Cumulative Density Function")
ax[2].set_title('Bar Plot');
../../../_images/examples_metrics_howtos_chord_length_distribution_11_0.svg

bins: defined by user

[5]:
x = ps.metrics.chord_length_distribution(im=im, bins=5)

Plot results:

[6]:
fig, ax = plt.subplots(1, 3, figsize=[10, 4])
ax[0].plot(x.pdf)
ax[1].plot(x.cdf)
ax[2].bar(x.L, x.cdf, x.bin_widths, edgecolor='k')
ax[0].set_title("Probability Density Function")
ax[1].set_title("Cumulative Density Function")
ax[2].set_title('Bar Plot');
../../../_images/examples_metrics_howtos_chord_length_distribution_15_0.svg

log: defined by user

[7]:
x = ps.metrics.chord_length_distribution(im=im, log=True)

Plot results:

[8]:
fig, ax = plt.subplots(1, 3, figsize=[10, 4])
ax[0].plot(x.pdf)
ax[1].plot(x.cdf)
ax[2].bar(x.LogL, x.cdf, x.bin_widths, edgecolor='k')
ax[0].set_title("Probability Density Function")
ax[1].set_title("Cumulative Density Function")
ax[2].set_title('Bar Plot');
../../../_images/examples_metrics_howtos_chord_length_distribution_19_0.svg

voxel_size: defined by user

[9]:
x = ps.metrics.chord_length_distribution(im=im, voxel_size=5)

Plot results:

[10]:
fig, ax = plt.subplots(1, 3, figsize=[10, 4])
ax[0].plot(x.pdf)
ax[1].plot(x.cdf)
ax[2].bar(x.L, x.cdf, x.bin_widths, edgecolor='k')
ax[0].set_title("Probability Density Function")
ax[1].set_title("Cumulative Density Function")
ax[2].set_title('Bar Plot');
../../../_images/examples_metrics_howtos_chord_length_distribution_23_0.svg

normalization: defined by user

options are count or length

[11]:
x = ps.metrics.chord_length_distribution(im=im, normalization='length')

Plot results:

[12]:
fig, ax = plt.subplots(1, 3, figsize=[10, 4])
ax[0].plot(x.pdf)
ax[1].plot(x.cdf)
ax[2].bar(x.L, x.cdf, x.bin_widths, edgecolor='k')
ax[0].set_title("Probability Density Function")
ax[1].set_title("Cumulative Density Function")
ax[2].set_title('Bar Plot');
../../../_images/examples_metrics_howtos_chord_length_distribution_27_0.svg