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

pub struct Ditherer<'a> {
    pub div: f64,
    pub offsets: &'a [(isize, isize, f64)],
    pub name: Option<&'a str>,
}

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:

  • [[0.0, 0.0, 43.75],`
  • [43.75, 31.25, 6.25]]`

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

Fields

div: f64

the divisor for the spilled error. see the third element of [Ditherer.offsets]

offsets: &'a [(isize, isize, f64)]

offsets represents a triplet (dx, dy, mul).

name: Option<&'a str>

the name of the ditherer, for debug output

Methods

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

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

Trait Implementations

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> Clone for Ditherer<'a>[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

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

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests for !=.

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

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

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

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

impl FromStr for Ditherer<'static>[src]

type Err = ErrorUnknownDitherer

The associated error which can be returned from parsing.

Auto Trait Implementations

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

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

Blanket Implementations

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

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

impl<T> From for T[src]

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

type Owned = T

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

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

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

The type returned in the event of a conversion error.

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

impl<T> SetParameter for T

fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
    T: Parameter<Self>, 

Sets value as a parameter of self.