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: int = 1, mode: Literal['edges', 'faces', 'corners'] = '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/4dccc089016c0b7c27f6eea6423f7260289d3fb9b67a3795ff714c599073f85f.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/843f8852009d5d3920d337621c9af644c5e598d982b4434f99b9405e247909af.png

mode

The type of borders to generate, with options being corners, edges and faces. In 2D edges and faces 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/edd10582577bcf9bdbbacae85a6217e816c1c32a6272e6faaff0b121c65e8a1d.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/e7a714fc891a0712dedc0ab04c1024fa2bf471456c8158d30c2bcaf51d95fe1d.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/9e33d067e635fb200ae80368c458b59dc3aca82b20a8ce654edd18b929aca833.png