voronoi_edges

import matplotlib.pyplot as plt
import numpy as np
import porespy as ps
[03:04:25] ERROR    PARDISO solver not installed, run `pip install pypardiso`. Otherwise,          _workspace.py:56
                    simulations will be slow. Apple M chips not supported.                                         
import inspect
b = inspect.signature(ps.generators.voronoi_edges)
print(b)
(shape: List[int], ncells: int, r: int = 0, flat_faces: bool = True, seed: int = None, **kwargs)

shape

The image can be 2D and 3D

shape = [100, 100]
ncells = 20
im = ps.generators.voronoi_edges(shape=shape, ncells=ncells)
fig, ax = plt.subplots(figsize=[4, 4])
ax.imshow(im, origin='lower', interpolation='none')
ax.axis(False);
../../../_images/99f83a188d9a5b9632379892994573052634f747422bdd95835041c82cda3fb2.png
shape = [50, 50, 50]
ncells = 40
im = ps.generators.voronoi_edges(shape=shape, r=3, ncells=ncells)
fig, ax = plt.subplots(figsize=[4, 4])
ax.imshow(ps.visualization.show_3D(im), interpolation='none')
ax.axis(False);
../../../_images/53937344d5553bb8c4c651679463381be2fda67dc09a7710582acb411a929297.png

flat_faces

By default the image will have voronoi edges laying on the image faces. This is accomplished by reflecting the points along each axis before running the tessellation. This can be disabled by setting flat_faces=False, but note that edges pointing to infinity are not drawn.

shape = [100, 100]
flat_faces = False
im = ps.generators.voronoi_edges(shape=shape, ncells=ncells, flat_faces=flat_faces)
fig, ax = plt.subplots(figsize=[4, 4])
ax.imshow(im, origin='lower', interpolation='none')
ax.axis(False);
../../../_images/6b1f5bdfeb63e6a27947ddf6a7e004572f1bd594e2aee7d57bd22f180d951223.png

r radius

The thickness of the edges. By default they are 1 pixel thick, but can be made fatter by setting r > 0.

fig, ax = plt.subplots(1, 2, figsize=[8, 4])

r = 1
ncells = 10
im1 = ps.generators.voronoi_edges(shape=shape, r=r, ncells=ncells)
ax[0].imshow(im1, origin='lower', interpolation='none')
ax[0].set_title(f'r = {r}')
ax[0].axis(False)

r = 4
im2 = ps.generators.voronoi_edges(shape=shape, r=r, ncells=ncells)
ax[1].imshow(im2, origin='lower', interpolation='none')
ax[1].set_title(f'r = {r}')
ax[1].axis(False);
../../../_images/a494ef2cf8c48bc72b8ed7ef928e9db30c19eebc70b1daf6ba002bbbb5741b2f.png

ncells

The number of Voronoi cells to add

fig, ax = plt.subplots(1, 2, figsize=[8, 4])

ncells = 10
im1 = ps.generators.voronoi_edges(shape=shape, ncells=ncells)
ax[0].imshow(im1, origin='lower', interpolation='none')
ax[0].set_title(f'ncells = {ncells}')
ax[0].axis(False)

ncells = 40
im2 = ps.generators.voronoi_edges(shape=shape, ncells=ncells)
ax[1].imshow(im2, origin='lower', interpolation='none')
ax[1].set_title(f'ncells = {ncells}')
ax[1].axis(False);
../../../_images/463b75a4b7a0db7e49423d391b3764232dd069216cd72b56199cc69186098c08.png