distance_transform_lin#
- distance_transform_lin(im, axis=0, mode='both')[source]#
Replaces each void voxel with the linear distance to the nearest solid voxel along the specified axis.
- Parameters:
im (ndarray) – The image of the porous material with
True
values indicating the void phase (or phase of interest).axis (int) – The direction along which the distance should be measured, the default is 0 (i.e. along the x-direction).
mode (str) –
Controls how the distance is measured. Options are:
- ’forward’
Distances are measured in the increasing direction along the specified axis
- ’reverse’
Distances are measured in the reverse direction. ‘backward’ is also accepted.
- ’both’
Distances are calculated in both directions (by recursively calling itself), then reporting the minimum value of the two results.
- Returns:
image – A copy of
im
with each foreground voxel containing the distance to the nearest background along the specified axis.- Return type:
ndarray
Examples
Click here to view online example.