Skip to content

lempiy/slic0

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust SLIC

Build & Test License Rust Documentation

Rust realization of Simple Linear Image Segmentation algorithm with SLIC0 and lowest gradient seeding support.

Purpose

Library can be used in all areas where image pre-processing is required.

  • Content-based image retrieval
  • Machine vision
  • Object detection
  • Recognition Tasks

More info here.

Example

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_rgb8().expect("Cannot get RGB from DynamicImage");
    let mut slic = get_slic(img, 30, 10.0, true);
    slic.compute();
    // save segments net to file
    slic.get_borders_image().save("./borders.png").expect("Cannot save image on disk");
    // print segments as ASCII 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!();
       }
    });
}

Case

test.jpg test.jpg

License

MIT © lempiy

Releases

No releases published

Packages

No packages published

Languages