SNOW partitioning parallel

The filter is used to perform SNOW algorithm in parallel and serial mode to save computational time and memory requirement respectively. SNOW algorithm converts a binary image in to partitioned regions while avoiding oversegmentation. SNOW_partitioning_parallel speeds up this process by decomposing the domain into several subdomains and either process them in different cores in parallel to save time or one by one in single core to save memory requirements.

Import Modules

import numpy as np
import porespy as ps
from import randomize_colors
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
gs = gridspec.GridSpec(2, 4)

Create a random image of overlapping spheres

im = ps.generators.overlapping_spheres([1000, 1000], r=10, porosity=0.5)
fig, ax = plt.subplots()
ax.imshow(im, origin='lower');

Apply SNOW_partitioning_parallel on the binary image

snow_out = ps.filters.snow_partitioning_parallel(
    im=im, divs=2, r_max=5, sigma=0.4)

Plot output results

fig, ax = plt.subplots(1, 3, figsize=[9, 3])
ax[0].set_title('Binary Image');
ax[1].set_title('Euclidean Distance Transform')
ax[2].set_title('Segmented Image');
print(f"Number of regions: {snow_out.regions.max()}")
Number of regions: 1006