get_border(shape, thickness=1, mode='edges', return_indices=False)[source]

Creates an array of specified size with corners, edges or faces labelled as True. This can be used as mask to manipulate values laying on the perimeter of an image.

  • shape (array_like) – The shape of the array to return. Can be either 2D or 3D.

  • thickness (scalar (default is 1)) – The number of pixels/voxels to place along perimeter.

  • mode (string) – The type of border to create. Options are ‘faces’, ‘edges’ (default) and ‘corners’. In 2D ‘faces’ and ‘edges’ give the same result.

  • return_indices (boolean) – If False (default) an image is returned with the border voxels set to True. If True, then a tuple with the x, y, z (if im is 3D) indices is returned. This tuple can be used directly to index into the image, such as im[tup] = 2.

  • asmask (Boolean) – If True (default) then an image of the specified shape is returned, otherwise indices of the border voxels are returned.


image – An ND-array of specified shape with True values at the perimeter and False elsewhere

Return type



>>> import porespy as ps
>>> import scipy as sp
>>> mask =[3, 3], mode='corners')
>>> print(mask)
[[ True False  True]
 [False False False]
 [ True False  True]]
>>> mask =[3, 3], mode='edges')
>>> print(mask)
[[ True  True  True]
 [ True False  True]
 [ True  True  True]]


Click here to view online example.