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)

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/0b7551c992e246858633c3acb808e260755cda89102ad6c415e43ff2aaa8e66a.svg

Apply region_size filter#

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

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