radial_density_distribution

Import packages

[1]:
import warnings

import matplotlib.pyplot as plt
import numpy as np
import porespy as ps
from edt import edt

warnings.filterwarnings('ignore')
ps.visualization.set_mpl_style()
np.random.seed(10)

Genearate image for testing

[2]:
skel = ps.generators.blobs(shape=[500, 500])
im = ps.filters.prune_branches(skel)
dt = edt(im)
fig, ax = plt.subplots()
ax.imshow(dt, origin="lower")

log = False
bins = 10
voxel_size = 1
../../../_images/examples_metrics_howtos_radial_density_4_0.svg

Apply metric function

Output is a tuple with elements R, pdf, cdf, bin_centers, bin_edges, and bin widths

default

[3]:
x = ps.metrics.radial_density_distribution(dt)

Plot results:

[4]:
fig, ax = plt.subplots(1, 2, figsize=[8, 4])
ax[0].plot(x.pdf)
ax[1].plot(x.cdf)
ax[0].set_title("Probability Density Function")
ax[1].set_title("Cumulative Density Function")

fig, ax = plt.subplots(1, 2, figsize=[8, 4])
ax[0].bar(x.R, x.pdf, x.bin_widths, edgecolor='k')
ax[1].bar(x.R, x.cdf, x.bin_widths, edgecolor='k')
ax[0].set_title('Bar Plot - Probability Density')
ax[1].set_title('Bar Plot - Cumulative Density');
../../../_images/examples_metrics_howtos_radial_density_10_0.svg
../../../_images/examples_metrics_howtos_radial_density_10_1.svg

bins

[5]:
x = ps.metrics.radial_density_distribution(dt,
                                           bins=5,
                                           log=log,
                                           voxel_size=voxel_size)

Plot results:

[6]:
fig, ax = plt.subplots(1, 2, figsize=[8, 4])
ax[0].plot(x.pdf)
ax[1].plot(x.cdf)
ax[0].set_title("Probability Density Function")
ax[1].set_title("Cumulative Density Function")

fig, ax = plt.subplots(1, 2, figsize=[8, 4])
ax[0].bar(x.R, x.pdf, x.bin_widths, edgecolor='k')
ax[1].bar(x.R, x.cdf, x.bin_widths, edgecolor='k')
ax[0].set_title('Bar Plot - Probability Density')
ax[1].set_title('Bar Plot - Cumulative Density');
../../../_images/examples_metrics_howtos_radial_density_14_0.svg
../../../_images/examples_metrics_howtos_radial_density_14_1.svg

log

[7]:
x = ps.metrics.radial_density_distribution(dt,
                                           bins=bins,
                                           log=True,
                                           voxel_size=voxel_size)

Plot results:

[8]:
fig, ax = plt.subplots(1, 2, figsize=[8, 4])
ax[0].plot(x.pdf)
ax[1].plot(x.cdf)
ax[0].set_title("Probability Density Function")
ax[1].set_title("Cumulative Density Function")

fig, ax = plt.subplots(1, 2, figsize=[8, 4])
ax[0].bar(x.LogR, x.pdf, x.bin_widths, edgecolor='k')
ax[1].bar(x.LogR, x.cdf, x.bin_widths, edgecolor='k')
ax[0].set_title('Bar Plot - Probability Density')
ax[1].set_title('Bar Plot - Cumulative Density');
../../../_images/examples_metrics_howtos_radial_density_18_0.svg
../../../_images/examples_metrics_howtos_radial_density_18_1.svg

voxel_size

[9]:
x = ps.metrics.radial_density_distribution(dt,
                                           bins=bins,
                                           log=log,
                                           voxel_size=10)

Plot results:

[10]:
fig, ax = plt.subplots(1, 2, figsize=[8, 4])
ax[0].plot(x.pdf)
ax[1].plot(x.cdf)
ax[0].set_title("Probability Density Function")
ax[1].set_title("Cumulative Density Function")

fig, ax = plt.subplots(1, 2, figsize=[10, 4])
ax[0].bar(x.R, x.pdf, x.bin_widths, edgecolor='k')
ax[1].bar(x.R, x.cdf, x.bin_widths, edgecolor='k')
ax[0].set_title('Bar Plot - Probability Density')
ax[1].set_title('Bar Plot - Cumulative Density');
../../../_images/examples_metrics_howtos_radial_density_22_0.svg
../../../_images/examples_metrics_howtos_radial_density_22_1.svg