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