voronoi_edges

import matplotlib.pyplot as plt
import numpy as np
import porespy as ps
[01:01:19] 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/0c8d59d812c258ee14d2f02deb97b9d3d5e86d0fefa5e1cede32c40aa3eaafe0.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/4fead6da23a53eb88c8c648a0a2d3694c848170f82db4a3084da636d34848bcc.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/3661ff0edb7367eed00d0d05bb3c140e4d88b8eb49b3f8220b84f0ec7309aaa3.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/4e1877e0db4a9395bc7db025878af091355d406c197a348b23bc0216c98330d9.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/b7a4975e4cce86b4a51649e81f94d6e600fec75e6206ca7c26b362ab9830b254.png