size_to_seq#

Converts values of invasion size into sequence numbers.

[1]:
import numpy as np
import porespy as ps
import matplotlib.pyplot as plt
from edt import edt
ps.visualization.set_mpl_style()

The arguments and default values for this function are:

[2]:
import inspect
inspect.signature(ps.filters.size_to_seq)
[2]:
<Signature (size, im=None, bins=None)>

Generate an image containing invasion sizes using the porosimetry function:

[3]:
np.random.seed(0)
im = ps.generators.blobs([200, 200], porosity=0.5)
inv = ps.filters.porosimetry(im)

size#

The sizes are produced by porosimetry for instance:

[4]:
seq = ps.filters.size_to_seq(size=inv)
fig, ax = plt.subplots(1, 2, figsize=[12, 6])
ax[0].imshow(inv, origin='lower', interpolation='none')
ax[0].set_title('Invasion map by size')
ax[0].axis(False)
ax[1].imshow(seq, origin='lower', interpolation='none')
ax[1].set_title('Invasion map by sequence')
ax[1].axis(False);
../../../_images/examples_filters_reference_size_to_seq_7_0.svg

im#

The boolean image can be optionally passed into so that uninvaded regions can be differentiated from solid (if both are labelled 0).

[5]:
seq = ps.filters.size_to_seq(size=inv, im=im)
fig, ax = plt.subplots(1, 2, figsize=[12, 6])
ax[0].imshow(inv, origin='lower', interpolation='none')
ax[0].set_title('Invasion map by size')
ax[0].axis(False)
ax[1].imshow(seq, origin='lower', interpolation='none')
ax[1].set_title('Invasion map by sequence')
ax[1].axis(False);
../../../_images/examples_filters_reference_size_to_seq_9_0.svg

In the right image above, there can be seen several regions that are isolated by the void space. They are colored yellow indicating they are filled last. This is caused by the fact that these regions were uninvaded so were set to 0, which makes them the last regions invaded. This may or may not be desired.

bins#

The number of sequence values to when converting sizes. The default is 25.

[6]:
fig, ax = plt.subplots(1, 2, figsize=[12, 6])

bins = 5
seq = ps.filters.size_to_seq(size=inv, bins=bins)
ax[0].imshow(seq, origin='lower', interpolation='none')
ax[0].set_title(f'bins = {bins}')
ax[0].axis(False)

bins = 25
seq = ps.filters.size_to_seq(size=inv, bins=bins)
ax[1].imshow(seq, origin='lower', interpolation='none')
ax[1].set_title(f'bins = {bins}')
ax[1].axis(False);
../../../_images/examples_filters_reference_size_to_seq_12_0.svg