local_thickness(im, sizes=25, mode='hybrid', divs=1)[source]

For each voxel, this function calculates the radius of the largest sphere that both engulfs the voxel and fits entirely within the foreground.

This is not the same as a simple distance transform, which finds the largest sphere that could be centered on each voxel.

  • im (ND-array) – A binary image with the phase of interest set to True

  • sizes (array_like or scalar) – The sizes to invade. If a list of values of provided they are used directly. If a scalar is provided then that number of points spanning the min and max of the distance transform are used.

  • mode (str) –

    Controls with method is used to compute the result. Options are:


    (default) Performs a distance tranform of the void space, thresholds to find voxels larger than sizes[i], trims the resulting mask if access_limitations is True, then dilates it using the efficient fft-method to obtain the non-wetting fluid configuration.


    Same as ‘hybrid’, except uses a second distance transform, relative to the thresholded mask, to find the invading fluid configuration. The choice of ‘dt’ or ‘hybrid’ depends on speed, which is system and installation specific.


    Using a single morphological image opening step to obtain the invading fluid confirguration directly, then trims if access_limitations is True. This method is not ideal and is included for comparison purposes.

  • divs (int or array_like) – The number of times to divide the image for parallel processing. If 1 then parallel processing does not occur. 2 is equivalent to [2, 2, 2] for a 3D image. The number of cores used is specified in porespy.settings.ncores and defaults to all cores.


image – A copy of im with the pore size values in each voxel.

Return type


See also



The term foreground is used since this function can be applied to both pore space or the solid, whichever is set to True.

This function is identical to porosimetry with access_limited set to False.

The way local thickness is found in PoreSpy differs from the traditional method (i.e. used in ImageJ https://imagej.net/Local_Thickness). Our approach is probably slower, but it allows for the same code to be used for local_thickness and porosimetry, since we can ‘trim’ invaded regions that are not connected to the inlets in the porosimetry function. This is not needed in local_thickness however.


Click here to view online example.