#blur #gaussian #linear-time #image

gaussian_blur

线性时间的高斯模糊

2 个版本

0.1.1 2021年5月20日
0.1.0 2021年5月20日

#669 in 图像

Unlicense/MIT

6KB
87

使用示例(与 image 结合使用)

use image::{io::Reader, DynamicImage, ImageBuffer, ImageOutputFormat};
let kernel: [usize; 15] = [2, 5, 9, 14, 21, 27, 32, 34, 32, 27, 21, 14, 9, 5, 2];
let img = Reader::open("railway.jpg")?.decode()?.to_rgb8();
let (width, height) = (img.width() as usize, img.height() as usize);
let raw = img.into_raw();
let (raw, width, height) = blur(height, width, kernel, raw);
let img = DynamicImage::ImageRgb8(ImageBuffer::from_raw(width as u32, height as u32, raw).unwrap());
let mut writer = File::create("out.png").unwrap();
img.write_to(&mut writer, ImageOutputFormat::Png).unwrap();

许可证

双许可,Unlicense 和 MIT 许可证。

无运行时依赖