Issues with aray shape when using `dask_image.imread` (and `dask.array.image.imread`) vs. `imageio.imread`
See original GitHub issueI’m loading a big bunch of tomographic data in a preview/analysis notebook.
As we keep scanning samples, the dataframe I put the preview images in gets larger and larger.
I’ve been using imageio.imread
to load the preview images (middle axial slices and MIPs) from disk.
I’d like to switch to dask_image.imread
for this, as I’m loading the full datasets with it and generate the preview files from the full stacks loaded like this.
I now saw that loading an image with imageio.imread
returns an image with two coordinates (size of the image), while dask_image.imread
(and dask.array.image.imread
return an image with three coordinates, the first one being 1, the second and third being the size of the image.
I’m very well aware that I can just .squeeze()
the array before displaying with matplotlib
, but expect that all the imread
functions return the same kind of array.
Minimal Complete Verifiable Example:
I’ve made a gist which shows my issue fully self-contained, it can be found here and can be started in Binder:
It boils down to
imgio = imageio.imread('random.png')
imgdask = dask.array.image.imread('random.png')
imgdaskimg = dask_image.imread.imread('random.png')
returning different shape
s.
This is closely related to https://github.com/dask/dask-image/issues/229 😃
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (1 by maintainers)
Top GitHub Comments
Thank you for the report (and binder example!) @habi
My best suggestion is to squeeze the array to remove the singleton dimension(s) if they’re causing you problems.
Since this has no effect if no singleton dimensions are present, you would be able to add this generally to your code. Then you’ll get the same output, regardless of whether you happen to be using dask or not.
Thanks for the comment @jakirkham!
The underlying issue is more that I’m using
to lazily load +10000 of images from disk (several samples with each a folder of +1000 reconstructions).
From these I then generate files as necessary (axial views and MIPs), but do not
view
them directly. It seems to me that I have to switch everything to the ‘pure dask’ way mentioned in issue #181 above.