Skip to main content

Crate box_image_pyramid

Crate box_image_pyramid 

Source
Expand description

Minimal image pyramid using 2x box-filter downsampling.

This crate provides a simple, efficient image pyramid for u8 grayscale images. Each level is produced by a 2x2 box-filter downsample (averaging four pixels into one). It is designed for real-time pipelines where you need coarse-to-fine processing without pulling in a full image processing library.

§Key features

  • Reusable buffers: construct a PyramidBuffers once and reuse it across frames to avoid repeated allocations.
  • Optional parallelism: enable the rayon and par_pyramid features for parallel row processing.
  • Optional SIMD: enable the simd and par_pyramid features for portable SIMD acceleration (requires nightly Rust).

§Example

use box_image_pyramid::{ImageView, PyramidParams, PyramidBuffers, build_pyramid};

let pixels = vec![128u8; 256 * 256];
let base = ImageView::new(256, 256, &pixels).unwrap();

let mut params = PyramidParams::default();
params.num_levels = 3;
params.min_size = 32;
let mut buffers = PyramidBuffers::new();
let pyramid = build_pyramid(base, &params, &mut buffers);

assert_eq!(pyramid.levels.len(), 3);
assert_eq!(pyramid.levels[0].img.width, 256);
assert_eq!(pyramid.levels[1].img.width, 128);
assert_eq!(pyramid.levels[2].img.width, 64);

Structs§

ImageBuffer
Owned grayscale image buffer (u8).
ImageView
Minimal borrowed grayscale image view (u8, row-major).
Pyramid
A top-down pyramid where levels[0] is the base (full resolution).
PyramidBuffers
Reusable backing storage for pyramid construction.
PyramidLevel
A single pyramid level. The scale is relative to the base image.
PyramidParams
Parameters controlling pyramid generation.

Functions§

build_pyramid
Build a top-down image pyramid using fixed 2x downsampling.