neuroglancer_scripts.downscaling module¶
Downscaling is used to create a multi-resolution image pyramid.
The central component here is the Downscaler base class. Use
get_downscaler() for instantiating a concrete downscaler object.
- class neuroglancer_scripts.downscaling.AveragingDownscaler(outside_value=None)[source]¶
Bases:
DownscalerDownscale by a factor of two in any given direction, with averaging.
This downscaler is suitable for grey-level images.
Todo
Use code from the neuroglancer module to support arbitrary factors.
- check_factors(downscaling_factors)[source]¶
Test support for given downscaling factors.
Subclasses must override this method if they do not support any combination of integer downscaling factors.
- downscale(chunk, downscaling_factors)[source]¶
Downscale a chunk according to the provided factors.
- Parameters:
chunk (numpy.ndarray) – chunk with (C, Z, Y, X) indexing
downscaling_factors (tuple) – sequence of integer downscaling factors (Dx, Dy, Dz)
- Returns:
the downscaled chunk, with shape
(C, ceil_div(Z, Dz), ceil_div(Y, Dy), ceil_div(X, Dx))- Return type:
- Raises:
NotImplementedError – if the downscaling factors are unsupported
- class neuroglancer_scripts.downscaling.Downscaler[source]¶
Bases:
objectBase class for downscaling algorithms.
- check_factors(downscaling_factors)[source]¶
Test support for given downscaling factors.
Subclasses must override this method if they do not support any combination of integer downscaling factors.
- downscale(chunk, downscaling_factors)[source]¶
Downscale a chunk according to the provided factors.
- Parameters:
chunk (numpy.ndarray) – chunk with (C, Z, Y, X) indexing
downscaling_factors (tuple) – sequence of integer downscaling factors (Dx, Dy, Dz)
- Returns:
the downscaled chunk, with shape
(C, ceil_div(Z, Dz), ceil_div(Y, Dy), ceil_div(X, Dx))- Return type:
- Raises:
NotImplementedError – if the downscaling factors are unsupported
- class neuroglancer_scripts.downscaling.MajorityDownscaler[source]¶
Bases:
DownscalerDownscaler using majority voting.
This downscaler is suitable for label images.
Todo
The majority downscaler could be really optimized (clever iteration with nditer, Cython, countless for appropriate cases)
- downscale(chunk, downscaling_factors)[source]¶
Downscale a chunk according to the provided factors.
- Parameters:
chunk (numpy.ndarray) – chunk with (C, Z, Y, X) indexing
downscaling_factors (tuple) – sequence of integer downscaling factors (Dx, Dy, Dz)
- Returns:
the downscaled chunk, with shape
(C, ceil_div(Z, Dz), ceil_div(Y, Dy), ceil_div(X, Dx))- Return type:
- Raises:
NotImplementedError – if the downscaling factors are unsupported
- class neuroglancer_scripts.downscaling.StridingDownscaler[source]¶
Bases:
DownscalerDownscale using striding.
This is a fast, low-quality downscaler that provides no protection against aliasing artefacts. It supports arbitrary downscaling factors.
- downscale(chunk, downscaling_factors)[source]¶
Downscale a chunk according to the provided factors.
- Parameters:
chunk (numpy.ndarray) – chunk with (C, Z, Y, X) indexing
downscaling_factors (tuple) – sequence of integer downscaling factors (Dx, Dy, Dz)
- Returns:
the downscaled chunk, with shape
(C, ceil_div(Z, Dz), ceil_div(Y, Dy), ceil_div(X, Dx))- Return type:
- Raises:
NotImplementedError – if the downscaling factors are unsupported
- neuroglancer_scripts.downscaling.add_argparse_options(parser)[source]¶
Add command-line options for downscaling.
- Parameters:
parser (argparse.ArgumentParser) – an argument parser
The downscaling options can be obtained from command-line arguments with
add_argparse_options()and passed toget_downscaler():import argparse parser = argparse.ArgumentParser() add_argparse_options(parser) args = parser.parse_args() get_downscaler(args.downscaling_method, vars(args))
- neuroglancer_scripts.downscaling.get_downscaler(downscaling_method, info=None, options={})[source]¶
Create a downscaler object.
- Parameters:
- Returns:
an instance of a sub-class of
Downscaler- Return type: