region_size#

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

Import packages#

[1]:
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)

im#

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

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

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

Apply region_size filter#

[3]:
x = ps.filters.region_size(im=im)

plt.figure(figsize=[6, 6])
plt.axis(False)
plt.imshow(x);
../../../_images/examples_filters_reference_region_size_6_0.svg