From 892fda2a7270c03ebdb7048d5ea90916162e9842 Mon Sep 17 00:00:00 2001
From: Benjamin Gilbert An open whole-slide image. If any operation on the object fails, Return a string describing the format vendor of the specified file.
This string is also accessible via the Images, such as label or macro images, which are associated with this
slide. This is a Installing
# The path can also be read from a config file, etc.
OPENSLIDE_PATH = r'c:\path\to\openslide-win64\bin'
-import os
+import os
if hasattr(os, 'add_dll_directory'):
# Windows
with os.add_dll_directory(OPENSLIDE_PATH):
- import openslide
+ import openslide
else:
- import openslide
+ import openslide
Basic usage
OpenSlide objects¶
OpenSlideError is raised.
OpenSlide has latching error semantics: once OpenSlideError is
@@ -113,7 +113,7 @@ Basic usage
PROPERTY_NAME_VENDOR
property.Basic usageassociated_images¶
Mapping from image
-name to RGBA Image.Image.
Unlike in the C interface, these images are not premultiplied.
@@ -207,15 +207,15 @@None if not available.
ImageCmsProfile | None
+ImageCmsProfile | None
Return an RGBA Image containing the contents of
+read_region(location: tuple[int, int], level: int, size: tuple[int, int]) Image¶
+
Return an RGBA Image containing the contents of
the specified region.
Unlike in the C interface, the image data is not premultiplied.
Return an Image containing an RGB thumbnail of the
+get_thumbnail(size: tuple[int, int]) Image¶
+
Return an Image containing an RGB thumbnail of the
slide.
bytes object in
-Image.info['icc_profile']. If no
+Image.info['icc_profile']. If no
profile is available, the icc_profile dictionary key is absent.
To include the profile in an image file when saving the image to disk:
image.save(filename, icc_profile=image.info.get('icc_profile'))
To perform color conversions using the profile, import it into
-ImageCms. For example, to synthesize an sRGB profile
+ImageCms. For example, to synthesize an sRGB profile
and use it to transform an image for display, with the default rendering
intent of the image’s profile:
from io import BytesIO
-from PIL import ImageCms
+from io import BytesIO
+from PIL import ImageCms
fromProfile = ImageCms.getOpenProfile(BytesIO(image.info['icc_profile']))
toProfile = ImageCms.createProfile('sRGB')
@@ -310,8 +310,8 @@ Basic usageOpenSlide.color_profile, already parsed into an
-ImageCmsProfile object. You can save processing time
-by building an ImageCmsTransform for the slide and
+ImageCmsProfile object. You can save processing time
+by building an ImageCmsTransform for the slide and
reusing it for multiple slide regions:
toProfile = ImageCms.createProfile('sRGB')
intent = ImageCms.getDefaultIntent(slide.color_profile)
@@ -327,7 +327,7 @@ Basic usage¶
-
-class openslide.OpenSlideCache(capacity: int)¶
+class openslide.OpenSlideCache(capacity: int)¶
An in-memory tile cache.
Tile caches can be attached to one or more OpenSlide objects
with OpenSlide.set_cache() to cache recently-decoded tiles. By
@@ -425,7 +425,7 @@
Caching¶
Exceptions¶
-
-exception openslide.OpenSlideError¶
+exception openslide.OpenSlideError¶
An error produced by the OpenSlide library.
Once OpenSlideError has been raised by a particular
OpenSlide, all future operations on that OpenSlide
@@ -435,14 +435,14 @@
Exceptions
-
-exception openslide.OpenSlideUnsupportedFormatError¶
+exception openslide.OpenSlideUnsupportedFormatError¶
OpenSlide does not support the requested file. Subclass of
OpenSlideError.
-
-exception openslide.OpenSlideVersionError¶
+exception openslide.OpenSlideVersionError¶
This version of OpenSlide does not support the requested functionality.
Subclass of OpenSlideError.
@@ -453,18 +453,18 @@ ExceptionsWrapping a Pillow Image¶
-
-class openslide.AbstractSlide¶
+class openslide.AbstractSlide¶
The abstract base class of OpenSlide and ImageSlide.
-
-class openslide.ImageSlide(file: str | bytes | PathLike[Any] | Image)¶
-A wrapper around an Image object that provides an
+class openslide.ImageSlide(file: str | bytes | PathLike[Any] | Image)¶
+
A wrapper around an Image object that provides an
OpenSlide-compatible API.
- Parameters:
-file – a filename or Image object
+file – a filename or Image object
- Raises:
OSError – if the file cannot be opened
@@ -500,7 +500,7 @@ Exceptions
-
-class openslide.deepzoom.DeepZoomGenerator(osr: AbstractSlide, tile_size: int = 254, overlap: int = 1, limit_bounds: bool = False)¶
+class openslide.deepzoom.DeepZoomGenerator(osr: AbstractSlide, tile_size: int = 254, overlap: int = 1, limit_bounds: bool = False)¶
A Deep Zoom generator that wraps an OpenSlide object,
ImageSlide object, or user-provided instance of
AbstractSlide.
@@ -577,8 +577,8 @@ Exceptions
-
-get_tile(level: int, address: tuple[int, int]) Image¶
-Return an RGB Image for a tile.
+get_tile(level: int, address: tuple[int, int]) Image¶
+Return an RGB Image for a tile.
- Parameters:
@@ -745,13 +745,13 @@ This Page