graph_based_image_segmentation/graph/image_node.rs
1/// Represents a pixel in a video. Each pixel is represented by its
2/// color which is needed to compute the weights between pixels.
3#[derive(Debug, Copy, Clone, Default)]
4pub struct ImageNode {
5 /// The label of the pixel (i.e. the index of the node this node belongs to).
6 pub label: usize,
7 /// Size of node after merging with other nodes.
8 pub n: usize,
9 /// ID of the node.
10 pub id: usize,
11 /// Maximum weight, i.e. the maximum distance in feature space
12 /// of any two connected pixels of this set (see [ImageEdge]).
13 ///
14 /// [ImageEdge]: struct.ImageEdge.html#structfield.w
15 pub max_w: f32,
16}
17
18/// Represents a pixel in a video. Each pixel is represented by its
19/// color which is needed to compute the weights between pixels.
20#[derive(Debug, Copy, Clone, Default)]
21pub struct ImageNodeColor {
22 /// Blue channel.
23 pub b: u8,
24 /// Green channel.
25 pub g: u8,
26 /// Red channel.
27 pub r: u8,
28}
29
30impl ImageNodeColor {
31 #[inline(always)]
32 pub const fn new_bgr(b: u8, g: u8, r: u8) -> Self {
33 Self { b, g, r }
34 }
35}