Expand description
This crate defines an easy and extensible way to conduct image convolutions, in a way that
is free of system dependencies, and works with no_std.
The purpose of convolve2d is to provide a single package that provides everything you need to
conduct image convolutions suitable for computer vision or image manipulation. Here’s a breif
overview of what’s on offer:
-
Two convolution functions: allowing you to pass your own buffer if speed is important, or have a buffer allocated and returned for a more idiomatic interface.
-
Traits: Convolution is defined generically across the
Matrixtrait. If you have a custom image type, simply define an implementation ofMatrix, and you’re good to go! -
Built-in
imageSupport: We also offer support for theimagelibrary through a feature flag (disabled by default), allowing you to seamlessly use the types you’re already used to! -
rayon: Compute convolutions in parallel using therayonflag. (Enabled by default) -
no_stdOperation: to suit the needs of specialty systems or WASM. -
Kernel Generators: The
kernelmodule provides generation functions for a number of kernels commonly used in image processing.
While other convolution libraries may be more efficient, using a faster algorithm, or running on the GPU, this library’s main focus is providing a complete convolution experience that is portable and easy to use.
§Features:
The following features are supported:
| Feature | Default | Description |
|---|---|---|
std | Yes | Allow access to the standard library, enabling the DynamicMatrix type. |
rayon | Yes | Use rayon to compute convolutions in parallel. |
image | No | Add extensions for interoperation with the image crate. |
full | No | All features. |
To use the library in no_std mode, simply disable all features:
convolve2d = { version = "0.1.0", default-features = false }§Notes on image Compatibility
Compatibility with the image library is provided using the image feature flag. This flag
provides the following features:
-
The various pixel formats (
Rgb,Luma, etc…) can now be converted to and from theSubPixelstype. This allows them to be scaled and added as required for convolutions. -
ImageBuffercan be converted to and fromDynamicMatrixes usingintoandfrom. -
ImageBuffers for which the pixel type isLumacan be used asMatrixes directly. This is because each element in the underlying data structure is one pixel. (Whereas in an RGB image, each element is one subpixel, meaning we need to group withSubPixels)
Modules§
- kernel
- Definitions for various kernels that can be generated automatically.
Structs§
- Dynamic
Matrix - A concrete implementation of
Matrixfor which the size is not known at compile time. - Static
Matrix - A
Matrixwith a size known at compile time. - SubPixels
- A collection of subpixels that should make working with multi-channeled images more convenient.
Traits§
- Matrix
- An easily implementable interface for types that can be used in a convolution.
- Matrix
Mut - A subtype of
Matrixallowing mutable access to the underlying data.
Functions§
- convolve2d
- Perform a 2D convolution on the specified image with the provided kernel.
- write_
convolution - Write the convolution of the provided image and kernel into the specified buffer.