snow_partitioning_n

an example for the use of porespy.filters.snow_partitioning_n

Import packages

[1]:
import numpy as np
import porespy as ps
import scipy.ndimage as spim
import matplotlib.pyplot as plt
import skimage

np.random.rand(0)
ps.visualization.set_mpl_style()

Partitions an all phases of an image into regions with marker-based watershed segmentation.

Generate image

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

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

Apply filter function

This function will partition each phase into regions, where a phase is indicated by values of 1 or greater, and 0’s are ignore. We can create an image of 1’s and 2:

[3]:
reg0 = ps.filters.snow_partitioning_n(im==0, r_max=4, sigma=0.4)
reg1 = ps.filters.snow_partitioning_n(im==1, r_max=4, sigma=0.4)
reg2 = ps.filters.snow_partitioning_n(im = im.astype(int) + 1, r_max=4, sigma=0.4)
[4]:
fig, ax = plt.subplots(1, 3, figsize=[8, 4])
ax[0].imshow(reg0.regions)
ax[0].axis(False)
ax[1].imshow(reg1.regions)
ax[1].axis(False)
ax[2].imshow(reg2.regions)
ax[2].axis(False);
../../../_images/examples_filters_howtos_snow_partitioning_n_8_0.svg