openslide-python icon indicating copy to clipboard operation
openslide-python copied to clipboard

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

Open fengzhi09 opened this issue 7 years ago • 2 comments

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

fengzhi09 avatar Aug 16 '18 10:08 fengzhi09

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 avatar Jul 05 '19 04:07 jxu

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

jxu avatar Jul 05 '19 04:07 jxu