7

I am using the python API of openslide packages to read some ndpi file.When I use the read_region function, sometimes it return a odd image. What problems could have happend?

I have tried to read the full image, and it will be worked well. Therefore, I think there is no problem with the original file.

from openslide import OpenSlide
import cv2
import numpy as np

slide = OpenSlide('/Users/xiaoying/django/ndpi-rest-api/slide/read/21814102D-PAS - 2018-05-28 17.18.24.ndpi')
image = slide.read_region((1, 0),6, (780, 960))
image.save('image1.png')

The output is strange output

2 Answers2

3

As the read_region documentation says, the x and y parameters are always in the coordinate space of level 0. For the behavior you want, you'll need to multiply those parameters by the downsample of the level you're reading.

0

This appears to be a version-realted bug, see also

https://github.com/openslide/openslide/issues/291#issuecomment-722935212

The problem seems to relate to libpixman verions 0.38.x . There is a Workaround section written by GunnarFarneback suggesting to load a different version first e.g.

export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libpixman-1.so.0.34.0

upadte easier solution is:

We are using Python 3.6.8+ and this did the trick for us: conda install pixman=0.36.0

André Aichert
  • 313
  • 2
  • 11