[−][src]Struct slic::Slic
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
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]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> SetParameter for T
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
T: Parameter<Self>,