[][src]Function slic::get_slic

pub fn get_slic(
    img: &RgbImage,
    num_of_super_pixels: u32,
    compactness: f64,
    slic_zero_mode: bool
) -> Slic

Constructor for slic0::Slic struct. Produces SLIC state object.

ArgumentRole
imgImage (image::RgbImage) target for SLIC.
num_of_super_pixelsApproximate (+/- 3) amount of requested clusters.
compactnessbalances color proximity and space proximity. Between 0-20.
slic_zero_moderun SLIC-zero, the zero compactness parameter mode of SLIC.

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();
    // print labels as ascii symbols art to stdout
    slic.labels.iter().enumerate().for_each(|(i, x)| {
       print!("{}", ((32 + *x) as u8 as char).to_string());
       if ((i + 1) % img.width() as usize) == 0 {
           println!();
       }
   });
}