graph_based_image_segmentation/segmentation/
node_merging.rs

1use crate::graph::{ImageEdge, ImageNode};
2use std::cell::Cell;
3
4/// The magic part of the graph segmentation, i.e. s given two nodes decide
5/// whether to add an edge between them (i.e. merge the corresponding segments).
6/// See the paper by Felzenswalb and Huttenlocher for details.
7pub trait NodeMerging {
8    /// Decide whether to merge the two segments corresponding to the given nodes or not.
9    ///
10    /// # Arguments
11    ///
12    /// * `s_n` - Node representing the first segment.
13    /// * `s_m` - Node representing the second segment.
14    /// * `e` - The edge between the two segments.
15    ///
16    /// # Returns
17    ///
18    /// `true` if merge
19    // TODO: Rename the method.
20    // TODO: Update the documentation on the return value.
21    fn should_merge(&self, s_n: &Cell<ImageNode>, s_m: &Cell<ImageNode>, e: &ImageEdge) -> bool;
22}