Struct dither::ditherer::Ditherer[][src]

pub struct Ditherer<'a> { /* fields omitted */ }

A type of Dither. See the documentation for the constants (i.e, ATKINSON) for the dither matrices themselves. A ditherer carries error from quantiation to nearby pixels after dividing by div and multiplying by the given scalar in offset; “spreading” the error, eg, take floyd-steinberg dithering: div=16

  • . x 7
  • 7 5 1

Suppose we have an grayscale image where the f64 pixel “p”“ at (x=3, y=0) is 100., and we quantize to black (0.0) and white(255.0) The ditherer sets p=0 and has a carried error of 100. The spread error is then:

  • . ---- . --- 43.75
  • 43.75 31.25 6.25

See tanner helland’s excellent writeup on dithering algorithms for details.

Implementations

impl<'a> Ditherer<'a>[src]

pub const fn new(div: f64, offsets: &'a [(isize, isize, f64)]) -> Self[src]

Trait Implementations

impl<'a> Clone for Ditherer<'a>[src]

impl<'a> Debug for Ditherer<'a>[src]

impl<'a> Default for Ditherer<'a>[src]

impl<'a> Display for Ditherer<'a>[src]

impl<'a, P> Dither<P> for Ditherer<'a> where
    P: Add<Output = P> + Clone + Default,
    P: Mul<f64, Output = P> + Div<f64, Output = P>, 
[src]

fn dither(&self, img: Img<P>, quantize: impl FnMut(P) -> (P, P)) -> Img<P>[src]

dither an image using the specified offsets and divisor. P is the type of pixel; in practice, it is either f64 or [RGB<f64]

impl<'a> Eq for Ditherer<'a>[src]

impl FromStr for Ditherer<'static>[src]

type Err = ErrorUnknownDitherer

The associated error which can be returned from parsing.

impl<'a> PartialEq<Ditherer<'a>> for Ditherer<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for Ditherer<'a>

impl<'a> Send for Ditherer<'a>

impl<'a> Sync for Ditherer<'a>

impl<'a> Unpin for Ditherer<'a>

impl<'a> UnwindSafe for Ditherer<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<Q, K> Equivalent<K> for Q where
    Q: Eq + ?Sized,
    K: Borrow<Q> + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.