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)
[[ -7 -8 -3 8 -4 2 6 -3 0 2]
[ 7 -10 1 -8 -5 7 2 3 1 -2]
[ 1 5 6 -1 9 0 9 -10 -3 0]
[ -4 1 5 -10 -4 5 -6 -8 7 0]
[ -7 -4 5 9 3 -4 -8 -1 4 2]
[ 0 -4 -5 -3 -6 3 7 -6 -7 3]
[ 0 -8 -1 -6 -9 -9 3 5 -1 6]
[ 8 2 -1 7 -10 -5 8 -8 0 5]
[ 5 -4 0 -8 -4 -7 -8 8 2 9]
[ -1 4 6 -7 1 2 0 -8 -8 -5]]
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()}");
