Struct OpenSlide

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

A convenient OpenSlide object with the ordinary OpenSlide functions as methods

This wraps the bindings found in the bindings module, but has a more (in my opinion) convenient API for rust. It also contains some other convenience methods.

Fields§

§properties: Properties

Implementations§

Source§

impl OpenSlide

Source

pub fn new(filename: &Path) -> Result<OpenSlide, Error>

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 get_level_count(&self) -> Result<u32, Error>

Get the number of levels in the whole slide image.

Source

pub fn get_level0_dimensions(&self) -> Result<(u64, u64), Error>

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

This method returns the (width, height) number of pixels of the level 0 whole slide image.

This is the same as calling get_level_dimensions(level) with level=0.

Source

pub fn get_level_dimensions<T: Integer + ToPrimitive + Debug + Display + Clone + Copy>( &self, level: T, ) -> Result<(u64, u64), Error>

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

This method returns the (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_level_downsample<T: Integer + Unsigned + ToPrimitive + Debug + Display + Clone + Copy>( &self, level: T, ) -> Result<f64, Error>

Get the downsampling factor of a given level.

Source

pub fn get_best_level_for_downsample<T: Num + ToPrimitive + PartialOrd + Debug + Display + Clone + Copy>( &self, downsample_factor: T, ) -> Result<u32, Error>

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

Source

pub fn read_region<T: Integer + Unsigned + ToPrimitive + Debug + Display + Clone + Copy>( &self, top_left_lvl0_row: T, top_left_lvl0_col: T, level: T, height: T, width: T, ) -> Result<RgbaImage, Error>

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

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

Args: top_left_lvl0_row: Row coordinate (increasing downwards) of top left pixel position top_left_lvl0_col: Column coordinate (increasing to the right) of top left pixel position level: At which level to grab the region from height: Height in pixels of the outputted region width: Width in pixels of the outputted region

Source

pub fn get_properties(&self) -> Result<HashMap<String, String>, Error>

Get a dictionary of properties associated with the current slide

There are some standard properties to every slide, but also a lot of vendor-specific properties. This method returns a HashMap with all key-value pairs of the properties associated with the slide.

Trait Implementations§

Source§

impl Clone for OpenSlide

Source§

fn clone(&self) -> OpenSlide

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Drop for OpenSlide

Source§

fn drop(&mut self)

This method is called when the object in dropped, and tries to close the slide.

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> SetParameter for T

Source§

fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result
where T: Parameter<Self>,

Sets value as a parameter of self.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.