Topology3d#

Defines basic 3d discrete topology utils.

Note

The definitions are compatible with a separable convolutional kernel with weights along the 3 dimensions given by:

>>> [[(2**(3**d))**k for k in range(3)] for d in range(3)]
check_border(data, value=0)[source]#
cube_base_2(center=None)[source]#

Returns an array with base 2 numbers on the cube for convolution and lut matching

cube_from_index(index, center=None)[source]#

Returns a boolean cube for the corresponding index

cube_labeled(center=None)[source]#

Returns an array with labels on the cube

cube_to_index(cube, center=None)[source]#

Returns index for a boolean cube

delete_border(data, value=0)[source]#
extract_neighbourhood(img, x, y, z)[source]#

Return the neighbourhoods of the indicated voxels

Arguments:

img (array): the 3d image x,y,z (n array): coordinates of the voxels to extract neighbourhoods from

Returns:

array (nx27 array): neighbourhoods

Note:

Assumes borders of the image are zero so that 0<x,y,z<w,h,d !

index_from_binary(source, sink=None, method='shared', dtype='uint32', processes=None, verbose=False)[source]#

Calculate the local 3x3x3 configuration in a binary source.

Note

The configuration kernel is separable and convolution with it is calculated via a sequence of 1d convolutions.

index_kernel(axis=None, dtype='uint32')[source]#

Separable 1d kernels to obtain configuration index.

n18_indices(dtype='uint8')[source]#

Indices as 6 Neighbourhood

n26_indices(dtype='uint8')[source]#

Indices as 6 Neighbourhood

n6_indices(dtype='uint8')[source]#

Indices as 6 Neighbourhood

n_cube_indices(center=None)[source]#

Number of different cubes

neighbourhood_list(img, dtype='int64', verbose=False)[source]#

Return a list of x,y,z and list indices of the 26 neighbours

neighbourhood_list_delete(nhl, ids, changed=True)[source]#

Delete points in a neighbourhood list

neighbourhood_opposing_directions()[source]#

Returns a list of neighbour indices that are opposite of each other

orientations()[source]#

Generate cubes with True voxels at each of the 13 orientations

print_cube(cube)[source]#

Print the cube for debugging

reflect(cube)[source]#

Generate the center point reflection.

rotate(cube, axis=2, steps=0)[source]#

Rotate a cube around an axis in 90 degrees steps

rotations12(cube)[source]#

Generate rotations in 12 diagonal directions

rotations6(cube)[source]#

Generate rotations in 6 main directions

xyz_from_ndex(index)[source]#
xyz_to_index(x, y, z)[source]#
n18 = array([[[False,  True, False],         [ True,  True,  True],         [False,  True, False]],         [[ True,  True,  True],         [ True, False,  True],         [ True,  True,  True]],         [[False,  True, False],         [ True,  True,  True],         [False,  True, False]]])#

18-Neighborhood excluding center

n26 = array([[[ True,  True,  True],         [ True,  True,  True],         [ True,  True,  True]],         [[ True,  True,  True],         [ True, False,  True],         [ True,  True,  True]],         [[ True,  True,  True],         [ True,  True,  True],         [ True,  True,  True]]])#

26-Neighborhood excluding center

n6 = array([[[False, False, False],         [False,  True, False],         [False, False, False]],         [[False,  True, False],         [ True, False,  True],         [False,  True, False]],         [[False, False, False],         [False,  True, False],         [False, False, False]]])#

6-Neighborhood excluding center