Skip to content

ahmetmutlugun/rscale2x

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rscale2x

A high-performance implementation of the Scale2x upscaling algorithm in Rust, with support for multi-core CPU parallelization and GPU acceleration.

Installation

From source

1. Install Dependencies

Install cargo and rust.

2. Building

Download the source of the project, then run cargo build --release in the directory to generate the binary in ./target/release/rscale2x.

Usage

Upscale and save images using the scale2x algorithm.

Usage: rscale2x [OPTIONS] --input <INPUT> --output <OUTPUT>

Options:
  -i, --input <INPUT>          Input image file path
  -o, --output <OUTPUT>        Output image file path
  -b, --blur <BLUR>            Gaussian blur [default: 0]
  -u, --unsharpen <UNSHARPEN>  Unsharpen [default: 0]
      --hue <HUE>              Hue shift [default: 0]
  -t, --threads <THREADS>      Number of threads (0 = auto, 1 = single-threaded) [default: 0]
      --gpu                    Use GPU acceleration via wgpu (Metal/Vulkan/DX12)
  -h, --help                   Print help information
  -V, --version                Print version information

Performance

End-to-End Benchmark

Tests include process startup, image decoding (PNG), algorithm execution, and encoding (PNG). Recorded on an 8-Core M1 Pro.

Image Size scalex (Original C) rscale2x (Single-Core) rscale2x (Multi-Core) rscale2x (GPU)
1024x1024 418ms 202ms 190ms 208ms
2048x2048 1.44s 701ms 661ms 690ms
4096x4096 4.90s 2.66s 2.50s 2.56s

Note: For smaller images, CPU paths are often faster due to zero initialization overhead. For very large images, Multi-core and GPU paths provide better scaling.

Features:

  • Fast: Outperforms the original C implementation by ~2x end-to-end.
  • Parallel: Uses rayon for efficient multi-core processing.
  • GPU Accelerated: Uses wgpu for high-performance compute on supported hardware.
  • Robust: Includes automated unit tests to verify algorithm correctness.

Testing:

Run the internal test suite:

cargo test

Dependencies:

  • Rayon for CPU parallelism.
  • Wgpu for GPU acceleration.
  • Image for image I/O.
  • Clap for CLI parsing.

Credits:

Original Scale2x algorithm by Andrea Mazzoleni. tree.png: Unsplash

About

A rust binary to upscale images using the scale2x algorithm.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors