I want to use the openslide functionality in pyvips

878 views Asked by At

I tried to use both openslide and pyvips and my application doesn't find the necesary .dll. I think it is a problem of using both librarys.

I have read that pyvips has openslide embed but I can't find how to use it. The main purpose for this is to read Whole Slide Images and see the different levels and augmentations, and work with them.

I'd really appreciate your help! Thank you

1

There are 1 answers

0
jcupitt On

Yes, pyvips usually includes openslide, so you can't use both together.

Use .get_fields() to see all the metadata on an image, for example:

$ python3
Python 3.9.7 (default, Sep 10 2021, 14:59:43) 
[GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyvips
>>> x = pyvips.Image.new_from_file("openslide/CMU-1.svs")
>>> x.width
46000
>>> x.height
32914
>>> x.get_fields()
['width', 'height', 'bands', 'format', 'coding', 'interpretation', 'xoffset', 'yoffset', 
'xres', 'yres', 'filename', 'vips-loader', 'slide-level', 'aperio.AppMag', 'aperio.Date', 
'aperio.Filename', 'aperio.Filtered', 'aperio.Focus Offset', 'aperio.ICC Profile', 
'aperio.ImageID', 'aperio.Left', 'aperio.LineAreaXOffset', 'aperio.LineAreaYOffset', 
...

pyvips will open base level of the image by default (the largest), use level= to pick other levels, perhaps:

>>> x = pyvips.Image.new_from_file("openslide/CMU-1.svs", level=2)
>>> x.width
2875

See the docs for details:

https://www.libvips.org/API/current/VipsForeignSave.html#vips-openslideload