use ndarray::{Array3, Ix3}; use ndarray_vision::core::*; use ndarray_vision::format::netpbm::*; use ndarray_vision::format::*; use ndarray_vision::processing::*; use std::path::{Path, PathBuf}; fn main() { let root = Path::new(env!("CARGO_MANIFEST_DIR")); let cameraman = root.clone().join("images/cameraman.ppm"); println!("{:?}", cameraman); let decoder = PpmDecoder::default(); let image: Image = decoder .decode_file(cameraman) .expect("Couldn't open cameraman.ppm"); let boxkern: Array3 = BoxLinearFilter::build(Ix3(3, 3, 3)).expect("Was unable to construct filter"); let mut image: Image = image.into_type(); image .conv2d_inplace(boxkern.view()) .expect("Poorly sized kernel"); // There's no u8: From so I've done this to hack things let mut cameraman = PathBuf::from(&root); cameraman.push("images/cameramanblur.ppm"); let ppm = PpmEncoder::new_plaintext_encoder(); ppm.encode_file(&image, cameraman) .expect("Unable to encode ppm"); }