diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2023-12-05 13:49:56 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2023-12-05 14:09:17 -0500 |
commit | c404a0a02915e4f6d329d7667ed30b8519b8a964 (patch) | |
tree | 8ca057be61563c0b7816331951bf28e270207e70 /src/frontier | |
parent | 932ff518e5f70c58e8dc687c00dab2bbdd4bec8d (diff) | |
download | kd-forest-c404a0a02915e4f6d329d7667ed30b8519b8a964.tar.xz |
Move soft deletion into the forest implementationmain
This allows us to filter out deleted items whenever we rebuild a tree.
Diffstat (limited to 'src/frontier')
-rw-r--r-- | src/frontier/image.rs | 4 | ||||
-rw-r--r-- | src/frontier/mean.rs | 10 | ||||
-rw-r--r-- | src/frontier/min.rs | 12 |
3 files changed, 7 insertions, 19 deletions
diff --git a/src/frontier/image.rs b/src/frontier/image.rs index ded0cbe..149a1b0 100644 --- a/src/frontier/image.rs +++ b/src/frontier/image.rs @@ -3,7 +3,7 @@ use super::{Frontier, Pixel, Target}; use crate::color::{ColorSpace, Rgb8}; -use crate::soft::SoftKdTree; +use crate::forest::KdForest; use acap::knn::NearestNeighbors; @@ -12,7 +12,7 @@ use image::RgbImage; /// A [Frontier] that places colors on the closest pixel of a target image. #[derive(Debug)] pub struct ImageFrontier<C> { - nodes: SoftKdTree<Pixel<C>>, + nodes: KdForest<Pixel<C>>, width: u32, height: u32, len: usize, diff --git a/src/frontier/mean.rs b/src/frontier/mean.rs index 30443c9..9ccfe7e 100644 --- a/src/frontier/mean.rs +++ b/src/frontier/mean.rs @@ -3,7 +3,7 @@ use super::{neighbors, Frontier, RcPixel, Target}; use crate::color::{ColorSpace, Rgb8}; -use crate::soft::SoftKdForest; +use crate::forest::KdForest; use acap::knn::NearestNeighbors; @@ -33,7 +33,7 @@ where #[derive(Debug)] pub struct MeanFrontier<C> { pixels: Vec<MeanPixel<C>>, - forest: SoftKdForest<RcPixel<C>>, + forest: KdForest<RcPixel<C>>, width: u32, height: u32, len: usize, @@ -114,12 +114,6 @@ where self.len += pixels.len(); self.forest.extend(pixels); - - if 2 * self.deleted >= self.len { - self.forest.rebuild(); - self.len -= self.deleted; - self.deleted = 0; - } } } diff --git a/src/frontier/min.rs b/src/frontier/min.rs index da08746..2a332e6 100644 --- a/src/frontier/min.rs +++ b/src/frontier/min.rs @@ -3,7 +3,7 @@ use super::{neighbors, Frontier, RcPixel, Target}; use crate::color::{ColorSpace, Rgb8}; -use crate::soft::SoftKdForest; +use crate::forest::KdForest; use acap::knn::NearestNeighbors; @@ -33,7 +33,7 @@ where pub struct MinFrontier<C, R> { rng: R, pixels: Vec<MinPixel<C>>, - forest: SoftKdForest<RcPixel<C>>, + forest: KdForest<RcPixel<C>>, width: u32, height: u32, x0: u32, @@ -57,7 +57,7 @@ where Self { rng, pixels, - forest: SoftKdForest::new(), + forest: KdForest::new(), width, height, x0, @@ -118,12 +118,6 @@ where } } - if 2 * self.deleted >= self.len { - self.forest.rebuild(); - self.len -= self.deleted; - self.deleted = 0; - } - Some((x, y)) } } |