libvips extract area of NDPI from Ex40 not from map

646 Views Asked by At

I am using libvips to get pyramids of .ndpi images.

through this answer and searching the documentation I found this command

vips extract_area myimage.ndpi[level=0] mypyramid.dz 0 0 10000 10000

Which extracts a crop starting at 0 0 and size 10000 10000 to a dzi file.

The level parameter is the magnification, 0 is the highest.

The problem is that the ndpi has the following images inside:

  • myimage_macro.tif
  • myimage_map.tif
  • myimage_x0.15625_z0.tif
  • myimage_x0.625_z0.tif
  • myimage_x10_z0.tif
  • myimage_x2.5_z0.tif
  • myimage_x40_z0.tif

And vips is taking myimage_macro.tif while I need myimage_x40_z0.tif

There should be a parameter like level to choose which from the images inside the OpenSlide (ndpi) I want.

Some people ask. Why not extracting the tif and then running vips?

Well, because vips tells me this:

openslide2vips: opening slide: No such value: directory 0, tag 278

Which means that using ndpisplit to extract the tif is somehow not saving the metadata to allow vips to recognize the image

So I am in a bit of a pesky situation. I have enormous images and I need to extract a slightly less enourmous piece and then have its pyramid.

Please help me, right now I am basically coding it all my self and it works but it is EXTREMELY slow.

1

There are 1 best solutions below

5
On BEST ANSWER

I've written this as an answer, though it's not really an answer. It seemed too long as just a comment.

The libvips openslideload operation lets you pick an associated image to load. You can get a list of the associated images from the slide-associated-images metadata tag. For example:

$ vipsheader -f slide-associated-images 2013_09_20_29.ndpi 
macro
$ vipsheader -f slide-associated-images CMU-1.svs
label, macro, thumbnail

You then pick out an associated image with perhaps:

$ vips crop CMU-1.svs[associated=label] x.jpg 10 10 100 100

To get a small part of the label.

So ... check what associated images openslide reports for your slide. If you can get the one you need, pick that with the associated parameter. If the image you need is not listed, I would contact the openslide project, since they will need to add support.

You could also check the openslide command-line tools, they might perhaps offer more options.