Crates.io | contour_tracing |
lib.rs | contour_tracing |
version | 1.0.12 |
source | src |
created_at | 2020-03-15 11:10:47.648217 |
updated_at | 2022-02-21 13:24:02.115458 |
description | A 2D library to trace contours. |
homepage | https://github.com/STPR/contour_tracing |
repository | https://github.com/STPR/contour_tracing |
max_upload_size | |
id | 218829 |
size | 37,401 |
A 2D library to trace contours.
How it works in a live demo: https://stpr.github.io/contour_tracing/
Core features:
Manual parameters:
contour_tracing = { version = "*", features = ["array"] }
use contour_tracing::array::bits_to_paths;
fn main() {
let bits = vec![vec![ 1,0,0 ],
vec![ 0,1,0 ],
vec![ 0,0,1 ]];
println!("{}", bits_to_paths(bits, true));
}
contour_tracing = { version = "*", features = ["image"] }
use image::{GrayImage, Luma};
use contour_tracing::image::single_l8_to_paths;
fn main() {
let mut image_buffer = GrayImage::new(3, 3);
let foreground_color: image::Luma<u8> = Luma([1]);
image_buffer.put_pixel(0, 0, foreground_color);
image_buffer.put_pixel(1, 1, foreground_color);
image_buffer.put_pixel(2, 2, foreground_color);
println!("{}", single_l8_to_paths(&mut image_buffer, foreground_color, true));
}
Both examples should print: M0 0H1V1H0ZM1 1H2V2H1ZM2 2H3V3H2Z
For more examples, have a look at the documentation:
Contour tracing library https://github.com/STPR/contour_tracing
Copyright (c) 2022, STPR - https://github.com/STPR
SPDX-License-Identifier: EUPL-1.2
Your contribution is highly appreciated. Do not hesitate to open an issue or a pull request. Note that any contribution submitted for inclusion in the project will be licensed according to the terms given in LICENSE.txt.