make_contiguous#
Import packages#
import matplotlib.pyplot as plt
import numpy as np
import porespy as ps
ps.visualization.set_mpl_style()
Generate image for testing#
im = np.random.randint(-10, 10, [10, 10], int)
print(im)
[[ 2 -9 9 9 -10 5 1 -4 5 -2]
[ 3 2 4 4 -2 -3 4 -8 9 5]
[ -4 -1 -4 2 1 0 6 6 -2 -8]
[-10 -3 6 2 -10 5 -6 -1 1 4]
[ -4 2 -2 1 4 -10 5 4 -4 8]
[ -6 2 -6 0 9 1 -5 6 -5 7]
[ 2 1 -7 -6 5 1 2 -9 2 0]
[ 7 7 -6 1 4 -6 -5 -1 7 5]
[ -3 1 -5 -7 -4 -10 3 4 -4 5]
[ 0 1 -1 -2 -5 2 -1 -8 3 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()}");