hold_peaks#

Replaces each voxel with the last peak seen along the given axis

import numpy as np
import porespy as ps
import matplotlib.pyplot as plt
from edt import edt
ps.visualization.set_mpl_style()
/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/openpnm/algorithms/_invasion_percolation.py:358: NumbaDeprecationWarning: The 'nopython' keyword argument was not supplied to the 'numba.jit' decorator. The implicit default value for this argument is currently False, but it will be changed to True in Numba 0.59.0. See https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit for details.
  def _find_trapped_pores(inv_seq, indices, indptr, outlets):  # pragma: no cover

im#

The input image will most likely be the distant transform

np.random.seed(0)
im = ps.generators.blobs(shape=[500, 500])
dt = edt(im)

pk = ps.filters.hold_peaks(im=dt, axis=0)

fig, ax = plt.subplots(1, 2, figsize=[16, 8])
ax[0].imshow(dt/im)
ax[0].axis(False)
ax[0].set_title('distance transform')

ax[1].imshow(pk/im)
ax[1].axis(False)
ax[1].set_title('peaks');
../../../_images/4f9d138c14b8cbea65f7aace9298292e70aa8af64831558443db29c2980ee212.png

axis#

Controls the axis of the search:

fig, ax = plt.subplots(1, 2, figsize=[12, 6])

axis = 0
pk1 = ps.filters.hold_peaks(im=dt, axis=axis)
ax[0].imshow(pk1/im)
ax[0].axis(False)
ax[0].set_title(f'axis = {axis}')

axis = 1
pk2 = ps.filters.hold_peaks(im=dt, axis=axis)
ax[1].imshow(pk2/im)
ax[1].axis(False)
ax[1].set_title(f'axis = {axis}');
../../../_images/a1a311b0e4be767c18e22e915811812155869622846aa7eead4585141430de52.png

ascending#

A boolean that controls the direction of the scanning:

fig, ax = plt.subplots(1, 2, figsize=[12, 6])

ascending = True
pk1 = ps.filters.hold_peaks(im=dt, ascending=ascending)
ax[0].imshow(pk1/im)
ax[0].axis(False)
ax[0].set_title(f'ascending = {ascending}')

ascending = False
pk2 = ps.filters.hold_peaks(im=dt, ascending=ascending)
ax[1].imshow(pk2/im)
ax[1].axis(False)
ax[1].set_title(f'ascending = {ascending}');
../../../_images/629257760df5b10db79a993abe7f342c96db9207609d3d460641efa4519b23f6.png