image_debug_utils/
lib.rs

1//! `image-debug-utils` is a collection of niche but highly practical utilities designed to complement
2//! the [`imageproc`] crate. It focuses on easing the debugging and visualization of common computer
3//! vision tasks.
4//!
5//! To ensure a familiar developer experience, the modules and functions are organized to mirror
6//! the structure of [`imageproc`] as closely as possible.
7//!
8//! # Main Modules
9//!
10//! *   [`contours`]: Utilities for working with contours found by `imageproc::contours`, including
11//!     filtering by aspect ratio and hierarchical sorting.
12//! *   [`rect`]: Tools for geometric primitives, such as converting rotated rectangle vertices
13//!     into axis-aligned bounding boxes (useful for `imageproc::geometry::min_area_rect`).
14//! *   [`region_labelling`]: Helpers for visualizing results from `imageproc::region_labelling`,
15//!     such as coloring principal connected components.
16//!
17//! # Example: Filtering and Sorting Contours
18//!
19//! ```rust
20//! use imageproc::contours::Contour;
21//! use imageproc::contours::BorderType;
22//! use image_debug_utils::contours::{remove_hypotenuse_in_place, sort_by_perimeters_owned};
23//! let mut contours: Vec<Contour<i32>> = Vec::new(); // Dummy data
24//! // 1. Remove thin, "hypotenuse-like" artifacts from contours
25//! remove_hypotenuse_in_place(&mut contours, 5.0, None);
26//!
27//! // 2. Sort remaining contours by their perimeter (descending)
28//! let sorted = sort_by_perimeters_owned(contours);
29//! ```
30//!
31//! # Example: Visualizing Connected Components
32//!
33//! ```rust
34//! use image_debug_utils::region_labelling::draw_principal_connected_components;
35//! use image::{Rgba, ImageBuffer, Luma};
36//! let labelled_image = ImageBuffer::<Luma<u32>, Vec<u32>>::new(10, 10); // Dummy data
37//! // Draw the top 5 largest connected components with contrasting colors
38//! let colored_image = draw_principal_connected_components(&labelled_image, 5, Rgba([0, 0, 0, 255]));
39//! ```
40
41mod colors;
42pub mod contours;
43pub mod rect;
44pub mod region_labelling;