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