borders#

Generate borders around an image

import inspect

import matplotlib.pyplot as plt

import porespy as ps

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/ebef915eb7fac21c68f01542d412b684f0faf86f27aba074dc4c40a7315b5eef.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/c0d0736a89329a0ce24a70b9b44cd04f15753caae0fa10fafadae181562d2bf1.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/5bf5b5093678e2afc55122765df49114742f80712e1ed1aa83f3de2610ed9834.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/949cdfc60efaa6ec43f0ae3f2e343b5c8dc6d88eec22bfa462022a09812d7c91.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/4a48cb27de3747c9261969978a85c070c7f75782b6b28228af952f584569cea8.png