deepzoom level for c openslide library
jcupitt at gmail.com
jcupitt at gmail.com
Tue Apr 28 04:06:41 EDT 2015
Hi, I'm the vips maintainer.
On 28 April 2015 at 04:11, Dmitry Fedorov <fedorov at ece.ucsb.edu> wrote:
> My novice and simple question is whether you guys have a c++ layer similar
> to deepzoom I could promptly use. Reiterating, I would simply want to fetch
> a tile of a given size at a given resolution level. Would Vips library
> provide that layer?
In vips you'd do something like this:
// get level 2
VImage level = VImage::new_from_file ("myslide.svs",
VImage::option()->set("level", 2));
// extract a tile at x, y, w, h
VImage tile = level.crop (x, y, w, h);
// process it in some way
VImage tile = (tile * 12 + 32).cast (VIPS_FORMAT_UCHAR).resize (0.25);
// make a jpeg in memory ready to send to a client
void *buf;
size_t size;
tile.write_to_buffer (".jpg", &buf, &size,
VImage::option()->set("Q", 95));
You can read the openslide metadata with things like:
int n_levels = level.get_int ("openslide.level-count")
double downsample = level.get_double ("openslide.level[2].downsample")
etc.
vips is demand-driven and only calculates the pixels it has to, so
loading a whole layer and then cropping a small area is efficient.
When it does calculate, it uses all your cores and only keeps enough
of the image in memory for the calculation you have set up, so it's
quick and does not need much memory.
The C++ API docs are here:
http://www.vips.ecs.soton.ac.uk/supported/7.42/doc/html/libvips/using-from-cpp.html
The C++ API is a very thin layer over the C API, so you need to read that too.
John
More information about the openslide-users
mailing list