Crates.io | dithord |
lib.rs | dithord |
version | 0.4.1 |
source | src |
created_at | 2024-01-05 09:37:22.977346 |
updated_at | 2024-04-02 04:26:36.615795 |
description | Provides capabilities for monochromatic Bayer ordered dithering on images. |
homepage | |
repository | https://github.com/exvacuum/dithord |
max_upload_size | |
id | 1089528 |
size | 43,551 |
This crate provides functionality which allows for monochromatic ordered dithering using a Bayer threshold matrix. This method of dithering is less accurate than others but is fast and visually appealing.
Example of level 2 dithering using this crate:
Currently only monochromatic dithering is supported, but support for arbitrary palettes could be considered as a feature.
cargo add dithord
This crate provides the OrderedDither
trait which is implemented for image::DynamicImage
, along with a ThresholdMap
struct for generating and storing the Bayer matrix.
use dithord::{ThresholdMap, OrderedDither};
use image::{io::Reader};
fn main() {
let mut image = Reader::open("example.png").unwrap().decode().unwrap();
// Generate level 2 (8x8) threshold map
let map = threshold_map::ThresholdMap::level(2);
// Apply dither
image = image.ordered_dither(map);
}
This crate provides a standalone binary for dithering images from the command line. It can be installed using cargo:
cargo install dithord --features=cli
The binary can then be used to dither images from the command line:
dithord input.png output.exr --level 2