Skip to main content

Slide

Struct Slide 

Source
pub struct Slide { /* private fields */ }
Expand description

Represents a single WSI, along with its metadata.

Implementations§

Source§

impl Slide

Source

pub fn open(path: impl AsRef<Path>) -> Result<Self, WsiError>

Opens a WSI from the specified path and returns a corresponding Slide instance.

§Arguments
  • path - Path to the WSI file.
§Returns

A Result containing a Slide instance on success, or a WsiError on failure.

§Errors

Returns WsiError if the file cannot be opened or the metadata cannot be read.

Source

pub fn path(&self) -> &PathBuf

Returns the path of the WSI.

Source

pub fn metadata(&self) -> &Metadata

Returns a reference to the metadata associated with the WSI.

Source

pub fn level_count(&self) -> usize

Returns the number of pyramid levels in the WSI.

Source

pub fn read_tile_raw( &self, level_idx: usize, tile_x: u32, tile_y: u32, ) -> Result<Vec<u8>, WsiError>

Reads and returns the raw tile bytes at the specified level and coordinates.

Given a level index and tile coordinates (tile_x, tile_y), this function retrieves the corresponding tile bytes from the WSI.

§Arguments
  • level_idx - The index of the pyramid level.
  • tile_x - The x-coordinate of the tile.
  • tile_y - The y-coordinate of the tile.
§Returns

A Result containing a vector of bytes representing the tile on success, or a WsiError on failure.

§Errors

Returns WsiError::LevelIndexOutOfBounds if the specified level index is invalid.

Source

pub fn decode_tile( &self, level_idx: usize, tile_x: u32, tile_y: u32, ) -> Result<Tile, WsiError>

Reads the raw tile bytes at the specified level and coordinates and decodes them into a Tile.

Given a level index and tile coordinates (tile_x, tile_y), this function retrieves the corresponding tile bytes from the WSI, decodes them and returns them in the form of a loaded Tile. This function should preferably be used over read_tile

§Arguments
  • level_idx - The index of the pyramid level.
  • tile_x - The x-coordinate of the tile.
  • tile_y - The y-coordinate of the tile.
§Returns

A Result containing a Tile representing the tile on success, or a WsiError on failure.

§Errors

Returns WsiError::LevelIndexOutOfBounds if the specified level index is invalid.

Source

pub fn tile_coords( &self, level_idx: usize, ) -> Result<impl Iterator<Item = (u32, u32)> + '_, WsiError>

Returns an iterator over the tile coordinates (tile_x, tile_y) for the specified level. The iterator yields tuples of (tile_x, tile_y) for each tile in the specified level, in row-major order.

§Arguments
  • level_idx - The index of the pyramid level.
§Returns

A Result containing an iterator over tile coordinates on success, or a WsiError on failure.

Source

pub fn tiles( &self, level_idx: usize, ) -> Result<impl Iterator<Item = Result<Tile, WsiError>> + '_, WsiError>

Decodes every tile at level_idx and passes each to f, according to options.

Source

pub fn extract<F>( &self, options: &ExtractionOptions, outputs: &SlideOutputs, f: F, ) -> Result<(), WsiError>
where F: Fn(Tile) -> Result<(), WsiError> + Sync,

Decodes every tile at level_idx and passes each to f, according to options.

f must be safe to call concurrently: Parallelism::Parallel invokes it from multiple worker threads at once.

§Errors

Returns WsiError::LevelIndexOutOfBounds if the specified level index is invalid, or WsiError::ThreadPool if a dedicated thread pool could not be built for Parallelism::Parallel with an explicit thread count.

Source

pub fn build_overview_image(&self) -> Result<DynamicImage, WsiError>

Stitches lowest-resolution pyramid level into a single image for use as a thumbnail.

Trait Implementations§

Source§

impl Debug for Slide

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !Freeze for Slide

§

impl RefUnwindSafe for Slide

§

impl Send for Slide

§

impl Sync for Slide

§

impl Unpin for Slide

§

impl UnsafeUnpin for Slide

§

impl UnwindSafe for Slide

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.