Skip to content

Conversation

@thewtex
Copy link
Collaborator

@thewtex thewtex commented Dec 23, 2024

  • ENH: tczyx, etc. support
  • PERF: itkwasm downsampling in zyx order

Downsample channels-first support, time + channels support. And
different orders.
Support memory layout assumed in _large_image_serialization.
@will-moore
Copy link

Thanks @thewtex,

I tried downsampling an image that has C dimension, hoping that the 2 separate channels would be downsampled independently, but it seems that the first channel is incorrectly resampled since it ends up being black:

import ngff_zarr as nz
import numpy as np

# 4D data
data = np.random.randint(0, 256, 16777216, dtype=np.uint8).reshape((2, 128, 256, 256))
image = nz.to_ngff_image(data, dims=['c', 'z', 'y', 'x'])

# downsample
multiscales = nz.to_multiscales(image, scale_factors=[2], chunks=64)

print("multiscales.images", multiscales.images)

# check that both channels have pixel data
for i, img in enumerate(multiscales.images):
    print("resolution", i)
    print("  ch0 max", img.data[0,:,:,:].max().compute())
    print("  ch1 max", img.data[1,:,:,:].max().compute())

This prints the following, showing that the first channel is black for the downsampled resolution:

resolution 0
  ch0 max 255
  ch1 max 255
resolution 1
  ch0 max 0
  ch1 max 211

The last `idx` from the previous computation was re-used without being
re-updated.

Also fix a bug in comparing a list to a tuple.
@thewtex
Copy link
Collaborator Author

thewtex commented Jan 7, 2025

@will-moore thanks for testing! I pushed a fix for that.

Copy link

@will-moore will-moore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working for me now, thanks!

@thewtex thewtex merged commit ce14332 into main Jan 8, 2025
36 checks passed
@thewtex thewtex deleted the channel branch January 8, 2025 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants