trim_nearby_peaks

Import packages

[1]:
import numpy as np
import porespy as ps
import scipy.ndimage as spim
import matplotlib.pyplot as plt
import skimage
from edt import edt

np.random.seed(0)
ps.visualization.set_mpl_style()

Generate image for testing

[2]:
im = ps.generators.blobs(shape=[200, 200])

plt.figure(figsize=[4, 4])
plt.axis(False)
plt.imshow(im);
../../../_images/examples_filters_howtos_trim_nearby_peaks_4_0.svg

Apply filter function

[3]:
dt = edt(im)
peaks = ps.filters.find_peaks(dt, r_max=4)

x = ps.filters.trim_nearby_peaks(peaks=peaks, dt=dt)

fix, ax = plt.subplots(1, 2, figsize=[8, 4])
ax[0].axis(False)
ax[0].imshow(peaks/im)
ax[1].axis(False)
ax[1].imshow(x/im);
../../../_images/examples_filters_howtos_trim_nearby_peaks_6_0.svg