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.- Attributes:
- copy_metadata:
If True, copy Zarr attributes from the input array to the new group.
- downscale:
Downscaling factor.
- in_place:
Does not do anything.
- labeled:
If True, check that the values in the downsampled levels are a subset of the values found in the input array.
- max_layer:
The maximum number of downsampled layers to create.
- method:
Downsampling 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)
- property func: Callable[[ndarray], list[numpy.ndarray]]
Get downsample function.
- gaussian(base: ndarray) list[numpy.ndarray]
Downsample using
skimage.transform.pyramid_gaussian()
.
- laplacian(base: ndarray) list[numpy.ndarray]
Downsample using
skimage.transform.pyramid_laplacian()
.
- local_mean(base: ndarray) list[numpy.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[numpy.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)
- zoom(base: ndarray) list[numpy.ndarray]
Downsample using
scipy.ndimage.zoom()
.