From 796a718b275380c5d6731a57788d579c5e66962b Mon Sep 17 00:00:00 2001 From: Christian Kento Rasmussen <christian.kento@gmail.com> Date: Fri, 17 Jan 2025 14:16:16 +0100 Subject: [PATCH] added mean based scaling method --- qim3d/io/_ome_zarr.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/qim3d/io/_ome_zarr.py b/qim3d/io/_ome_zarr.py index 6573831a..022e16cd 100644 --- a/qim3d/io/_ome_zarr.py +++ b/qim3d/io/_ome_zarr.py @@ -178,6 +178,20 @@ class OMEScaler( log.info(f"- Scale {i+1}: {rv[-1].shape}") return list(rv) + + def scaleZYXmean(self, base): + """ Downsample using the mean of the pixels in each block + + Args: + base (dask): The 3D array (volume) to be downsampled. Must be a Dask array for chunked processing. + + Returns: + list: A list of downsampled volumes of increasingly lower resolution. + """ + mip = [base] + for _ in range(self.max_layer): + mip.append(da.coarsen(da.mean, mip[-1], {0:self.downscale, 1:self.downscale, 2:self.downscale}, trim_excess=True)) + return mip def export_ome_zarr( -- GitLab