Smoothing#

Smoothing

Smooth a binary image based on the local configuration of voxels in a cube.

See also

The, parallel

R2(cube)[source]#
S3(cube)[source]#
U0(cube)[source]#
U1(cube)[source]#
U2(cube)[source]#
cube_to_smoothing(cube)[source]#

Match cube configurations to delete, add or keep a voxel.

generate_lookup_table(function=<function index_to_smoothing>, verbose=True, processes=None)[source]#

Generates lookup table for templates

index_to_smoothing(index, verbose=True)[source]#

Match index of configuration to smoothing action

initialize_lookup_table(function=<function index_to_smoothing>, filename='Smoothing.npy', verbose=True, processes=None)[source]#

Initialize the lookup table

rotations_edges(cube)[source]#
rotations_faces(cube)[source]#
rotations_node_faces(cube)[source]#
rotations_nodes(cube)[source]#
smooth_by_configuration(source, sink=None, iterations=1, processing_parameter=None, processes=None, verbose=False)[source]#

Smooth a binary source using the local configuration around each pixel.

Arguments

sourcearray or Source

The binary source to smooth.

sinkarray, Source or None

The sink to write result of smoothing. If None, return array.

iterationsint

Number of smoothing iterations.

processing_parameterNone or dict

The parameter passed to ClearMap.ParallelProcessing.BlockProcessing.process().

processesint or None

number of processes to use.

verbosebool

If True, print progress information.

Returns

smoothedarray or Source

Thre smoothed binary array.

Note

The algorithm is based on a topological smoothing operation defined by adding or removing forground pixels based on the local topology of the binary array.

smooth_by_configuration_block(source, iterations=1, verbose=False)[source]#

Smooth a binary source using the local configuration around each pixel.

Arguments

sourcearray

The binary source to smooth.

iterationsint

Number of smoothing iterations.

verbosebool

If True, print progress information.

Returns

smoothedarray

The smoothed binary array.

smooth_by_counting(source, sink=None, low=5, high=10, shape=None)[source]#

Smooth binary image by counting neighbours.

Arguments

sourcearray

The binary source to smooth.

sinkarray or None.

The sink to write the smoothed source to.

lowint

If a voxel has less then this number of 26-neighbours it is set to False.

highint

If a voxel has more then this number of 26-neighbours it is set to True.

shapetuple of int or None

The shape of the square structuring element to consider.

Returns

sinkarray

The smoothed sbinary source.

Note

The algorithm uses a sequence of 1d convoluions for speed, allowing only rectangular like structuring elements.

smooth_by_configuration_filename = 'Smoothing.npy'#

Filename for the look up table mapping a cube configuration to the smoothing action for the center pixel.