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