Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
VIPS is an image processing system that can work with large images without loading the entire image into RAM. It includes a library, libvips, and a graphical interface, nip2. As of libvips 7.28.3 and nip2 7.28.2, VIPS supports reading whole-slide images with OpenSlide.
Exporting slide data with vips
libvips includes a command-line program,
vips, that can be used to export data from a whole-slide image to another format.
To convert level 0 of a slide to an LZW-compressed tiled TIFF:
vips openslideload CMU-1.mrxs slide.tiff[tile,compression=lzw]
You cannot write a JPEG-compressed tiled TIFF this way, because the TIFF writer gets confused by the alpha channel returned by OpenSlide. On VIPS 7.30 and above, you can work around this by using
vips extract_band CMU-1.mrxs slide.tiff[tile,compression=jpeg] 0 --n 3
VIPS 7.28 uses different syntax:
vips im_extract_bands CMU-1.mrxs slide.tiff:jpeg,tile 0 3
If the output TIFF will be larger than 4 GB, libvips must be linked against libtiff >= 4, and BigTIFF support must be explicitly enabled in the TIFF writer:
vips openslideload CMU-1.mrxs slide.tiff[tile,compression=lzw,bigtiff]
To convert level 3 instead of level 0:
vips openslideload --level 3 CMU-1.mrxs slide.tiff[tile,compression=lzw]
This is equivalent to:
vips tiffsave CMU-1.mrxs[level=3] slide.tiff --tile --compression=lzw
To save the "label" associated image as a PNG:
vips openslideload --associated label CMU-1.mrxs label.png
Note that VIPS before 7.40.5 will swap the red and blue channels. (On big-endian systems, the color channels and alpha are rotated right by one position.)
VIPS ≥ 7.40.5 supports an
autocrop option to output only the region of the slide that contains pixel data:
vips dzsave CMU-1.mrxs[autocrop] pyramid
This is generally more convenient for "sparse" slide formats such as MIRAX, but it also causes a coordinate shift relative to the original slide file.
Viewing a slide with nip2
nip2 is the VIPS GUI. It can only work with one slide level at a time, so it does not provide an efficient zoomable interface. However, unlike other conventional image viewers/editors, it can handle very large images.
nip2 uses the older
vips7 syntax for loading slides.
To load level 0:
To load level 3:
To load the "label" associated image: