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
impl OpenSlide
sourcepub fn new(filename: &Path) -> Result<OpenSlide, Error>
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.
sourcepub fn get_level_count(&self) -> Result<u32, Error>
pub fn get_level_count(&self) -> Result<u32, Error>
Get the number of levels in the whole slide image.
sourcepub fn get_level0_dimensions(&self) -> Result<(u64, u64), Error>
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.
sourcepub fn get_level_dimensions<T: Integer + ToPrimitive + Debug + Display + Clone + Copy>(
&self,
level: T
) -> Result<(u64, u64), Error>
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
sourcepub fn get_level_downsample<T: Integer + Unsigned + ToPrimitive + Debug + Display + Clone + Copy>(
&self,
level: T
) -> Result<f64, Error>
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.
sourcepub fn get_best_level_for_downsample<T: Num + ToPrimitive + PartialOrd + Debug + Display + Clone + Copy>(
&self,
downsample_factor: T
) -> Result<u32, Error>
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.
sourcepub 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>
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
sourcepub fn get_properties(&self) -> Result<HashMap<String, String>, Error>
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.