find_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

ps.visualization.set_mpl_style()

Create image and variables

[2]:
im = ps.generators.blobs(shape=[100, 100], blobiness=0.5, porosity=0.7)

plt.figure(figsize=[4, 4])
plt.axis(False)
plt.imshow(im)
[2]:
<matplotlib.image.AxesImage at 0x275a525d250>
../../../_images/examples_filters_howtos_find_peaks_4_1.svg

Apply filter function

This function is used to find peaks in the distance transform.

r_max

You can vary the size of the the area that is searched by adjusting r_max:

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

fig, ax = plt.subplots(1, 2, figsize=[8, 4]);
ax[0].imshow(x/im)
ax[1].imshow(xx/im)
ax[0].axis(False)
ax[1].axis(False)
ax[0].set_title('r_max = 4')
ax[1].set_title('r_max = 10');
../../../_images/examples_filters_howtos_find_peaks_6_0.svg