trim_nearby_peaks(peaks, dt, f=1.0)[source]

Finds pairs of peaks that are nearer to each other than to the solid phase, and removes the peak that is closer to the solid.

  • peaks (ndarray) – A boolean image containing True values to mark peaks in the distance transform (dt)

  • dt (ndarray) – The distance transform of the pore space for which the true peaks are sought.

  • f (scalar) – Controls how close peaks must be before they are considered near to each other. Sets of peaks are tagged as near if d_neighbor < f * d_solid.


image – An array the same size as peaks containing a subset of the peaks in the original image.

Return type:



Each pair of peaks is considered simultaneously, so for a triplet of peaks each pair is considered. This ensures that only the single peak that is furthest from the solid is kept. No iteration is required.


[1] Gostick, J. “A versatile and efficient network extraction algorithm using marker-based watershed segmenation”. Physical Review E. (2017)