trim_nearby_peaks(peaks, dt, f=1)[source]#

Removes peaks that are nearer to another peak than to solid

  • peaks (ndarray) – A image containing nonzeros values indicating peaks in the distance transform (dt). If peaks is boolean, a boolean is returned; if peaks have already been labelled, then the original labels are returned, missing the trimmed peaks.

  • dt (ndarray) – The distance transform of the pore space

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


image – An array the same size and type 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 nearby 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)


Click here to view online example.