Skip to content

andrestubbe/FastImage

Repository files navigation

FastImage — SIMD‑Accelerated, Off‑Heap Image Processing for Java

Ultra-fast native image processing using AVX2/SSE4.1 kernels and zero-GC memory management.

Build Java Platform License: MIT JitPack

FastImage ist eine ultra‑schnelle, native‑beschleunigte Image‑Processing‑Engine für Java, gebaut für das FastJava‑Ecosystem. Es kombiniert AVX/SSE SIMD, off‑heap Storage, zero‑copy Pipelines und eine fluent API, um typische BufferedImage‑Operationen 10–50× schneller auszuführen — ohne GC‑Pressure, ohne Pixel‑Loops, ohne JVM‑Overhead.

// Quick Start — SIMD-Accelerated Filtering
import fastimage.FastImage;

public class Demo {
    public static void main(String[] args) {
        FastImage img = FastImage.load("input.jpg");
        
        img.adjustContrast(1.2f)
           .blurStack(15.0f)
           .grayscale();
           
        img.save("output.png");
        img.dispose(); // Free native memory
    }
}

Table of Contents


Key Features

  • 🚀 SIMD Acceleration — Hand-optimized C++ kernels using AVX2 and SSE4.1 vector instructions.
  • 🧠 Zero-GC Overhead — Pixels are stored in off-heap memory, preventing GC pauses during heavy manipulation.
  • 🌀 Advanced Blur Suite — Real-time Gaussian, Stack (iOS-style), and Kawase blurs.
  • 🛡️ Fail-Safe JNI — Robust error handling with FastImageException and native handle validation.
  • 🔄 Fast Conversion — Optimized bit-copying between BufferedImage and native memory.

Performance

FastImage utilizes the full power of your CPU, outperforming standard Java2D loops by orders of magnitude:

Operation Java2D (BufferedImage) FastImage (SIMD) Speedup
Brightness ~48.6 ms/op ~1.5 ms/op 32x
Gaussian Blur (r10) ~1100.0 ms/op ~170.4 ms/op 6.5x
Grayscale ~20.0 ms/op ~1.3 ms/op 15x

Tested on: 1920x1080 (1080p) ARGB Image on Intel i7-12700K.


Installation

FastJava modules require two dependencies: the module itself, and FastCore (which handles the native library extraction).

Maven (JitPack)

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>com.github.andrestubbe</groupId>
        <artifactId>fastimage</artifactId>
        <version>0.1.0</version>
    </dependency>
    <dependency>
        <groupId>com.github.andrestubbe</groupId>
        <artifactId>fastcore</artifactId>
        <version>0.1.0</version>
    </dependency>
</dependencies>

Gradle (JitPack)

repositories {
    maven { url 'https://jitpack.io' }
}

dependencies {
    implementation 'com.github.andrestubbe:fastimage:0.1.0'
    implementation 'com.github.andrestubbe:fastcore:0.1.0'
}

Option 3: Direct Download

Download the latest JARs directly from the releases:

  1. 📦 fastimage-v0.1.0.jar
  2. ⚙️ fastcore-v0.1.0.jar

Try the Demo

  1. Clone this repository: git clone https://github.com/andrestubbe/FastImage.git
  2. Run the automated showcase: .\run-demo.bat

Includes the interactive Visual Editor and the Blur Gallery.


API Reference

Method Description
void grayscale() Converts image to luminance-weighted grayscale via SIMD.
void adjustBrightness(f) Scales RGB values with saturation clamping.
void adjustContrast(f) Adjusts image contrast around the midpoint.
void blurGaussian(r) High-quality Gaussian blur approximation ($O(N)$).
void blurStack(r) Extremely fast separable weighted blur.
void resize(w, h) Bilinear resizing using native kernels.

Platform Support

Architecture Instruction Set OS
x64 AVX2 (Runtime Dispatch) Windows 10/11
x64 SSE4.1 (Fallback) Windows 10/11

Building from Source

For detailed instructions on compiling the C++ JNI code and building the Maven FatJAR, see COMPILE.md.


License

MIT License — See LICENSE file for details.


Related Projects


Made with ⚡ by Andre Stubbe

About

High-performance image processing for Java. SIMD-accelerated resize, blur, grayscale. 10-50× faster.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors