[−][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.
Argument | Role |
---|---|
img | Image (image::RgbImage ) target for SLIC. |
num_of_super_pixels | Approximate (+/- 3) amount of requested clusters. |
compactness | balances color proximity and space proximity. Between 0-20. |
slic_zero_mode | run 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!(); } }); }