Dask-Image
Dask-Image provides distributed image processing capabilities built on Dask, enabling scalable operations on large image datasets that exceed memory. It is currently at version 2025.11.0 and typically releases on an annual cadence, often in sync with other Dask ecosystem projects, with bug fix releases as needed.
Common errors
-
AttributeError: module 'dask.array' has no attribute 'image'
cause Attempting to import `imread` from the old `dask.array.image` path, which no longer exists.fixChange the import to `from dask_image.imread import imread`. -
NotImplementedError: The 'scipy.ndimage.gaussian_filter' function is not implemented for Dask arrays.
cause Trying to apply a raw SciPy (or NumPy) function directly to a Dask Array, which does not automatically distribute the operation.fixUse the equivalent function from `dask_image.ndfilters` (e.g., `from dask_image.ndfilters import gaussian_filter`) or a `dask.array` method if one exists. -
ModuleNotFoundError: No module named 'tifffile'
cause Attempting to load TIFF files using `dask_image.imread.imread` without the necessary `tifffile` dependency installed.fixInstall `tifffile` via `pip install tifffile` or install `dask-image` with complete extras: `pip install 'dask-image[complete]'`.
Warnings
- gotcha Directly using NumPy or SciPy functions on Dask Arrays without Dask-Image wrappers will often fail or lead to inefficient computations.
- gotcha Poor chunking strategies can lead to severe performance issues or out-of-memory errors, especially when processing large images.
- deprecated The `imread` function for image loading was moved from `dask.array.image` to `dask_image.imread`.
Install
-
pip install dask-image -
pip install 'dask-image[complete]'
Imports
- imread
from dask.array.image import imread
from dask_image.imread import imread
- gaussian_filter
from dask_image.ndfilters import gaussian_filter
- label
from dask_image.ndmeasure import label
Quickstart
import dask.array as da
import dask_image.imread
import numpy as np
# Simulate loading a large image (e.g., a multi-gigabyte TIFF file)
# In a real scenario, you'd use: image_dask = dask_image.imread.imread('path/to/your/large_image.tif')
# For quickstart, create a dummy Dask array:
dummy_data = np.random.rand(2000, 2000, 3).astype(np.float32)
image_dask = da.from_array(dummy_data, chunks=(512, 512, 3))
print(f"Dask Array shape: {image_dask.shape}")
print(f"Dask Array chunks: {image_dask.chunks}")
# Perform a simple Dask computation (e.g., calculate the mean intensity)
mean_intensity = image_dask.mean().compute()
print(f"Mean intensity of the image: {mean_intensity:.4f}")
# Example using a filter (requires 'dask-image[complete]' for scikit-image)
# from dask_image.ndfilters import gaussian_filter
# filtered_image_dask = gaussian_filter(image_dask, sigma=1)
# print(f"Filtered Dask Array shape: {filtered_image_dask.shape}")
# print(f"Filtered image mean: {filtered_image_dask.mean().compute():.4f}")