bokeh 0.1.0

A Rust implementation of image-blurring, focussing on disc-shaped kernels to produce a bokeh lens-effect.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use bokeh::{params::*, Blur};
use image::{io::Reader as ImageReader, GenericImageView};

fn main() {
    let input_path = "inputs/M35.jpg";
    let output_path = "output.png";

    let mut img = ImageReader::open(input_path).unwrap().decode().unwrap();
    let (x, y) = img.dimensions();
    let l = (x * y) as usize;
    let mut mask = vec![true; l / 2];
    mask.extend_from_slice(&vec![false; l / 2]);
    img.bokeh_blur_with_mask(&mask, 10.0, &KERNEL9_PARAM_SET, 3.0);
    img.save(output_path).unwrap();
}