Struct exoquant::Histogram [] [src]

pub struct Histogram {
    // some fields omitted
}

A histogram that counts the number of times each color occurs in the input image data.

The Histogram is used to describe the color distribution of the input image to the quantization process. Histogram implements both Extend<Color> and FromIterator<Color>, so you can either create an empty instance using Histogram::new() and fill it width histogram.extend(iter), or just create from an Iterator<Color> using iter.collect().

The Histogram::new(), histogram.extend(...) method is useful when you want to create one palette for multiple distinct images, multiple frames of a GIF animation, etc.

Examples

let mut histogram = Histogram::new();
histogram.extend(image.pixels.iter().cloned());
let histogram: Histogram = image.pixels.iter().cloned().collect();

Methods

impl Histogram
[src]

fn new() -> Histogram

Returns a new, empty Histogram.

fn to_color_counts(&self, colorspace: &ColorSpace) -> Vec<ColorCount>

Converts the rgba8 Histogram to a Vec of ColorCount in quantization color space.

Mostly used internally.

fn iter<'a>(&'a self) -> Box<Iterator<Item=(&Color, &usize)> + 'a>

Returns an iterator over the histogram data.

Trait Implementations

impl Extend<Color> for Histogram
[src]

fn extend<T>(&mut self, iter: T) where T: IntoIterator<Item=Color>

Extends a collection with the contents of an iterator. Read more

impl FromIterator<Color> for Histogram
[src]

fn from_iter<T>(iter: T) -> Self where T: IntoIterator<Item=Color>

Creates a value from an iterator. Read more