Struct OpenSlide

Source
pub struct OpenSlide {
    pub properties: Properties,
    /* private fields */
}
Expand description

Openslide object is a simple wrapper around openslide_t “C” type. Implementation provides all functions available in the “C” API It contains also openslide and vendor specific properties found in WSI.

Note : As stated by the OpenSlide documentation, all function are thread-safe except close() For this reason OpenSlide implement the Drop trait which call close() automatically

Fields§

§properties: Properties

Implementations§

Source§

impl OpenSlide

Source

pub fn get_version() -> Result<String>

Get the version of the OpenSlide library.

Source

pub fn new<T: AsRef<Path>>(path: T) -> Result<OpenSlide>

This method tries to open the slide at the given filename location.

This function can be expensive; avoid calling it unnecessarily. For example, a tile server should not create a new object on every tile request. Instead, it should maintain a cache of OpenSlide objects and reuse them when possible.

Source

pub fn detect_vendor(path: &Path) -> Result<String>

Quickly determine whether a whole slide image is recognized.

Source

pub fn properties(&self) -> &Properties

Source

pub fn get_level_count(&self) -> Result<u32>

Get the number of levels in the whole slide image.

Source

pub fn get_level_dimensions(&self, level: u32) -> Result<Size>

Get the dimensions of level 0 (the largest level).

This method returns the Size { width, height } number of pixels of the whole slide image at the specified level. Returns an error if the level is invalid

Source

pub fn get_all_level_dimensions(&self) -> Result<Vec<Size>>

Get dimensions of all available levels

Source

pub fn get_level_downsample(&self, level: u32) -> Result<f64>

Get the downsampling factor of a given level.

Source

pub fn get_all_level_downsample(&self) -> Result<Vec<f64>>

Get all downsampling factors for all available levels.

Source

pub fn get_best_level_for_downsample(&self, downsample: f64) -> Result<u32>

Get the best level to use for displaying the given downsample factor.

Source

pub fn get_property_names(&self) -> Vec<String>

Get the list of all available properties.

Source

pub fn get_property_value(&self, name: &str) -> Result<String>

Get the value of a single property.

Source

pub fn read_region(&self, region: &Region) -> Result<Vec<u8>>

Copy pre-multiplied ARGB data from a whole slide image.

This function reads and decompresses a region of a whole slide image into a Vec

Args: offset: (x, y) coordinate (increasing downwards/to the right) of top left pixel position level: At which level to grab the region from size: (width, height) in pixels of the outputted region

Size of output Vec is Width * Height * 4 (RGBA pixels)

Source

pub fn get_associated_image_names(&self) -> Result<Vec<String>>

Get the list name of all available associated image.

Source

pub fn read_associated_buffer(&self, name: &str) -> Result<(Size, Vec<u8>)>

Copy pre-multiplied ARGB data from a whole slide image.

This function reads and decompresses an associated image into an Vec

Args: name: name of the associated image we want to read

Size of output Vec is width * height * 4 (RGBA pixels)

Source

pub fn get_associated_image_dimensions(&self, name: &str) -> Result<Size>

Get the size of an associated image

Source

pub fn read_image_rgba(&self, region: &Region) -> Result<RgbaImage>

Copy pre-multiplied ARGB data from a whole slide image.

This function reads and decompresses a region of a whole slide image into an RgbImage

Args: offset: (x, y) coordinate (increasing downwards/to the right) of top left pixel position level: At which level to grab the region from size: (width, height) in pixels of the outputted region

Source

pub fn read_image_rgb(&self, region: &Region) -> Result<RgbImage>

Copy pre-multiplied ARGB data from from an associated image..

This function reads and decompresses a region of a whole slide image into an RgbaImage

Args: offset: (x, y) coordinate (increasing downwards/to the right) of top left pixel position level: At which level to grab the region from size: (width, height) in pixels of the outputted region

Source

pub fn read_associated_image_rgba(&self, name: &str) -> Result<RgbaImage>

Copy pre-multiplied ARGB data from an associated image.

This function reads and decompresses an associated image into an RgbaImage

Args: name: name of the associated image we want to read

Source

pub fn read_associated_image_rgb(&self, name: &str) -> Result<RgbImage>

Copy pre-multiplied ARGB data from an associated image.

This function reads and decompresses an associated image into an RgbaImage

Args: name: name of the associated image we want to read

Source

pub fn thumbnail_rgba(&self, size: &Size) -> Result<RgbaImage>

Get a RGBA image thumbnail of desired size of the whole slide image. Args: size: (width, height) in pixels of the thumbnail

Source

pub fn thumbnail_rgb(&self, size: &Size) -> Result<RgbImage>

Get a RGB image thumbnail of desired size of the whole slide image. Args: size: (width, height) in pixels of the thumbnail

Trait Implementations§

Source§

impl Debug for OpenSlide

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for OpenSlide

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Slide for OpenSlide

Source§

fn get_bounds(&self) -> Bounds

Get properties of the whole slide image through Properties struct.
Source§

fn get_level_count(&self) -> Result<u32>

Get the number of levels in the whole slide image.
Source§

fn get_level_dimensions(&self, level: u32) -> Result<Size>

Get the dimensions of level 0 (the largest level). Read more
Source§

fn get_level_downsample(&self, level: u32) -> Result<f64>

Get the downsampling factor of a given level.
Source§

fn get_best_level_for_downsample(&self, downsample: f64) -> Result<u32>

Get the best level to use for displaying the given downsample factor.
Source§

fn read_image_rgba(&self, region: &Region) -> Result<RgbaImage>

Copy pre-multiplied ARGB data from a whole slide image. Read more
Source§

fn read_image_rgb(&self, region: &Region) -> Result<RgbImage>

Copy pre-multiplied ARGB data from an associated image. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.