Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jp2 slicing #359

Open
YangForever opened this issue Mar 26, 2024 · 1 comment
Open

jp2 slicing #359

YangForever opened this issue Mar 26, 2024 · 1 comment

Comments

@YangForever
Copy link

Describe the issue: Hi, I am trying to use dask_image.imread.imread() to speed up the sub-volume extraction on my dataset of .jp2 format, but it throws an error when I extract multiple slices.

Psudocode Example:

import dask_image.imread

def read_subvol_stack(path, file_type):
    img_array_dask = dask_image.imread.imread(f"{path}/*.{file_type}")
    print(img_array_dask)
    img_array = img_array_dask[0:900, :, :].compute()
    return img_array

The print() function gives:

dask.array<_map_read_frame, shape=(3770, 1898, 1898), dtype=uint16, chunksize=(1, 1898, 1898), chunktype=numpy.ndarray>

When the compute() is running, an error occurs:

ValueError: could not broadcast input array from shape (1,1898,1898) into shape (1,1,1898)

I have checked, when compute() function activated, the imread() will read an image in shape of (1,1,1898, 1898), so the chunk size of (1, 1898, 1898) can’t be broadcast.

The code works well for .tif or .png images.

Anything else we need to know?:
I replicate the error if it helps: https://github.com/YangForever/DaskImageSlicing/tree/main

Environment:

  • Dask version: 2023.11.0
  • Python version: 3.9
  • Operating System: Ubuntu 20.04
  • Install method (conda, pip, source): conda
@m-albert
Copy link
Collaborator

m-albert commented May 8, 2024

@YangForever thanks for reporting this issue 🙏

Actually, there are several known problems with the current dask_image.imread implementation (see #229) and we recommend considering one of the readers mentioned here.

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

No branches or pull requests

2 participants