Git Product home page Git Product logo

lutz's Introduction

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);
}

lutz's People

Contributors

rreverser avatar

Stargazers

sam avatar  avatar invisageable avatar Jack Vial avatar WJH avatar

Watchers

 avatar James Cloos avatar sam avatar  avatar

lutz's Issues

test_cshape fails

Should this test not fail?

#[test]
fn test_cshape(){
        let bytes: [u8; 25] = [
            0 , 99, 99, 99 , 0 , //
            0 , 99, 0 , 89 , 0 , //
            0 , 0 , 0 , 99 , 0 , //
            0 , 99, 0 , 99 , 0 , //
            0 , 99, 99, 99 , 0 , //
        ];
        let buffer = image::GrayImage::from_raw(5,5, bytes.to_vec()).unwrap();
        let image = Image8::new(buffer, 20);  // Image8 is identical to the example
        let blobs =  lutz::<_, Vec<_>>(image);
        let blobs = Vec::from_iter(blobs);
        assert_eq!(1, blobs.len());
}	

Beautiful library I would really like continue using.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.