install question

Benjamin Gilbert bgilbert at cs.cmu.edu
Fri Mar 30 16:49:18 EDT 2012


On 03/30/2012 03:48 PM, David Gutman wrote:
> Also is there any documentation anywhere for the python-tools?  Or do
> I have to just figure it out from doing a dir(python-tools) or
> whatever and walk through the functions?

Try help('openslide') and help('openslide.deepzoom').

> I saw there's a write_as_png or something that will write out a
> cropped area from a given layer.. just trying to do something similar
> in an "all" python way (And also want to write a TIFF and not PNG).

For small layers, you could do:

   slide = OpenSlide('CMU-1.svs')
   region = slide.read_region((0, 0), level,
                              slide.level_dimensions[level])
   # region is a PIL.Image
   region.save('out.tiff')

(Note that OpenSlide is now calling layers "levels", since everyone else 
already does.)

However, PIL does not seem to support BigTIFF, or large images 
generally.  Also, this will load the entire level into RAM.  So this 
approach is not recommended.

You may want to check out libvips, which is an image processing library 
specifically designed for working with images that cannot fit into RAM. 
  The current release, version 7.28, can load images from OpenSlide, and 
it knows how to write TIFF.  Python bindings are available.

--Benjamin Gilbert


More information about the openslide-users mailing list