Crate image2

source ·
Expand description

image2 is an image processing crate with a focus on ease-of-use, support for a wide range of datatypes and composable operations.

Getting started:

use image2::{
   ImageBuf,
   Rgb, Gray,
   Type,
   io,
   Filter,
   filter::ToGrayscale
};

fn main() {
   // Read an image using the default JPEG decoder (stb_image)
   let image: ImageBuf<f64, Rgb> = io::read("test/test.jpg").unwrap();

   // Setup a filter
   let filter = ToGrayscale.and_then(|f| {
       f64::max_f() - f
   });

   // Create an output image
   let mut output: ImageBuf<f64, Gray> = ImageBuf::new_like_with_color::<Gray>(&image);

   // Execute the filter
   filter.eval(&mut output, &[&image]);

   // Save the image using the default PNG encoder (stb_image)
   io::write("example.png", &output).unwrap();
}

Re-exports

pub use self::color::Color;
pub use self::color::Gray;
pub use self::color::Rgb;
pub use self::color::Rgba;
pub use self::filter::Filter;
pub use self::image::Image;
pub use self::kernel::Kernel;

Modules

Macros

filter is used to simplify the process of defining compute_at to create new filters

Structs

Image implementation using Vec<T> to store data
Image implementation backed by a raw pointer, typically used for storing C pointers allocated using malloc.
PixelVec is a 4-channel pixel backed by a static array

Enums

Determines how to free an allocated pointer

Traits

Pixel is used to access chunks of image data
PixelMut is used to access mutable chunks of image data
Implementing Type allows for a type to be used as values contained in an Image