OpenSlide Usages

less than 1 minute read

OpenSlide lib μ‚¬μš©λ°©λ²•

μ‚¬μš©ν–ˆλ˜ λ©”μ„œλ“€ μ€‘μ—μ„œλ§Œ 뽑아봀닀.

# OpenSlide_objλ₯Ό svs 파일둜 읽어왔을 λ•Œμ˜ obj라고 κ°€μ •ν•œλ‹€.
OpenSlide_obj = openslide.OpenSlide(svs_path)

OpenSlide_obj.level_dimensions
# A list of (width, height) tuples, one for each level of the slide. level_dimensions[k] are the dimensions of level k
# ex. ((300, 300), (200, 200), (100, 100))

OpenSlide_obj.properties
# Metadata about the slide, in the form of a Mapping from OpenSlide property name to property value. Property values are always strings. OpenSlide provides some standard properties, plus additional properties that vary by slide format.

OpenSlide_obj.read_region(location, level, size)
# Return an RGBA Image containing the contents of the specified region.
# Unlike in the C interface, the image data is not premultiplied.
# ---------------------------------------------------------------------
# Parameters
# location (tuple) – (x, y) tuple giving the top left pixel in the level 0 reference frame
# level (int) – the level number
# size (tuple) – (width, height) tuple giving the region size

OpenSlide_obj.get_thumbnail(size)
# get_thumbnail(size)
# Return an Image containing an RGB thumbnail of the slide.
# ---------------------------------------------------------
# Parameters
# size (tuple) – the maximum size of the thumbnail as a (width, height) tuple

Appendix

Reference

https://openslide.org/api/python/

Leave a comment