lineal_path_distribution

Determines the probability that a point lies within a certain distance of the opposite phase along a specified direction

Import packages

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

ps.visualization.set_mpl_style()
np.random.seed(10)
ps.settings.loglevel = 50

Genearate image for testing

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

Apply metric function

Output is a tuple with the elements bin_centers, pdf, cdf, relfreq, bin_centers, bin_edges, and bin_widths

default

[3]:
x = ps.metrics.lineal_path_distribution(im)
<__array_function__ internals>:5: RuntimeWarning: Converting input from bool to <class 'numpy.uint8'> for compatibility.

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.pdf, x.L, x.bin_widths)
ax[0].set_title("Probability Density Function")
ax[1].set_title("Cumulative Density Function")
ax[2].set_title('Bar Plot');
../../../_images/examples_metrics_howtos_linear_density_11_0.svg

bins

[5]:
x = ps.metrics.lineal_path_distribution(im, bins=5)
<__array_function__ internals>:5: RuntimeWarning: Converting input from bool to <class 'numpy.uint8'> for compatibility.

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.pdf, x.L, x.bin_widths)
ax[0].set_title("Probability Density Function")
ax[1].set_title("Cumulative Density Function")
ax[2].set_title('Bar Plot');
../../../_images/examples_metrics_howtos_linear_density_15_0.svg

voxel_size

[7]:
x = ps.metrics.lineal_path_distribution(im, voxel_size=5)
<__array_function__ internals>:5: RuntimeWarning: Converting input from bool to <class 'numpy.uint8'> for compatibility.

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.pdf, x.L, x.bin_widths)
ax[0].set_title("Probability Density Function")
ax[1].set_title("Cumulative Density Function")
ax[2].set_title('Bar Plot');
../../../_images/examples_metrics_howtos_linear_density_19_0.svg

log

[9]:
x = ps.metrics.lineal_path_distribution(im, log=True)

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.pdf, x.LogL, x.bin_widths)
ax[0].set_title("Probability Density Function")
ax[1].set_title("Cumulative Density Function")
ax[2].set_title('Bar Plot');
../../../_images/examples_metrics_howtos_linear_density_23_0.svg