region_size#

Each voxel is replaced with the size of the region to which it belongs

Import packages#

import matplotlib.pyplot as plt
import numpy as np
import porespy as ps
import scipy.ndimage as spim
import skimage
ps.visualization.set_mpl_style()
np.random.seed(0)
[03:26:34] ERROR    PARDISO solver not installed, run `pip install pypardiso`. Otherwise,          _workspace.py:56
                    simulations will be slow. Apple M chips not supported.                                         

im#

Generate a test image. Can be either 2D or 3D.

im = ps.generators.blobs(shape=[200, 200])

plt.figure(figsize=[6, 6])
plt.axis(False)
plt.imshow(im);
../../../_images/d77209f3650bd6830b09462a8ed61fe6eb9f4ae35816e146f9cfcd7266fe0577.png

Apply region_size filter#

x = ps.filters.region_size(im=im)

plt.figure(figsize=[6, 6])
plt.axis(False)
plt.imshow(x);
../../../_images/6963e97282947f357ba5e2077bd9357277c3bbcdd64622827167ecfd4abcf9b2.png