CellProfiler / python-bioformats

Read and write life sciences file formats
Other
129 stars 45 forks source link

JavaException: Image plane too large. #48

Closed manuels closed 8 years ago

manuels commented 8 years ago

I'm trying to load a ~200MB big NDPI slide scanner file but this fails with this error message:

img = bioformats.load_image('/mnt/schoellingm/idaf/tmp/12-244-3-HE - 2012-03-12 22.30.10.ndpi', series=0)
JavaException: Image plane too large. Only 2GB of data can be extracted at one time. You can workaround the problem by opening the plane in tiles; for further details, see: http://www.openmicroscopy.org/site/support/bio-formats/about/bug-reporting.html#common-issues-to-check

According to the link you should only load a subsection of the image using openBytes(int, int, int, int, int) but even this, too:

import bioformats.formatreader as F
ImageReader = F.make_image_reader_class()
reader = ImageReader()
reader.setId(path)
(reader.getSizeY(), reader.getSizeX())
# (41216, 34816)
data = reader.openBytes(0,0,0,100,100)
JavaException: Image plane too large. Only 2GB of data can be extracted at one time. You can workaround the problem by opening the plane in tiles; for further details, see: http://www.openmicroscopy.org/site/support/bio-formats/about/bug-reporting.html#common-issues-to-check

Could it be that the proxy to the java classes do not support function overloading for the several variants of openBytes with different number of parameters?

byte[]  openBytes(int no)
Obtains the specified image plane from the current file as a byte array.
byte[]  openBytes(int no, byte[] buf)
Obtains the specified image plane from the current file into a pre-allocated byte array of (sizeX * sizeY * bytesPerPixel * RGB channel count).
byte[]  openBytes(int no, byte[] buf, int x, int y, int w, int h)
Obtains a sub-image of the specified image plane into a pre-allocated byte array.
byte[]  openBytes(int no, int x, int y, int w, int h)
Obtains a sub-image of the specified image plane, whose upper-left corner is given by (x, y).

(copied from here)

manuels commented 8 years ago

oh, you should use openBytesXYWH() instead!

imagesc-bot commented 3 years ago

This issue has been mentioned on Image.sc Forum. There might be relevant details there:

https://forum.image.sc/t/bio-formats-read-region-equivalent/39150/11