use crate::{EdgeMethod, Image, Result};
#[derive(Debug, Clone, PartialEq)]
pub enum Operation {
UnsharpMask {
radius: f32,
amount: f32,
threshold: u8,
},
HighPassSharpen {
strength: f32,
},
EnhanceEdges {
strength: f32,
method: EdgeMethod,
},
Clarity {
strength: f32,
radius: f32,
},
}
impl Operation {
pub fn name(&self) -> &'static str {
match self {
Operation::UnsharpMask { .. } => "Unsharp Mask",
Operation::HighPassSharpen { .. } => "High-Pass Sharpen",
Operation::EnhanceEdges { .. } => "Edge Enhancement",
Operation::Clarity { .. } => "Clarity",
}
}
pub fn apply(&self, image: Image) -> Result<Image> {
match self {
Operation::UnsharpMask {
radius,
amount,
threshold,
} => image.unsharp_mask(*radius, *amount, *threshold),
Operation::HighPassSharpen { strength } => image.high_pass_sharpen(*strength),
Operation::EnhanceEdges { strength, method } => image.enhance_edges(*strength, *method),
Operation::Clarity { strength, radius } => image.clarity(*strength, *radius),
}
}
}