openslide / openslide-python

Python bindings to OpenSlide
https://openslide.org/
GNU Lesser General Public License v2.1
357 stars 182 forks source link

[python api] openslide.read_region broke when svs too large #122

Open fengzhi09 opened 5 years ago

fengzhi09 commented 5 years ago

Context

Issue type (bug report or feature request): bug report Operating system (e.g. Fedora 24, Mac OS 10.11, Windows 10): Windows 10 Platform (e.g. 64-bit x86, 32-bit ARM): 64-bit x86 OpenSlide version: 1.1.1 Slide format (e.g. SVS, NDPI, MRXS): svs

Details

call like this: openslide.open_slide(svs_file) level = 1 dimension=slide.level_dimensions[level] // It broken many times. // Among all broken dimensions of all svs files, min is (25895,21005) max is (89639,51222) slide.read_region((0, 0), level, dimension)

stack_trace: File "D:\projects\cancer_ml_project\tools\SVS2PNGConverter.py", line 31, in convert_for_file imsave(out_folder + "/" + png_file, np.array(slide.read_region((0, 0), level, dimension))) File "D:\projects\cancer_ml_project\venv\lib\site-packages\openslide__init__.py", line 223, in read_region level, size[0], size[1]) File "D:\projects\cancer_ml_project\venv\lib\site-packages\openslide\lowlevel.py", line 258, in read_region buf = (w h c_uint32)() OverflowError: The 'length' attribute is too large

jxu commented 5 years ago

read_region is for reading relatively small regions that will fit into memory (probably image area < 2^32) It's usually not possible to read the whole region into memory anyway. That's the point of OpenSlide

jxu commented 5 years ago

Maybe duplicate of https://github.com/openslide/openslide/issues/73