You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
OpenSeadragon cannot read whole slide images formats (from Aperio, Hamamatsu and so on)
But it can read DeepZoom.
So whole slide images must be first converted to Deepzoom.
The main tool for that is libvips, it relies on openslide to read whole slide images. libvips defines a function vips_dzsave
int
vips_dzsave (VipsImage *in,
const char *name,
...);
Can also be used from the command line vips utility
vips dzsave CMU-3.ndpi CMU-3.dzi
How to use libvips and openslide from javascript ?
Someone asking for node.js bindings for openslide on the
openslide repo (openslide/openslide#204)
sharp('input.tiff')
.png()
.tile({
size: 512
})
.toFile('output.dz', function(err, info) {
// output.dzi is the Deep Zoom XML definition
// output_files contains 512x512 tiles grouped by zoom level
});
since early versions sharp supports reading in whole slide images (using openslide), as well as writing DeepZoom images (Added DeepZoom support lovell/sharp#146).
The documentation used to include installation instructions for installing sharp with openslide support but now no mention of openslide anymore...
I naively tried
sharp('CMU-3.ndpi')
.png()
.tile({
size: 512
})
.toFile('output.dz', function(err, info) {
// output.dzi is the Deep Zoom XML definition
// output_files contains 512x512 tiles grouped by zoom level
});
@xmkevin, sharp can read all the formats that openslide can read,
you just need to enable openslide support. There are some notes in the README.
Somehow one may has to /enable openslide support/ and I'm not sure what that means. Potentially useful to figure it out because sharp, coupled with openslide seems to be able to do precisely what we are looking for.
The gitHub repo provide an example reading a whole slide image with openslide:
var vips = require('vips');
// get a rect from a level
// autocrop trims off pixels outside the image bounds
var image = vips.Image.openslideload('somefile.svs', {level: 2, autocrop: true});
console.log('level size:', image.width, 'x', image.height);
// try 'vipsheader -a somefile.svs' at the command-line to see all the metadata
// fields you can get
console.log('associated images are:', image.get('slide-associated-images'));
// crop is left, top, width, height in pixels
// images are RGBA with premultiplication taken out
image.crop(100, 100, 1000, 1000).writeToFile('x.png');
// extract an associated image
image = vips.Image.openslideload('somefile.svs', {associated: 'label'});
image.writeToFile('label.png');
That also looks like exactly what we'd need.
question What bother writing node bindings when sharp can do it ? Isn't it redundant with sharp ? How does sharp differ from libvips (in terms of functionalities)
!!! !!!Had to update libvips to the latest version.
Didn't work with the libvips-dev available in the ubuntu repo, so installed from source.
Now possible to read a slide using vips in javascript
const vips = require('vips');
var image = vips.Image.openslideload('CMU-3.ndpi')
ISSUE Cannot figure out how to use dzsave using javascript bindings
// None of these work
var test = vips.Image.dzsave('CMU-3.ndpi', 'test.dz')
image.dzsave('output.dz')
vips.Image.dzsave('CMU-3.dzi')
OpenSeadragon cannot read whole slide images formats (from Aperio, Hamamatsu and so on)
But it can read DeepZoom.
So whole slide images must be first converted to Deepzoom.
The main tool for that is libvips, it relies on openslide to read whole slide images.
libvips defines a function
vips_dzsave
Can also be used from the command line
vips
utilityHow to use libvips and openslide from javascript ?
Someone asking for node.js bindings for openslide on the
openslide repo (openslide/openslide#204)
Main libvips developer John Cupitt suggests to use sharp
sharp
The documentation used to include installation instructions for installing sharp with openslide support but now no mention of openslide anymore...
I naively tried
but doesn't produce any output.
In may 2017 jcupitt writes
Somehow one may has to /enable openslide support/ and I'm not sure what that means. Potentially useful to figure it out because sharp, coupled with openslide seems to be able to do precisely what we are looking for.
node-vips
Sept. 2017: Experimental node binding for libvips
(https://github.com/libvips/node-vips)
The gitHub repo provide an example reading a whole slide image with openslide:
That also looks like exactly what we'd need.
!!! !!! Had to update libvips to the latest version.
Didn't work with the libvips-dev available in the ubuntu repo, so installed from source.
Now possible to read a slide using vips in javascript
dzsave
using javascript bindingsdzsave
is only mentioned inlib/autogen.js
The text was updated successfully, but these errors were encountered: