#image-processing #dither #dithering #ordered #palette #capabilities #bayer

bin+lib dithord

Provides capabilities for monochromatic Bayer ordered dithering on images

7 unstable releases (3 breaking)

0.4.1 Apr 2, 2024
0.4.0 Apr 2, 2024
0.3.0 Jan 21, 2024
0.2.0 Jan 14, 2024
0.1.2 Jan 14, 2024

#315 in Images

Download history 1/week @ 2024-01-01 17/week @ 2024-01-08 6/week @ 2024-01-15 32/week @ 2024-02-19 3/week @ 2024-02-26 16/week @ 2024-03-11 274/week @ 2024-04-01

290 downloads per month

MIT/Apache

15KB
172 lines

dithord: Bayer ordered dithering crate

Crates.io Version

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:

image image

Currently only monochromatic dithering is supported, but support for arbitrary palettes could be considered as a feature.

Add to Project

cargo add dithord

Usage

This crate provides the OrderedDither trait which is implemented for image::DynamicImage, along with a ThresholdMap struct for generating and storing the Bayer matrix.

Example

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);
}

Using standalone

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

Dependencies

~13MB
~65K SLoC