summaryrefslogtreecommitdiffstats
path: root/src/frontier/image.rs
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2020-06-24 15:20:02 -0400
committerTavian Barnes <tavianator@tavianator.com>2020-06-24 15:44:14 -0400
commit39c0348c9f98b4dd29bd112a0a2a42faa67c92d4 (patch)
tree6c8ed80bd8cbbb0af79c9ac57bdb39634fa178fd /src/frontier/image.rs
parentadaafdd7043507cbceae65e78c38954e47103b5c (diff)
downloadkd-forest-master.tar.xz
Use the acap nearest neighbors implementationHEADmaster
Diffstat (limited to 'src/frontier/image.rs')
-rw-r--r--src/frontier/image.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/frontier/image.rs b/src/frontier/image.rs
index 5642297..18bf620 100644
--- a/src/frontier/image.rs
+++ b/src/frontier/image.rs
@@ -1,16 +1,17 @@
//! Frontier that targets an image.
-use super::{Frontier, Pixel};
+use super::{Frontier, Pixel, Target};
use crate::color::{ColorSpace, Rgb8};
-use crate::metric::soft::SoftKdTree;
-use crate::metric::NearestNeighbors;
+use crate::soft::SoftKdTree;
+
+use acap::NearestNeighbors;
use image::RgbImage;
/// A [Frontier] that places colors on the closest pixel of a target image.
#[derive(Debug)]
-pub struct ImageFrontier<C: ColorSpace> {
+pub struct ImageFrontier<C> {
nodes: SoftKdTree<Pixel<C>>,
width: u32,
height: u32,
@@ -58,7 +59,7 @@ impl<C: ColorSpace> Frontier for ImageFrontier<C> {
fn place(&mut self, rgb8: Rgb8) -> Option<(u32, u32)> {
let color = C::from(rgb8);
- if let Some(node) = self.nodes.nearest(&color).map(|n| n.item) {
+ if let Some(node) = self.nodes.nearest(&Target(color)).map(|n| n.item) {
let pos = node.pos;
node.delete();