Expand description
§wsi-rs
wsi-rs is a whole-slide image reader focused on deterministic public
APIs for TIFF-family WSI, DICOM VL WSI, selected vendor containers, and
explicit failure behavior for unsupported inputs.
§Quick Start
Read a region in level coordinates as an image::RgbaImage:
use wsi_rs::{LevelIdx, RegionRequest, SceneId, SeriesId, Slide};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let slide = Slide::open("sample.svs")?;
let region = RegionRequest::builder(SceneId::new(0), SeriesId::new(0), LevelIdx::new(0))
.origin_px((0, 0))
.size_px((1024, 1024))
.build()?;
let image = slide.read_region_rgba(®ion)?;
image.save("region.png")?;
Ok(())
}§Tile Reads
Use tile-level APIs for viewers, caches, benchmarks, and workflows that need exact tile coordinates:
use wsi_rs::{LevelIdx, SceneId, SeriesId, Slide, TileOutputPreference, TilePixels, TileRequest};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let slide = Slide::open("sample.svs")?;
let request = TileRequest::builder(SceneId::new(0), SeriesId::new(0), LevelIdx::new(0))
.tile(0, 0)
.build()?;
match slide.read_tile(&request, TileOutputPreference::cpu())? {
TilePixels::Cpu(tile) => {
println!("{}x{} tile", tile.width(), tile.height());
}
TilePixels::Device(_) => unreachable!("CPU output was requested"),
_ => unreachable!("CPU output was requested"),
}
Ok(())
}Re-exports§
pub use error::WsiError;pub use properties::Properties;
Modules§
- error
- output
- prelude
- Common imports for applications using
wsi-rs. - properties
Structs§
- Associated
Image - Metadata for an associated image (label, macro, thumbnail).
- Axes
Shape - Axis extents beyond x/y. Default is 2D (z=1, c=1, t=1).
- Cache
Config - Channel
Info - CpuTile
- Generic decoded pixel buffer.
- Dataset
- A whole-slide image file (or set of files for DICOM).
- Dataset
Id - Unique identity for cache keying. 128-bit to avoid truncation collisions.
- Decode
Execution Options - Decode
Route Decision - Device
Output Context - Display
Window - Windowing parameters for high-dynamic-range display conversion.
- Format
Registry - IccProfile
Key - Identifies the scene and series an ICC profile applies to.
- Level
- One resolution level in a pyramid.
- Level
Idx - Stable index into
Series::levels. - Plane
Idx - Plane index for multi-dimensional axes (z/c/t).
- Plane
Selection - Selects a z/c/t plane. Default is (0,0,0) for plain 2D reads.
- Probe
Result - Result from a cheap file-format probe.
- RawCompressed
Tile - Raw compressed tile bytes that can be copied into another container without decoding pixels.
- RawCompressed
Tile Builder - Builder for
RawCompressedTilethat names payload metadata fields. - Region
Request - A region request — used by Slide (public API), not by backends.
- Region
Request Builder - Builder for
RegionRequest. - Scene
- A distinct scan region within a dataset.
- SceneId
- Stable index into
Dataset::scenes. - Series
- A coherent image pyramid sharing the same axes and sample type.
- Series
Id - Stable index into
Scene::series. - Slide
- Top-level handle. Owns the SlideReader + shared cache.
- Slide
Open Options - Slide
Read Context - Source
IccProfile - Source ICC profile bytes plus the normalized key and extraction provenance.
- Source
IccProfile Conflict - Conflict returned when a source ICC profile would make the legacy map ambiguous.
- Source
IccProfile Key - Normalized dataset location for an ICC profile found in source metadata.
- Svcache
Tile Selection - Tile
Entry - Per-tile position and size in an Irregular layout.
- TileHit
- Result of tile intersection computation.
- Tile
Request - A single-tile request — the backend primitive.
- Tile
Request Builder - Builder for
TileRequest. - Tile
View Request - A viewer/display-tile request.
- Tile
View Request Builder - Builder for
TileViewRequest.
Enums§
- Color
Space - Declared color model.
- Compression
- Compression codec for TIFF tile/strip data.
- CpuTile
Data - Typed, aligned sample storage.
- CpuTile
Layout - Whether channel samples are interleaved or planar.
- Decode
Route - Device
Tile - Renderer-uploadable device payload. Real payload fields land in Phase 5.
- Encoded
Tile Photometric Interpretation - Photometric interpretation for an encoded tile payload.
- IccProfile
Provenance - Provenance for ICC profile bytes extracted from source metadata.
- Level
Source Kind - Whether a pyramid level is backed by source pixels or generated by the reader.
- Output
Backend Request - Pixel
Format - Concrete pixel format for decoded CPU and device-resident surfaces.
- Probe
Confidence - RawCompressed
Tile Build Error - Error returned by
RawCompressedTileBuilderwhen required metadata is missing. - Request
Build Error - Error returned by public request builders when a required field is missing.
- Sample
Type - Svcache
Policy - Tile
Codec Kind - Tile
Layout - How tiles are organized at a given level.
- Tile
Output Preference - Tile
Pixels - Output payload from
SlideReader::read_tilesand friends.
Traits§
- Dataset
Reader - Opens a file and returns a SlideReader.
- Format
Probe - Detects whether a file is a given format. Fast, no full parse.
- Slide
Reader - Phase-2 read interface.