Smoothing#
Smoothing
Smooth a binary image based on the local configuration of voxels in a cube.
See also
The
, parallel
- generate_lookup_table(function=<function index_to_smoothing>, verbose=True, processes=None)[source]#
Generates lookup table for templates
- initialize_lookup_table(function=<function index_to_smoothing>, filename='Smoothing.npy', verbose=True, processes=None)[source]#
Initialize the lookup table
- 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.