$ show image-rs/imageproc
imageproc is a Rust library providing a comprehensive suite of image processing operations built on top of the `image` crate. It includes a wide range of filters (Gaussian blur, bilateral, median, sharpen), geometric transformations (rotation, scaling, warping, projection), drawing primitives (lines, shapes, text with font rendering), feature detection (FAST corners, BRIEF descriptors, Hough lines, HoG, Haar-like features), contrast manipulation (histogram equalization, Otsu thresholding), morphology (dilation, erosion, structuring elements), distance transforms, template matching, seam carving, image hashing, and noise addition. The library is designed for performance with extensive use of `unsafe` code where justified, and provides both mutable and immutable API variants, as well as parallel execution via the `rayon` feature. It serves as a practical tool for computer vision and graphics editors, with a focus on correctness and reproducibility (regression tests against reference images). The crate is modular, with each major operation in its own file, and includes many examples demonstrating realistic workflows like edge detection, object matching, and text overlay. While not a research project, it implements classic computer vision algorithms with modern Rust idioms and is actively maintained with regular releases.
The LLM identified 5 files worth highlighting for reuse:
Provides `Kernel<'a, K>` β a 2D convolution kernel with compile-time dimension and channel type safety. Supports vectorized (SIMD) and scalar modes, and offers methods like `filter()`, `filter_with_stride()`, and `apply_kernel()`. Self-contained and generic over any numeric `Pixel` type that implements the appropriate traits. Easily extractable for any project needing robust convolution.
Implements `DisjointSetForest`, a union-find data structure with path compression and union by rank. Used internally for connected component labeling but completely generic. Provides `union()`, `find()`, `set_size()`, and iteration over components. Minimal dependenciesβonly `Vec` and primitive operationsβmaking it trivial to reuse in other Rust projects.
Contains binary and grayscale morphological operations (dilate, erode, open, close). The `Mask` struct stores sorted point offsets for efficient neighborhood iteration, with invariants enforced at construction. Grayscale operations use a generic `mask_reduce` function parameterized over min/max operators, enabling both dilation and erosion from one implementation. The `Mask` can be created from predefined shapes (square, diamond, disk) or from an arbitrary image. This module is well-abstracted and could be extracted with its helper types for any library needing morphological operations.
Provides `arbitrary_image()`, a proptest strategy for generating random images of arbitrary dimensions and pixel types, with options for transparency and grayscale. Also includes `arbitrary_kernel()` and `arbitrary_mask()` strategies. These are invaluable for property-based testing of image processing algorithms and are reusable in any project using `image` and `proptest`. The module demonstrates advanced proptest composition.
Defines `Point<T>` (where `T: Primitive`) with methods for vector arithmetic, dot product, magnitude, and conversion. Used extensively across the crate but completely self-contained. The design supports both integer and floating-point coordinates, with traits like `PointScalable` and `PointAddable` for generic operations. Could be extracted as a lightweight 2D geometry library.