Superpixels for Rust
This crate contains algorithms for segmenting an image into perceptually similar regions.
Currently it only has one implementation:
- SLIC (Simple Linear Iterative Clustering) translated to Rust.
Example Command-line Usage
cargo run --features="build-binary" -- \
--outline-image=assets/hawaii_outline.jpg assets/hawaii.jpg

Library Usage
The superpixel executable is a reasonably compact example. This crate expects
images in the format of the image crate, specially a image::DynamicImage::Rgb8.
extern crate superpixel;
extern crate image;
use Vec;
use repeat;
use Instant;
use DynamicImage;
use ;
...
let img : image:Rgb8 = ...; // get your image from somewhere
// SLIC operates on LAB space
let mut lab_vec : = repeat.take.collect;
rgb_to_lab_image;
let num_patches = 9000;
let compactness = 20;
let iterations = 10;
// klabels has the pixel labelling to segment id
let mut klabels : = vec!;
// while 9000 superpixels/patches are requested, the exact number may differ so the actual number is returned
let num_superpixels = do_segmentation_with_num_superpixels;
// debug image for showing where segment boundaries are
let outline_fn = "test.png";
let outline_color = Rgb;
save_image_with_segment_boundaries;
Windows
When developing on Windows - if you have installed 64bit libraries, and 64bit MSVC rust, you need to do
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64
before running cargo build
License
MIT