diff --git a/.gitignore b/.gitignore index ddca0b6..083be28 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,4 @@ pkg/ .DS_Store dist/ *.iml -.idea \ No newline at end of file +.idea/ diff --git a/image-processor/src/lib.rs b/image-processor/src/lib.rs index 8b1b41d..e95c154 100644 --- a/image-processor/src/lib.rs +++ b/image-processor/src/lib.rs @@ -1,6 +1,6 @@ +use image::imageops::FilterType; use image::{GenericImage, GenericImageView, Pixel, Rgba, RgbaImage}; use photon_rs::PhotonImage; -use image::imageops::FilterType; mod samples; @@ -19,9 +19,19 @@ pub fn spiegel(photon_image: PhotonImage, median_kernelsize: u32, preview: bool) let i1 = RgbaImage::from_vec(width, height, raw_pixels).unwrap(); let i2 = if preview { - image::imageops::resize(&i1, u32::min(500, width >> 1), u32::min(500, height >> 1), FilterType::Nearest) + image::imageops::resize( + &i1, + u32::min(500, width >> 1), + u32::min(500, height >> 1), + FilterType::Nearest, + ) } else { - image::imageops::resize(&i1, u32::min(500, width), u32::min(500, height), FilterType::Nearest) + image::imageops::resize( + &i1, + u32::min(500, width), + u32::min(500, height), + FilterType::Nearest, + ) }; let mut i3 = imageproc::filter::median_filter(&i2, median_kernelsize, median_kernelsize); let i4 = if !preview { @@ -80,16 +90,16 @@ fn fill( let yy = y % height; dest.unsafe_put_pixel(x, y, sample.unsafe_get_pixel(xx, yy)); src.unsafe_put_pixel(x, y, BLACK); - if x > 1 { + if x > 1 && src.unsafe_get_pixel(x - 1, y) != BLACK { points.push(Coord(x - 1, y)); } - if y > 1 { + if y > 1 && src.unsafe_get_pixel(x, y - 1) != BLACK { points.push(Coord(x, y - 1)); } - if x < src.width() - 1 { + if x < src.width() - 1 && src.unsafe_get_pixel(x + 1, y) != BLACK { points.push(Coord(x + 1, y)); } - if y < src.height() - 1 { + if y < src.height() - 1 && src.unsafe_get_pixel(x, y + 1) != BLACK { points.push(Coord(x, y + 1)); } } diff --git a/index.html b/index.html index 77d6b10..24ac9f0 100644 --- a/index.html +++ b/index.html @@ -27,6 +27,7 @@