mod common; use ccvl::*; const OUTER: image::SRGBA = image::SRGBA { r: 0.0, g: 1.0, b: 0.0, a: 1.0, }; const INNER: image::SRGBA = image::SRGBA { r: 0.0, g: 0.0, b: 1.0, a: 1.0, }; fn main() -> std::process::ExitCode { common::process_image(|mut img| { let greyscale = img.map(|p| image::Luminance::from(p)); let thresholded = filter::threshold_auto(greyscale); let contours = contour::find(thresholded); for contour in contours { let n = contour.vertices.len(); for i in 0..n { let (x0, y0) = contour.vertices[i]; let (x1, y1) = contour.vertices[(i + 1) % n]; draw::line(x0, y0, x1, y1, &mut img, match contour.kind { contour::Kind::Outer => OUTER, contour::Kind::Inner => INNER, }); } } img }) }