From 39c0348c9f98b4dd29bd112a0a2a42faa67c92d4 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Wed, 24 Jun 2020 15:20:02 -0400 Subject: Use the acap nearest neighbors implementation --- src/frontier/min.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/frontier/min.rs') diff --git a/src/frontier/min.rs b/src/frontier/min.rs index 269f3b7..95b3321 100644 --- a/src/frontier/min.rs +++ b/src/frontier/min.rs @@ -1,19 +1,18 @@ //! Minimum selection frontier. -use super::{neighbors, Frontier, Pixel}; +use super::{neighbors, Frontier, RcPixel, Target}; use crate::color::{ColorSpace, Rgb8}; -use crate::metric::soft::SoftKdForest; -use crate::metric::NearestNeighbors; +use crate::soft::SoftKdForest; -use rand::Rng; +use acap::NearestNeighbors; -use std::rc::Rc; +use rand::Rng; /// A pixel on a min frontier. #[derive(Debug)] struct MinPixel { - pixel: Option>>, + pixel: Option>, filled: bool, } @@ -31,7 +30,7 @@ impl MinPixel { pub struct MinFrontier { rng: R, pixels: Vec>, - forest: SoftKdForest>>, + forest: SoftKdForest>, width: u32, height: u32, x0: u32, @@ -94,7 +93,7 @@ impl MinFrontier { return None; } - let rc = Rc::new(Pixel::new(x, y, color)); + let rc = RcPixel::new(x, y, color); pixel.pixel = Some(rc.clone()); pixel.filled = true; @@ -144,7 +143,7 @@ impl Frontier for MinFrontier { let color = C::from(rgb8); let (x, y) = self .forest - .nearest(&color) + .nearest(&Target(color)) .map(|n| n.item.pos) .map(|(x, y)| self.free_neighbor(x, y).unwrap()) .unwrap_or((self.x0, self.y0)); -- cgit v1.2.3