I have a whole-slide-images (.svs format) which are scanned at 20x. For my problem, I would like to upscale the slides to 40x along with the slide metadata. I tried it by the combination of the openslide, NumPy, cv2, and vips
command. For a smaller size of slides, I can achieve this but for larger size slides I can't. Is there a straightforward way available to achieve this?
I followed following steps
I would just use libvips resize
. For example:
$ vipsheader CMU-1.svs
CMU-1.svs: 46000x32914 uchar, 4 bands, srgb, openslideload
$ /usr/bin/time -f %M:%e vips resize CMU-1.svs x.tif[compression=jpeg,tile,pyramid] 2
673804:80.56
$ vipsheader x.tif
x.tif: 92000x65828 uchar, 3 bands, srgb, tiffload
80s and 680mb of memory to make x.tif
, a tiled, pyramidal, jpeg-compressed TIFF. libvips can't write SVS files, but this will be pretty close. By default it'll do the upsize with a bicubic interpolator.
In Python you'd use pyvips:
import pyvips
x = pyvips.Image.new_from_file("CMU-1.svs")
x = x.resize(2)
x.write_to_file("x.tif", compression="jpeg", tile=True, pyramid=True)