Expand description
Crate to handle image data backed either by a contiguous slice or a vector.
The image data is stored in a row-major order and can be of different pixel
types - u8, u16, and f32. The image data supports arbitrary color spaces
and number of channels, but the number of channels must be consistent with the
length of the backing storage.
The image size is limited to 65535 x 65535 pixels. In case the image is a
Bayer mosaic image, the crate supports debayering of the image data.
The crate additionally supports serialization and deserialization of the image
data using the serde framework.
The crate provides a concrete type ImageRef to store image data and a type-erased
version DynamicImageRef to store image data with different pixel types.
Additionally, the crate provides a GenericImageRef type to store a DynamicImageRef
with additional metadata, such as the image creation timestamp, and many more. The
metadata keys must be 80 characters or less. Uniqueness of the keys is not enforced,
but is strongly recommended; the keys are case-insensitive.
The crate, with the optional image feature, provides can convert between
DynamicImageRef and DynamicImage from the image crate.
With the optional fitsio feature, the crate can write a GenericImageRef, with
all associated metadata, to a FITS file.
§Usage
use refimage::{ImageRef, ColorSpace, DynamicImageRef, GenericImageRef, GenericImageOwned};
use std::time::SystemTime;
use std::path::Path;
let mut data = vec![1u8, 2, 3, 4, 5, 6, 0, 0]; // 3x2 grayscale image, with extra padding that will be ignored
let img = ImageRef::new(&mut data, 3, 2, ColorSpace::Gray).unwrap(); // Create ImageRef
let img = DynamicImageRef::from(img); // Convert to DynamicImageRef
let mut img = GenericImageRef::new(SystemTime::now(), img); // Create GenericImageRef with creation time info
img.insert_key("CAMERANAME", "Canon EOS 5D Mark IV".to_string()).unwrap(); // Insert metadata
let serialized = bincode::serialize(&img).unwrap(); // Serialize the image
let deserialized: GenericImageOwned = bincode::deserialize(&serialized).unwrap(); // Deserialize the image§Optional Features
Features are available to extend the functionalities of the core refimage data types:
rayon: ParallelizesGenericImageRef::to_luma(and similar),GenericImageRef::to_luma_custom,GenericImageRef::into_u8andGenericImageRef::debayerfunctions (enabled by default).fitsio: ExposesFitsWritetrait to writeGenericImageRefandGenericImageOwned(disabled by default).image: EnablesTryFromconversions betweenDynamicImageandDynamicImageRef,DynamicImageOwned(disabled by default).
Structs§
- A serializable, generic image with metadata, backed by
DynamicImageOwned. - A serializable, generic image with metadata, backed by
DynamicImageRef. - A metadata item.
- A structure that holds image data backed by a vector.
- A structure that holds image data backed by a slice or a vector.
- Configuration used to find the optimum exposure.
- Builder for the
OptimumExposurecalculator.
Enums§
- Error codes for the Bayer demosaicing.
- Enum to describe the Bayer pattern of the image.
- Description of the color space of the image.
- The demosaicing algorithm to use to fill in the missing color channels.
- Dynamic
Image imageA Dynamic Image - Image data with a dynamic pixel type, backed by owned data.
- Image data with a dynamic pixel type, backed by a mutable slice of data.
- Fits
Compression fitsioCompression algorithms used in FITS files. - Fits
Error fitsioEnumeration of all error types - A serializable, generic image with metadata, backed by either a
GenericImageRefor aGenericImageOwned. - A type-erased enum to hold a metadata value.
- Enum to describe the primitive pixel type of the image. The underlying
i8representation conforms to the FITS standard.
Constants§
- Key for the camera name metadata.
- Key for exposure time metadata of the image.
- Key for the name of the program that generated this object.
- Key for the timestamp metadata. This key is inserted by default when creating a new
GenericImageRef,GenericImageOwnedorGenericImage.
Traits§
- A trait for shifting Bayer patterns.
- Trait to calculate the optimum exposure time and binning.
- A trait for copying a region of interest (ROI) from one image to another.
- Trait to apply a Demosaic algorithm to an image.
- A data format that can deserialize any data structure supported by Serde.
- An
Enlargable::Largervalue should be enough to calculate the sum (average) of a few hundred or thousand Enlargeable values. - Fits
Write fitsioTrait for writing objects to FITS files. - A trait for accessing the properties of an image.
- The type of each channel in a pixel. For example, this can be
u8,u16,f32. - A trait for selecting a region of interest (ROI) from an image.
- A data format that can serialize any data structure supported by Serde.
- A trait for converting an image to a luminance image.