graph-based-image-segmentation 0.2.1

An implementation of graph-based image segmentation algorithms based on superpixels.
Documentation
/// Represents a pixel in a video. Each pixel is represented by its
/// color which is needed to compute the weights between pixels.
#[derive(Debug, Copy, Clone, Default)]
pub struct ImageNode {
    /// The label of the pixel (i.e. the index of the node this node belongs to).
    pub label: usize,
    /// Size of node after merging with other nodes.
    pub n: usize,
    /// ID of the node.
    pub id: usize,
    /// Maximum weight, i.e. the maximum distance in feature space
    /// of any two connected pixels of this set (see [ImageEdge]).
    ///
    /// [ImageEdge]: struct.ImageEdge.html#structfield.w
    pub max_w: f32,
}

/// Represents a pixel in a video. Each pixel is represented by its
/// color which is needed to compute the weights between pixels.
#[derive(Debug, Copy, Clone, Default)]
pub struct ImageNodeColor {
    /// Blue channel.
    pub b: u8,
    /// Green channel.
    pub g: u8,
    /// Red channel.
    pub r: u8,
}

impl ImageNodeColor {
    #[inline(always)]
    pub const fn new_bgr(b: u8, g: u8, r: u8) -> Self {
        Self { b, g, r }
    }
}