mod detection;
mod removal;
pub use detection::{CloudDetector, CloudMask};
pub use removal::CloudRemover;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CloudConfig {
pub confidence_threshold: f32,
pub dilation_radius: usize,
pub erosion_radius: usize,
pub band_indices: Vec<usize>,
pub normalization_mean: Vec<f32>,
pub normalization_std: Vec<f32>,
pub use_temporal: bool,
pub blend_alpha: f32,
}
impl CloudConfig {
#[must_use]
pub fn sentinel2() -> Self {
Self {
confidence_threshold: 0.5,
dilation_radius: 5,
erosion_radius: 2,
band_indices: vec![1, 2, 3, 7, 10, 11],
normalization_mean: vec![0.1340, 0.1447, 0.1374, 0.2982, 0.2035, 0.1416],
normalization_std: vec![0.0356, 0.0390, 0.0484, 0.0651, 0.0717, 0.0746],
use_temporal: false,
blend_alpha: 0.8,
}
}
#[must_use]
pub fn landsat() -> Self {
Self {
confidence_threshold: 0.5,
dilation_radius: 5,
erosion_radius: 2,
band_indices: vec![1, 2, 3, 4, 5, 6],
normalization_mean: vec![0.1320, 0.1450, 0.1380, 0.2950, 0.2000, 0.1400],
normalization_std: vec![0.0350, 0.0400, 0.0480, 0.0650, 0.0720, 0.0750],
use_temporal: false,
blend_alpha: 0.8,
}
}
}
impl Default for CloudConfig {
fn default() -> Self {
Self::sentinel2()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_sentinel2_config() {
let config = CloudConfig::sentinel2();
assert_eq!(config.band_indices.len(), 6);
assert_eq!(config.confidence_threshold, 0.5);
}
#[test]
fn test_landsat_config() {
let config = CloudConfig::landsat();
assert_eq!(config.band_indices.len(), 6);
assert!(config.dilation_radius > 0);
}
}