lutz

Crates.iolutz
lib.rslutz
version1.4.0
sourcesrc
created_at2021-04-11 19:54:02.957919
updated_at2023-11-14 02:12:39.113406
descriptionRust implementation of "An Algorithm for the Real Time Analysis of Digitised Images" by R. K. Lutz
homepage
repositoryhttps://github.com/RReverser/lutz
max_upload_size
id382131
size39,473
Ingvar Stepanyan (RReverser)

documentation

README

Lutz

This is a Rust implementation of "An Algorithm for the Real Time Analysis of Digitised Images" by R. K. Lutz.

It's a single-pass algorithm for connected-component labeling that allows to find 8-connected objects in a binary (monochrome) image.

Usage

Crate expects the user to implement its lutz::Image trait. A possible implementation for a struct wrapping an image::GrayImage type:

struct Image {
    img: image::GrayImage,
    threshold: u8,
}

impl lutz::Image for Image {
    fn width(&self) -> u32 {
        self.img.width()
    }

    fn height(&self) -> u32 {
        self.img.height()
    }

    fn has_pixel(&self, x: u32, y: u32) -> bool {
        self.img.get_pixel(x, y).0[0] > self.threshold
    }
}

Once constructed, a reference to such image should be passed to the lutz function. It will return an iterator over detected objects, each represented as a Vec<Pixel> of its pixel coordinates:

for obj_pixels in lutz::lutz(&img) {
    println!("{:?}", obj_pixels);
}
Commit count: 24

cargo fmt