[−][src]Trait kmeans_colors::Calculate
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>
)
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]
)
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.
Implementations on Foreign Types
impl<Wp: WhitePoint> Calculate for Lab<Wp>
[src]
fn get_closest_centroid(
lab: &[Lab<Wp>],
centroids: &[Lab<Wp>],
indices: &mut Vec<u8>
)
[src]
lab: &[Lab<Wp>],
centroids: &[Lab<Wp>],
indices: &mut Vec<u8>
)
fn recalculate_centroids(
rng: &mut impl Rng,
buf: &[Lab<Wp>],
centroids: &mut [Lab<Wp>],
indices: &[u8]
)
[src]
rng: &mut impl Rng,
buf: &[Lab<Wp>],
centroids: &mut [Lab<Wp>],
indices: &[u8]
)
fn check_loop(centroids: &[Lab<Wp>], old_centroids: &[Lab<Wp>]) -> f32
[src]
fn create_random(rng: &mut impl Rng) -> Lab<Wp>
[src]
fn difference(c1: &Lab<Wp>, c2: &Lab<Wp>) -> f32
[src]
impl Calculate for Srgb
[src]
fn get_closest_centroid(rgb: &[Srgb], centroids: &[Srgb], indices: &mut Vec<u8>)
[src]
fn recalculate_centroids(
rng: &mut impl Rng,
buf: &[Srgb],
centroids: &mut [Srgb],
indices: &[u8]
)
[src]
rng: &mut impl Rng,
buf: &[Srgb],
centroids: &mut [Srgb],
indices: &[u8]
)