apply_padded(im, pad_width, func, pad_val=1, **kwargs)[source]#

Applies padding to an image before sending to func, then extracts the result corresponding to the original image shape.

  • im (ndarray) – The image to which func should be applied

  • pad_width (int or list of ints) – The amount of padding to apply to each axis. Refer to numpy.pad documentation for more details.

  • pad_val (scalar) – The value to place into the padded voxels. The default is 1 (or True) which extends the pore space.

  • func (function handle) – The function to apply to the padded image.

  • kwargs – Additional keyword arguments are collected and passed to func.


A use case for this is when using skimage.morphology.skeletonize_3d to ensure that the skeleton extends beyond the edges of the image.


Click here to view online example.