#blur #gaussian #graphics

yanked stackblur

A fast approximation of gaussian blur

0.1.0 May 15, 2021

#20 in #blur

MIT/Apache

17KB
235 lines

stackblur

crates.io docs.rs

Fast gaussian blur approximation.

A Rust implementation of StackBlur by Mario Klingemann. Very fast and accurate gaussian blur approximation. Based off of the Java implementation by Enrique López Mañas, licensed under Apache 2.0.

Notice

stackblur is currently under heavy development, and may contain breaking changes between releases. Releases will be stabilized for 1.0.0.

Usage

use std::num::{NonZeroU8, NonZeroUsize};

use stackblur::blur;

const RED: u32 = 0xffff0000;
const GREEN: u32 = 0xff00ff00;
const BLUE: u32 = 0xff0000ff;

// load your image, u32 RGBA pixels
let mut pixels: Vec<u32> = vec![
    RED, GREEN, GREEN, RED,
    GREEN, RED, BLUE, GREEN,
    GREEN, BLUE, RED, GREEN,
    RED, GREEN, GREEN, RED,
];

// blur!
blur(
    &mut pixels,
    NonZeroUsize::new(4).unwrap(),
    NonZeroUsize::new(4).unwrap(),
    NonZeroU8::new(1).unwrap(),
);

Examples

All examples blurred in both directions with radius 15.

cballs without blur cballs blurred

western without blur western blurred

Add RGBA PNGs to samples/input and run cargo run --release --example samples to see your own!

Coding Style

Obey rustfmt and Rust 2018 conventions, as well as clippy lints.

Contributing

Pull requests are always welcome.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed under the terms of both the MIT License and the Apache License (Version 2.0).

Versioning

This project adheres to Semantic Versioning.

Changes are documented in the Changelog.

See the tags for available releases.

Authors

See the list of contributors.

License

See LICENSE-APACHE and LICENSE-MIT for details.

Acknowledgments

  • Mario Klingemann for the original stackblur aglorithm.
  • Enrique López Mañas for the Java port this code was based off of.
  • Many members of the Rust Discord that assisted with various questions and inspirations.

Want your name here? Contact me or open a PR!

No runtime deps