diff options
Diffstat (limited to 'src/analysis.rs')
-rw-r--r-- | src/analysis.rs | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/src/analysis.rs b/src/analysis.rs index e22408b..aabe4e5 100644 --- a/src/analysis.rs +++ b/src/analysis.rs @@ -3,22 +3,22 @@ use crate::{LabelFormat,LabelU16}; use avl_tree::*; #[derive(Debug)] -struct Data { - label: u16, - area: usize, - perimeter: usize, - cell_cell: usize, - cell_tissue: usize, +pub struct Data { + pub label: u16, + pub area: usize, + pub perimeter: usize, + pub neighboring: usize, + pub non_neighboring: usize, } impl Data { - const fn new(label: u16, area: usize, perimeter: usize, cell_cell: usize, cell_tissue: usize) -> Self { + const fn new(label: u16, area: usize, perimeter: usize, neighboring: usize, non_neighboring: usize) -> Self { Self { label, area, perimeter, - cell_cell, - cell_tissue, + neighboring, + non_neighboring, } } } @@ -33,7 +33,7 @@ fn any(a: &[bool]) -> bool { } impl LabelFormat<u16> { - fn get_tree(&self) -> AVLTree<u16, Data> { + pub fn get_tree(&self) -> AVLTree<u16, Data> { let mut avt = avl_tree::AVLTree::<u16, Data>::new(); for y in 0..self.height { for x in 0..self.width { @@ -52,8 +52,8 @@ impl LabelFormat<u16> { Some(data) => { new_data.area = data.area; new_data.perimeter = data.perimeter; - new_data.cell_cell = data.cell_cell; - new_data.cell_tissue = data.cell_tissue; + new_data.neighboring = data.neighboring; + new_data.non_neighboring = data.non_neighboring; }, None => { }, @@ -70,29 +70,29 @@ impl LabelFormat<u16> { None => false, }); let add_perimeter = any(&perimeter_slice); - let cell_cell_slice = neighbors.map(|x| + let neighboring_slice = neighbors.map(|x| match x { Some(y) => (y != new_data.label) && (!y.is_zero()), None => false, }); - let add_cell_cell = any(&cell_cell_slice); - let cell_tissue_slice = neighbors.map(|x| + let add_neighboring = any(&neighboring_slice); + let non_neighboring_slice = neighbors.map(|x| match x { Some(y) => y.is_zero(), None => false, }); - let add_cell_tissue = any(&cell_tissue_slice); + let add_non_neighboring = any(&non_neighboring_slice); // Always increase area new_data.area += 1; // Increase perimeter if there is a neighbor that is not the same cell if add_perimeter { new_data.perimeter += 1; } - if add_cell_tissue { - new_data.cell_tissue += 1; + if add_non_neighboring { + new_data.non_neighboring += 1; } - if add_cell_cell { - new_data.cell_cell += 1; + if add_neighboring { + new_data.neighboring += 1; } avt.insert(key, new_data); } |