pub struct LazyMeasurementStack { /* private fields */ }Expand description
File-backed measurement frames decoded, preprocessed, and cached on access.
Construction reads image headers to validate grayscale type and dimensions, but does not decode measurement pixel buffers. A bounded thread-safe LRU cache keeps the working set out of core while returned shared frame handles remain stable. Cache byte accounting covers frame pixel buffers retained by the cache, not handles that callers keep alive after eviction.
Frame decoding occurs without holding the cache mutex, so callers can read
different uncached frames concurrently; a second lookup makes concurrent
reads of the same frame converge on one cached handle. A poisoned cache is
treated as corrupted state: Self::frame returns an error rather than
reusing it. The infallible cache-statistics accessors report zero after
poisoning because they cannot expose that error; rebuild the stack before
using it again.
Implementations§
Source§impl LazyMeasurementStack
impl LazyMeasurementStack
pub fn from_image_files<P: AsRef<Path>>( paths: &[P], frame_metadata: Vec<FrameMetadata>, ) -> Result<Self>
Sourcepub fn from_tiff_stack(
path: impl AsRef<Path>,
frame_metadata: Vec<FrameMetadata>,
) -> Result<Self>
pub fn from_tiff_stack( path: impl AsRef<Path>, frame_metadata: Vec<FrameMetadata>, ) -> Result<Self>
Opens a multipage TIFF lazily. Page headers are validated up front, but each page’s pixels are decoded only when that frame is requested.
Sourcepub fn from_manifest(path: impl AsRef<Path>) -> Result<Self>
pub fn from_manifest(path: impl AsRef<Path>) -> Result<Self>
Loads a manifest while leaving measurement frames file-backed. Small shared correction images and optional per-frame backgrounds/masks are loaded once; configured corrections are applied during frame decoding.
pub fn from_manifest_definition( manifest: MeasurementSpec, base_directory: impl AsRef<Path>, ) -> Result<Self>
pub fn with_dark_frame(self, dark: Vec<f64>) -> Result<Self>
pub fn with_flat_field(self, flat: Vec<f64>) -> Result<Self>
pub fn with_background(self, background: Vec<f64>) -> Result<Self>
pub fn with_masks(self, masks: Vec<u8>) -> Result<Self>
pub fn normalize_exposure(self) -> Self
pub fn clamp_negative(self) -> Self
Sourcepub fn with_preprocessing(
self,
preprocessing: PreprocessingConfig,
) -> Result<Self>
pub fn with_preprocessing( self, preprocessing: PreprocessingConfig, ) -> Result<Self>
Replaces the preprocessing flags. Required correction arrays must have already been supplied through the corresponding builder.
Sourcepub fn with_cache_capacity(self, capacity: usize) -> Result<Self>
pub fn with_cache_capacity(self, capacity: usize) -> Result<Self>
Sets the maximum decoded frames retained in memory. The default is one.
Sourcepub fn with_cache_byte_capacity(self, capacity: usize) -> Result<Self>
pub fn with_cache_byte_capacity(self, capacity: usize) -> Result<Self>
Sets a second cache limit in bytes. It must fit at least one decoded
f64 frame. Count and byte limits are enforced simultaneously.
pub fn frame_count(&self) -> usize
pub fn image_shape(&self) -> (usize, usize)
pub fn frame_len(&self) -> usize
pub fn frame_metadata(&self) -> &[FrameMetadata]
pub fn preprocessing(&self) -> &PreprocessingConfig
Sourcepub fn paths(&self) -> &[PathBuf]
pub fn paths(&self) -> &[PathBuf]
Returns one path per frame. Multipage TIFF frames therefore repeat the stack path and can be distinguished by their metadata labels.