use ndarray::Array2;
use thiserror::Error;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum StopReason {
SnrBelow,
GradientFlip,
Filled,
}
#[derive(Debug, Clone)]
pub struct GrowthResult {
pub mask: Array2<bool>,
pub stop_reason: StopReason,
pub n_iterations: usize,
}
#[derive(Debug, Error, PartialEq)]
pub enum GrowError {
#[error("seed pixel {seed:?} is out of bounds for data shape {shape:?}")]
SeedOutOfBounds {
seed: (usize, usize),
shape: (usize, usize),
},
#[error("label map shape {label_shape:?} must equal data shape {data_shape:?}")]
LabelShapeMismatch {
label_shape: (usize, usize),
data_shape: (usize, usize),
},
#[error("label.allowed must be non-empty")]
LabelAllowedEmpty,
#[error("seed pixel {seed:?} sits on label {label}, which is not in allowed")]
SeedOnDisallowedLabel { seed: (usize, usize), label: i32 },
#[error("config.check_interval must be >= 1")]
CheckIntervalZero,
#[error("at least one stop criterion (SNR or gradient) must be enabled")]
NoStopCriterion,
#[error("err must be supplied when SNR stop is enabled")]
SnrStopWithoutErr,
#[error("err must not be supplied when SNR stop is disabled")]
ErrWithoutSnrStop,
#[error("err shape {err_shape:?} must equal data shape {data_shape:?}")]
ErrShapeMismatch {
err_shape: (usize, usize),
data_shape: (usize, usize),
},
}