[][src]Struct slic::Slic

pub struct Slic<'a> {
    pub k: u32,
    pub compactness: f64,
    pub slic_zero_mode: bool,
    pub labels: Vec<i64>,
    pub img: &'a RgbImage,
    // some fields omitted
}

Main SLIC state struct which holds the state for each step of clustering process.

This struct is created by the slic::get_slic function. See its documentation for more.

Fields

k: u32

result amount of superpixels (clusters).

compactness: f64

value between 0-20. balances color proximity and space proximity. Higher values give more weight to space proximity, making superpixel shapes more square/cubic. In SLICO mode, this is the initial compactness.

slic_zero_mode: bool

run SLIC-zero, the zero compactness parameter mode of SLIC.

labels: Vec<i64>

SLIC result Vec. Labels mask produced on input image. Max label is k.

img: &'a RgbImage

reference image target image received in slic::get_slic.

Methods

impl<'_> Slic<'_>[src]

pub fn compute(&mut self)[src]

Mutable methods which runs SLIC computations. Applies iterations until residual error will be close to 0. Calls enforce connectivity using Connected Components Algorithm

pub fn get_borders_image(&self) -> RgbaImage[src]

Crates 4-channel image::RgbaImage with self.img dimensions. Draws yellow borders for each cluster on transparent background. Moves result variable to caller.

Examples:

use slic::get_slic;
use image::{open};
fn main() {
    let mut image = open("./my_image.jpg").ok().expect("Cannot open image");
    let img = image
        .as_mut_rgb8()
        .expect("Cannot get RGB from DynamicImage");

    let mut slic = get_slic(img, 30, 10.0, true);
    slic.compute();
    slic.get_borders_image().save("./borders.png").expect("Cannot save image on disk");
}

Auto Trait Implementations

impl<'a> Sync for Slic<'a>

impl<'a> Send for Slic<'a>

impl<'a> Unpin for Slic<'a>

impl<'a> UnwindSafe for Slic<'a>

impl<'a> RefUnwindSafe for Slic<'a>

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> SetParameter for T