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
PyramidBuffersonce and reuse it across frames to avoid repeated allocations. - Optional parallelism: enable the
rayonandpar_pyramidfeatures for parallel row processing. - Optional SIMD: enable the
simdandpar_pyramidfeatures 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, ¶ms, &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§
- Image
Buffer - Owned grayscale image buffer (u8).
- Image
View - Minimal borrowed grayscale image view (u8, row-major).
- Pyramid
- A top-down pyramid where
levels[0]is the base (full resolution). - Pyramid
Buffers - Reusable backing storage for pyramid construction.
- Pyramid
Level - A single pyramid level. The
scaleis relative to the base image. - Pyramid
Params - Parameters controlling pyramid generation.
Functions§
- build_
pyramid - Build a top-down image pyramid using fixed 2x downsampling.