[][src]Trait kmeans_colors::Calculate

pub trait Calculate: Sized {
    fn get_closest_centroid(
        buffer: &[Self],
        centroids: &[Self],
        indices: &mut Vec<u8>
    );
fn recalculate_centroids(
        rng: &mut impl Rng,
        buf: &[Self],
        centroids: &mut [Self],
        indices: &[u8]
    );
fn check_loop(centroids: &[Self], old_centroids: &[Self]) -> f32;
fn create_random(rng: &mut impl Rng) -> Self;
fn difference(c1: &Self, c2: &Self) -> f32; }

A trait for enabling k-means calculation of a data type.

Required methods

fn get_closest_centroid(
    buffer: &[Self],
    centroids: &[Self],
    indices: &mut Vec<u8>
)

Find a points's nearest centroid, index the point with that centroid.

fn recalculate_centroids(
    rng: &mut impl Rng,
    buf: &[Self],
    centroids: &mut [Self],
    indices: &[u8]
)

Find the new centroid locations based on the average of the points that correspond to the centroid. If no points correspond, the centroid is re-initialized with a random point.

fn check_loop(centroids: &[Self], old_centroids: &[Self]) -> f32

Calculate the distance metric for convergence comparison.

fn create_random(rng: &mut impl Rng) -> Self

Generate random point.

fn difference(c1: &Self, c2: &Self) -> f32

Calculate the geometric distance between two points, the square root is omitted.

Loading content...

Implementations on Foreign Types

impl<Wp: WhitePoint> Calculate for Lab<Wp>[src]

impl Calculate for Srgb[src]

Loading content...

Implementors

Loading content...