image-max-polling 0.1.0

A high-performance Rust library for maximum pooling operations on images, leveraging SIMD instructions (AVX2/NEON) and parallel processing for accelerated performance.
Documentation

Image Max Polling with SIMD Acceleration

A high-performance Rust library for maximum pooling operations on images, leveraging SIMD instructions (AVX2/NEON) and parallel processing for accelerated performance.

Features

  • SIMD Optimization: Utilizes AVX2 (x86-64) or NEON (ARM) intrinsics for vectorized processing.
  • Parallel Execution: Multi-threaded processing via Rayon for scalable performance.
  • Dynamic CPU Detection: Runtime checks for AVX2 support (x86-64 only).
  • Image Compatibility: Works seamlessly with the image crate for input/output.

Installation

Add to your Cargo.toml:

[dependencies]

image-max-polling = "0.1"

Usage

Basic Example

Process an image with 8x8 max pooling:

use image_max_polling::{max_pooling_simd, supports_avx2};
use image::{GrayImage, ImageReader};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    println!("AVX2 supported: {}", supports_avx2());

    let img = ImageReader::open("input.png")?.decode()?.to_luma8();
    let pooled = max_pooling_simd(img.as_bytes(), img.width() as usize, 8);

    GrayImage::from_vec(
        img.width() / 8,
        img.height() / 8,
        pooled,
    )?.save("output.png")?;

    Ok(())
}

Advanced: Custom Pooling Factor

let pooled_data = max_pooling_simd(&pixels, width, pooling_factor);

Requirements

  • Rust: 1.60+ (2024 edition)
  • CPU:
    • x86-64 with AVX2 OR
    • ARMv8 with NEON
  • OS: Linux/macOS/Windows

Testing

Run examples with:

cargo run --example max_pooling

License

MIT License - See LICENSE for details.