[−][src]Struct dither::ditherer::Ditherer
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]
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]
P: Add<Output = P> + Clone + Default,
P: Mul<f64, Output = P> + Div<f64, Output = P>,
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> PartialEq<Ditherer<'a>> for Ditherer<'a>
[src]
fn eq(&self, other: &Self) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<'a> Default for Ditherer<'a>
[src]
impl<'a> Clone for Ditherer<'a>
[src]
fn clone(&self) -> Ditherer<'a>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<'a> Eq for Ditherer<'a>
[src]
impl<'a> Display for Ditherer<'a>
[src]
impl<'a> Debug for Ditherer<'a>
[src]
impl FromStr for Ditherer<'static>
[src]
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> SetParameter for T
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
T: Parameter<Self>,
Sets value
as a parameter of self
.