pub trait Watershed<T = ()> {
    // Required methods
    fn transform(
        &self,
        input: ArrayView2<'_, u8>,
        seeds: &[(usize, usize)]
    ) -> Array2<usize>;
    fn transform_with_hook(
        &self,
        input: ArrayView2<'_, u8>,
        seeds: &[(usize, usize)]
    ) -> Vec<T>;
    fn transform_to_list(
        &self,
        input: ArrayView2<'_, u8>,
        seeds: &[(usize, usize)]
    ) -> Vec<(u8, Vec<usize>)>;
    fn transform_history(
        &self,
        input: ArrayView2<'_, u8>,
        seeds: &[(usize, usize)]
    ) -> Vec<(u8, Array2<usize>)>;
}
Expand description

Actual trait for performing the watershed transform. It is implemented in different ways by different versions of the algorithm. This trait is dyn-safe, which means that trait objects may be constructed from it.

Required Methods§

source

fn transform( &self, input: ArrayView2<'_, u8>, seeds: &[(usize, usize)] ) -> Array2<usize>

Returns watershed transform of input image.

source

fn transform_with_hook( &self, input: ArrayView2<'_, u8>, seeds: &[(usize, usize)] ) -> Vec<T>

Runs the watershed transform, executing the hook specified by the TransformBuilder (if there is one) each time the water level is raised. The results from running the hook each time are collected into a vec and returned by this function.

source

fn transform_to_list( &self, input: ArrayView2<'_, u8>, seeds: &[(usize, usize)] ) -> Vec<(u8, Vec<usize>)>

Returns a Vec containing the areas of all the lakes per water level. The length of the nested Vec is always equal to the number of seeds, although some lakes may have zero area (especially for the merging transform, see docs for MergingWatershed)

source

fn transform_history( &self, input: ArrayView2<'_, u8>, seeds: &[(usize, usize)] ) -> Vec<(u8, Array2<usize>)>

Returns a list of images where each image corresponds to a snapshot of the watershed transform at a particular water level.

Caution: this function has to allocate a full image each time the water level is raised. This significantly increases memory usage. If you just want plots of the intermediate images, consider turning on the plots feature instead.

Implementors§