snow_partitioning_n(im, r_max=4, sigma=0.4)[source]

This function partitions an imaging oontain an arbitrary number of phases into regions using a marker-based watershed segmentation. Its an extension of snow_partitioning function with all phases partitioned together.

  • im (ND-array) – Image of porous material where each phase is represented by unique integer starting from 1 (0’s are ignored).

  • r_max (scalar) – The radius of the spherical structuring element to use in the Maximum filter stage that is used to find peaks. The default is 4.

  • sigma (scalar) – The standard deviation of the Gaussian filter used. The default is 0.4. If 0 is given then the filter is not applied.



The actual image of the porous material


The combined distance transform of the image


The list of max label of each phase in order to distinguish between each other


The partitioned regions of n phases using a marker based watershed with the peaks found by the SNOW algorithm

Return type

A named tuple with the following attribute


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

[2] Khan, ZA et al. “Dual network extraction algorithm to investigate multiple transport processes in porous materials: Image-based modeling of pore and grain-scale processes”. Computers in Chemical Engineering. (2019)


In principle it is possible to perform a distance transform on each phase separately, merge these into a single image, then apply the watershed only once. This, however, has been found to create edge artifacts between regions arising from the way watershed handles plateaus in the distance transform. To overcome this, this function applies the watershed to each of the distance transforms separately, then merges the segmented regions back into a single image.