make_contiguous
#
Import packages#
import numpy as np
import porespy as ps
import scipy.ndimage as spim
import matplotlib.pyplot as plt
import skimage
ps.visualization.set_mpl_style()
Generate image for testing#
im = np.random.randint(-10,10, [10,10], int)
print(im)
[[ 2 7 4 7 -4 -10 -4 7 2 -10]
[ 4 3 3 5 7 -1 5 2 -6 -1]
[ 6 -10 -10 1 4 -8 -8 -1 0 -8]
[ 2 9 8 3 8 -10 -5 -1 8 7]
[ 0 -4 3 -3 6 0 2 1 -8 3]
[ -8 0 4 5 -5 8 9 -9 -6 -5]
[ 0 8 0 3 0 -8 -5 -10 -1 8]
[ -8 8 0 -1 -4 4 1 -7 6 -7]
[-10 0 4 5 -8 -9 -10 -4 9 2]
[ -2 2 3 7 5 -1 -6 6 9 4]]
fig, ax = plt.subplots(1, 1, figsize=[4, 4])
ax.imshow(im)
ax.axis(False)
ax.set_title(f"Minimum = {im.min()}");

Demonstrate function#
im1 = ps.tools.make_contiguous(im=im, mode='keep_zeros')
fig, ax = plt.subplots(1, 1, figsize=[4, 4]);
ax.imshow(im1)
ax.axis(False)
ax.set_title(f"Minimum = {im1.min()}");
