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

Unintuitive read_region for levels

Open jxu opened this issue 6 years ago • 3 comments

Context

Issue type (bug report or feature request): Feature request Operating system (e.g. Fedora 24, Mac OS 10.11, Windows 10): RHEL 7.6 Platform (e.g. 64-bit x86, 32-bit ARM): x86_64 OpenSlide Python version (openslide.__version__): 1.1.1 OpenSlide version (openslide.__library_version__): 3.4.1 Slide format (e.g. SVS, NDPI, MRXS): SVS

Details

For read_region in non-0 level I've found out that location is relative to level 0 image (stated in docs) but size is relative to level image. The docs say

Unlike in the C interface, the image data is not premultiplied.

but this should be clarified.

jxu avatar Jul 06 '19 23:07 jxu

has anyone provided a solution for this? it's quite unintuitive. If the admins/managers of openslide-python allow me and give simple example to make things clear, I could totally fix it (python-side only) myself.

def read_region(<originalparams>): # do some simple location and size calcuation here before passing to openslide lib return user_desired_image

VincePlantItAi avatar Jul 21 '21 12:07 VincePlantItAi

Premultiplied refers to the pixel data, not the boundaries of the region. We match the OpenSlide API here: location is in level 0 and size is the actual size of the region we're reading.

bgilbert avatar Jul 22 '21 02:07 bgilbert

thank you @bgilbert for your reply.

So the main point behind your response is, the original openslide API should be matched, so we cannot change the python wrapper for OpenSlide into its own.

Did I get you correctly?

VincePlantItAi avatar Jul 22 '21 23:07 VincePlantItAi