Scale (ome_zarr.scale)

Module for downsampling numpy arrays via various methods.

See the Scaler class for details.

class ome_zarr.scale.Scaler(copy_metadata: bool = False, downscale: int = 2, in_place: bool = False, labeled: bool = False, max_layer: int = 4, method: str = 'nearest')

Helper class for performing various types of downsampling.

A method can be chosen by name such as “nearest”. All methods on this that do not begin with “_” and not either “methods” or “scale” are valid choices. These values can be returned by the methods() method.

>>> import numpy as np
>>> data = np.zeros((1, 1, 1, 64, 64))
>>> scaler = Scaler()
>>> downsampling = scaler.nearest(data)
>>> for x in downsampling:
...     print(x.shape)
(1, 1, 1, 64, 64)
(1, 1, 1, 32, 32)
(1, 1, 1, 16, 16)
(1, 1, 1, 8, 8)
(1, 1, 1, 4, 4)
gaussian(base: ndarray) List[ndarray]

Downsample using skimage.transform.pyramid_gaussian().

laplacian(base: ndarray) List[ndarray]

Downsample using skimage.transform.pyramid_laplacian().

local_mean(base: ndarray) List[ndarray]

Downsample using skimage.transform.downscale_local_mean().

static methods() Iterator[str]

Return the name of all methods which define a downsampling.

Any of the returned values can be used as the methods argument to the Scaler constructor

nearest(base: ndarray) List[ndarray]

Downsample using skimage.transform.resize().

resize_image(image: Array | ndarray) Array | ndarray

Resize a numpy array OR a dask array to a smaller array (not pyramid)

scale(input_array: str, output_directory: str) None

Perform downsampling to disk.

zoom(base: ndarray) List[ndarray]

Downsample using scipy.ndimage.zoom().