Trait exoquant::optimizer::Optimizer [] [src]

pub trait Optimizer {
    fn step(&self, colors: Vec<Colorf>, histogram: &[ColorCount]) -> Vec<Colorf>;

    fn optimize_palette(
        &self,
        colorspace: &ColorSpace,
        palette: &[Color],
        histogram: &Histogram,
        num_iterations: usize
    ) -> Vec<Color> { ... } fn is_noop(&self) -> bool { ... } }

An interface for K-Means optimizers.

Required Methods

Do one K-Means optimization step and return colors that better represent the histogram.

This is the one function custom implementations have to provide.

Provided Methods

Optimize a given palette with a number of K-Means iteration.

Examples:

let palette = Quantizer::create_palette(&histogram, &colorspace, 256);
let palette = optimizer::KMeans.optimize_palette(&colorspace, &palette,
  &histogram, 16);

Returns whether this Optimizer is a No-op implementation.

This is used to shortcut some functions that take an Optimizer as a paramter if the Optimizer won't do anything anyway.

Implementors