Skip to content

Commit 688d93f

Browse files
committed
API docs
1 parent 8a7bcf7 commit 688d93f

File tree

7 files changed

+31
-4
lines changed

7 files changed

+31
-4
lines changed

visionmagic/src/aggregation.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//! Processor to remove small clusters by merging into larger ones
12
use std::collections::HashSet;
23
use visioncortex::{Color, ColorImage};
34
use visioncortex::color_clusters::Clusters;
@@ -14,12 +15,16 @@ pub struct Processor {
1415
counter: usize,
1516
}
1617

18+
/// [`Clusters`]
1719
pub type Input = Clusters;
1820

21+
/// [`ColorImage`]
1922
pub type Output = ColorImage;
2023

2124
pub struct Params {
25+
/// Allowed color difference between shapes in same aggregate
2226
pub deviation: f64,
27+
/// Minimum patch size in area
2328
pub min_size: u32,
2429
}
2530

@@ -29,9 +34,9 @@ struct Aggregate {
2934
}
3035

3136
#[derive(Copy, Clone, Default, Eq, Ord, Hash, PartialEq, PartialOrd)]
32-
pub struct AggregateIndex(pub usize);
37+
struct AggregateIndex(pub usize);
3338

34-
pub const ZERO: AggregateIndex = AggregateIndex(0);
39+
const ZERO: AggregateIndex = AggregateIndex(0);
3540

3641
impl Default for Params {
3742
fn default() -> Self {
@@ -149,7 +154,7 @@ impl Processor {
149154
&mut self.aggregates[index.0 as usize]
150155
}
151156

152-
pub fn neighbours_of(&self, myselfi: AggregateIndex) -> Vec<AggregateIndex> {
157+
fn neighbours_of(&self, myselfi: AggregateIndex) -> Vec<AggregateIndex> {
153158
let myself = self.get_agg(myselfi);
154159
let mut neighbours = HashSet::new();
155160

visionmagic/src/cluster_stat.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//! Processor to calculate color statistic on set of clusters
12
use visioncortex::{ColorStat, ColorStatBuilder};
23
use visioncortex::color_clusters::Clusters;
34
use crate::pipeline::Processor as ProcessorTrait;
@@ -10,8 +11,10 @@ pub struct Processor {
1011
counter: usize,
1112
}
1213

14+
/// [`Clusters`]
1315
pub type Input = Clusters;
1416

17+
/// [`ColorStat`]
1518
pub type Output = ColorStat;
1619

1720
#[derive(Default)]

visionmagic/src/clustering.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//! Processor to perform clustering & hierarchical clustering on an image
12
use visioncortex::ColorImage;
23
use visioncortex::color_clusters::{Clusters, IncrementalBuilder, Runner, RunnerConfig, HIERARCHICAL_MAX};
34
use crate::pipeline::Processor as ProcessorTrait;
@@ -8,12 +9,16 @@ pub struct Processor {
89
builder: Option<IncrementalBuilder>,
910
}
1011

12+
/// [`ColorImage`]
1113
pub type Input = ColorImage;
1214

15+
/// [`Clusters`]
1316
pub type Output = Clusters;
1417

1518
pub struct Params {
19+
/// Valid range is 1~256. More levels means finer gradient
1620
pub color_levels: u32,
21+
/// Perform hierarchical clustering up to this size (area)
1722
pub hierarchical: u32,
1823
}
1924

visionmagic/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
//! Collection of vision & graphics algorithms
12
pub use visioncortex;
23

34
pub mod aggregation;
45
pub mod cluster_stat;
56
pub mod clustering;
6-
pub mod pipeline;
7+
mod pipeline;
78
pub mod segmentation;
89
pub mod simplification;
910

visionmagic/src/pipeline.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
/// Processor is an element of an image processing pipeline
12
pub trait Processor {
23

4+
/// Type definition of input
35
type Input;
6+
/// Type definition of output
47
type Output;
8+
/// Type definition of parameters
59
type Params;
610

711
/// Create a new Processor instance

visionmagic/src/segmentation.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//! Processor to group clusters together by the disjoint set algorithm
12
use std::collections::HashMap;
23
use visioncortex::{Color, ColorImage, ColorSum};
34
use visioncortex::color_clusters::{Cluster, Clusters, ClusterIndex};
@@ -12,12 +13,15 @@ pub struct Processor {
1213
counter: usize,
1314
}
1415

16+
/// [`Clusters`]
1517
pub type Input = Clusters;
1618

19+
/// [`ColorImage`]
1720
pub type Output = ColorImage;
1821

1922
#[derive(Default)]
2023
pub struct Params {
24+
/// Allowed color difference between shapes in same set
2125
pub deviation: f64,
2226
}
2327

visionmagic/src/simplification.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//! Processor to simplify an image by pruning the image tree
12
use visioncortex::{Color, CompoundPath, PathSimplifyMode};
23
use visioncortex::color_clusters::{Cluster, Clusters, ClustersView};
34
use crate::pipeline::Processor as ProcessorTrait;
@@ -11,8 +12,10 @@ pub struct Processor {
1112
stop: usize,
1213
}
1314

15+
/// [`Clusters`]
1416
pub type Input = Clusters;
1517

18+
/// [`CompoundPath`] with [`Color`]
1619
pub type Output = Vec<OutputUnit>;
1720

1821
pub struct OutputUnit {
@@ -21,7 +24,9 @@ pub struct OutputUnit {
2124
}
2225

2326
pub struct Params {
27+
/// Valid range is 0~65535. Ratio of how many nodes we retain from the image tree
2428
pub fidelity: u32,
29+
/// Valid range is 0~65535. Ratio of how many points we use to outline each shape
2530
pub shape_details: u32,
2631
}
2732

0 commit comments

Comments
 (0)