reduce_peaks#

Broad or elongated peaks are replaced with single peaks located at the centre of original voxels

Import packages#

import numpy as np
import porespy as ps
import scipy.ndimage as spim
import matplotlib.pyplot as plt
import skimage
from edt import edt
ps.visualization.set_mpl_style()
np.random.seed(0)
/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

peaks#

Find peaks on the test image

im = ps.generators.blobs(shape=[200, 200])
dt = edt(im)
peaks = ps.filters.find_peaks(dt, r_max=4)

plt.figure(figsize=[6, 6])
plt.axis(False)
plt.imshow(peaks/im);
../../../_images/c40f5c4ac54c70f4ebf59a4895c0e0fdde2bdb5fc7ac273ca5428b40ad3a14f8.png

Apply reduce_peaks filter#

x = ps.filters.reduce_peaks(peaks=peaks)
plt.figure(figsize=[6, 6])
plt.axis(False)
plt.imshow(x/im);
../../../_images/733466d9766070384e261dba93105d4046ef4e84fff62204099b2e6b23e23fc1.png