#image-processing #image-conversion #ndarray #traits #rgb

ndimage

A simple library for conversion between ndarray and image

2 releases

0.1.1 Mar 26, 2024
0.1.0 Mar 4, 2024

#606 in Images

Download history 111/week @ 2024-02-29 32/week @ 2024-03-07 15/week @ 2024-03-14 112/week @ 2024-03-21 46/week @ 2024-03-28 16/week @ 2024-04-04

85 downloads per month

MIT license

12KB
241 lines

ndimage

Provides traits that allow conversion between ndarray crate and image crate.

It can be used for debugging, testing, or for using ndarray's image processing capabilities on image crate's images.

Drawbacks

The conversion from ndarray to image is not zero-copy. Only supports RGB and Gray images currently.

Usage

Borrow as mutable and call mut_ndarray method to get a mutable reference to the ndarray.

use ndimage::MutNdarray;
use image::{Rgb, RgbImage};

let mut vals = RgbImage::new(2, 4);
vals.mut_ndarray();

Borrow as immutable and call ref_ndarray method to get a reference to the ndarray.

use ndimage::RefNdarray;
use image::{Rgb, RgbImage};

let vals = RgbImage::new(2, 4);
vals.ref_ndarray();

Convert from image to ndarray.

use ndimage::IntoNdarray;
use image::{Rgb, RgbImage};

let vals = RgbImage::new(2, 4);
let arr = vals.into_ndarray();

Dependencies

~14MB
~84K SLoC