Crate image_pyramid

Source
Expand description

§Image Pyramid

Maintenance crates-io api-docs dependency-status

§Overview

This is a small Rust crate that facilitates quickly generating an image pyramid from a user-provided image.

§Usage

See the crates.io page for installation instructions, then check out the examples directory for example code. Below is a simple illustrative example of computing a default pyramid (Gaussian where each level is half resolution).

use image::DynamicImage;
use image_pyramid::*;

let image = DynamicImage::new_rgba8(640, 480); // Or load from file
let pyramid = match ImagePyramid::create(&image, None) {
  Ok(pyramid) => pyramid,
  Err(e) => {
    eprintln!("Error creating image pyramid: {}", e);
    return;
  }
};

Or a slightly more complex example, illustrating how to create a bandpass pyramid where each octave is 2/3 the resolution, smoothed using a triangle (linear) filter.

use image::DynamicImage;
use image_pyramid::*;

let image = DynamicImage::new_rgba8(640, 480); // Or load from file
let params = ImagePyramidParams {
  scale_factor:   (2.0 / 3.0).into_unit_interval().unwrap(),
  pyramid_type:   ImagePyramidType::Bandpass,
  smoothing_type: SmoothingType::Triangle,
};
let pyramid = match ImagePyramid::create(&image, Some(&params)) {
  Ok(pyramid) => pyramid,
  Err(e) => {
    eprintln!("Error creating image pyramid: {}", e);
    return;
  }
};

ImagePyramidParams::scale_factor field is a UnitIntervalValue, which must be a floating-point value in the interval (0, 1). Creating a value of this type yields a Result and will contain an error if the value is not valid.

§Support

Open an Issue with questions or bug reports, and feel free to open a PR with proposed changes.

§Contributing

Follow standard Rust conventions, and be sure to add tests for any new code added.

Structs§

ImagePyramid
A computed image pyramid and its associated metadata.
ImagePyramidParams
The set of parameters required for computing an image pyramid. For most applications, the default set of parameters is correct.
ImageToProcess
A simple wrapper extending the functionality of the given image with image-pyramid support
UnitIntervalValue
A container for a value falling on the range (0.0, 1.0) (exclusive, meaning the values 0.0 and 1.0 are not valid)

Enums§

ImagePyramidError
An enumeration of the errors that may be emitted from the image_pyramid crate
ImagePyramidType
What type of pyramid to compute. Each has different properties, applications, and computation cost.
SmoothingType
How to smooth an image when downsampling

Traits§

CanComputePyramid
Describes types that can compute their own image pyramid
IntoUnitInterval
A trait describing some floating-point type that can be converted to a unit-interval value (0.0 to 1.0, exclusive)