borders

Generate borders around an image

import matplotlib.pyplot as plt
import numpy as np
import porespy as ps
import inspect
inspect.signature(ps.generators.borders)
<Signature (shape, thickness=1, mode='edges')>

shape

Will typically be the shape of another image, which can be 2D or 3D:

im = ps.generators.blobs([20, 20], porosity=0.6)
bd = ps.generators.borders(shape=im.shape)

fig, ax = plt.subplots(1, 1, figsize=[6, 6])
ax.imshow(bd, interpolation='none')
ax.axis(False);
../../../_images/daec04695e6f4f91a345688628da1ba300e7b4addd28db13d6fb89df93829934.png

thickness

Controls the thickness of the border:

im = ps.generators.blobs([20, 20], porosity=0.6)
bd = ps.generators.borders(shape=im.shape, thickness=3)

fig, ax = plt.subplots(1, 1, figsize=[6, 6])
ax.imshow(bd, interpolation='none')
ax.axis(False);
../../../_images/877cbfcab13738aeb1679c167f92d7564b4a1594373a1391ff2f2ae4d68e6090.png

mode

The type of borders to generate, with options being corners, edges and faces. In 2D edges and corners are the same.

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

bd = ps.generators.borders(shape=im.shape, thickness=3, mode='faces')
ax[0].imshow(bd, interpolation='none')
ax[0].axis(False)

bd = ps.generators.borders(shape=im.shape, thickness=3, mode='edges')
ax[1].imshow(bd, interpolation='none')
ax[1].axis(False)

bd = ps.generators.borders(shape=im.shape, thickness=3, mode='corners')
ax[2].imshow(bd, interpolation='none')
ax[2].axis(False);
../../../_images/3d4da6df88f8b1735ff72e9a567dde18835aa8ced79d539b030cbb391ebdc992.png
im = ps.generators.blobs(shape=[10, 10, 10], porosity=0.6)
bd = ps.generators.borders(shape=im.shape, thickness=3, mode='edges')
ax = plt.figure().add_subplot(projection='3d')
ax.voxels(bd, edgecolor='k', linewidth=0.25);
../../../_images/25f6b6222c45e299508ae1763c96101ba18683b2640b3c0bd422684a363bb879.png
im = ps.generators.blobs(shape=[15, 15, 15], porosity=0.6)
bd = ps.generators.borders(shape=im.shape, thickness=3, mode='corners')
ax = plt.figure().add_subplot(projection='3d')
ax.voxels(bd, edgecolor='k', linewidth=0.25);
../../../_images/833e07cc17427a1f308c8798e66fe733124b9ac4256cfe47615cf9d6bc062b85.png