Struct color_quant::NeuQuant [−][src]
pub struct NeuQuant { /* fields omitted */ }
Implementations
impl NeuQuant
[src]
pub fn new(samplefac: i32, colors: usize, pixels: &[u8]) -> Self
[src]
Creates a new neuronal network and trains it with the supplied data.
Pixels are assumed to be in RGBA format.
colors
should be $>=64$. samplefac
determines the faction of
the sample that will be used to train the network. Its value must be in the
range $[1, 30]$. A value of $1$ thus produces the best result but is also
slowest. $10$ is a good compromise between speed and quality.
pub fn init(&mut self, pixels: &[u8])
[src]
Initializes the neuronal network and trains it with the supplied data.
This method gets called by Self::new
.
pub fn map_pixel(&self, pixel: &mut [u8])
[src]
Maps the rgba-pixel in-place to the best-matching color in the color map.
pub fn index_of(&self, pixel: &[u8]) -> usize
[src]
Finds the best-matching index in the color map.
pixel
is assumed to be in RGBA format.
pub fn lookup(&self, idx: usize) -> Option<[u8; 4]>
[src]
Lookup pixel values for color at idx
in the colormap.
pub fn color_map_rgba(&self) -> Vec<u8>
[src]
Returns the RGBA color map calculated from the sample.
pub fn color_map_rgb(&self) -> Vec<u8>
[src]
Returns the RGBA color map calculated from the sample.
Auto Trait Implementations
impl RefUnwindSafe for NeuQuant
impl Send for NeuQuant
impl Sync for NeuQuant
impl Unpin for NeuQuant
impl UnwindSafe for NeuQuant
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,