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 (ndarray) – 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.


results – A custom object with the follow data as attributes:

  • ’im’

    The original image of the porous material

  • ’dt’

    The combined distance transform in alll phases of the image

  • ’phase_max_label’

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

  • ’regions’

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

Return type:

Results object


[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)

See also



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.