Anscombe Transform¶
Zarr V2 and V3 codecs for compressing photon-limited movies using the Anscombe Transform.
What is it?¶
This codec is designed for compressing movies with Poisson noise, which are produced by photon-limited modalities such as:
- Multiphoton microscopy
- Radiography
- Astronomy
How it works¶
The codec re-quantizes grayscale data efficiently using a square-root-like transformation to equalize noise variance across grayscale levels: the Anscombe Transform. This results in:
- Fewer unique grayscale levels
- Significant improvements in data compressibility
- No sacrifice to signal accuracy
Requirements¶
To use the codec, you need to provide two pieces of information:
zero_level: The input value corresponding to the absence of lightconversion_gain(also calledphoton_sensitivity): The conversion factor from signal levels to photon counts
The codec assumes that the video is linearly encoded with a potential offset and that these parameters can be accurately estimated from the data.
Features¶
- ✅ Zarr V2 support via
numcodecsinterface - ✅ Zarr V3 support via
ArrayArrayCodecinterface - ✅ Automatic parameter estimation from data
- ✅ Lossless compression for photon-limited data
- ✅ Python 3.11+ support
Quick Example¶
import zarr
import numpy as np
from anscombe_transform import AnscombeTransformV3
# Create sample data with Poisson noise
data = np.random.poisson(lam=50, size=(100, 512, 512)).astype('int16')
# Create Zarr array with Anscombe codec and blosc compression
store = zarr.storage.MemoryStore()
arr = zarr.create_array(
store=store,
shape=data.shape,
chunks=(10, 512, 512),
dtype='int16',
filters=[AnscombeTransformV3(zero_level=100, conversion_gain=2.5)],
compressors=[{'name': 'blosc', 'configuration': {'cname': 'zstd', 'clevel': 5}}],
zarr_format=3
)
# Write and read data
arr[:] = data
recovered = arr[:]