kaleidoscope 1.4.0
 
Loading...
Searching...
No Matches
kaleidoscope

LibKaleidoscope

๐ŸŒˆโœจ Transform Images into Mesmerizing Kaleidoscope Art โœจ๐ŸŒˆ

A blazingly fast, cross-platform library to create stunning kaleidoscope effects on images
Built with โค๏ธ using C, C++, Python, and CUDA

๐Ÿ“Š Project Status

GitHub GitHub Workflow Status GitHub Workflow Status GitHub Workflow Status Codecov Codacy grade

๐Ÿ› ๏ธ Technology Stack

C Badge C++ Badge Python Badge CUDA Badge CMake Badge

๐ŸŽฏ What is LibKaleidoscope?

LibKaleidoscope is a high-performance, cross-platform library that transforms ordinary images into breathtaking kaleidoscope patterns. Written in C with FFI support, it offers seamless integration with multiple programming languages and includes GPU acceleration for ultimate performance.

‍๐Ÿ”— Learn More: Check out the mathematical explanation of the kaleidoscope effect!

๐ŸŒŸ Key Features

๐Ÿš€ Performance ๐ŸŒ Multi-Language ๐ŸŽจ Easy to Use โšก GPU Accelerated
Ultra-fast processing with optimized algorithms C, C++, Python, CUDA support Simple 3-function API CUDA backend for maximum speed

๐ŸŽญ Supported Languages

๐Ÿ” Click to see language details

๐ŸŽฏ Core Languages

Language Purpose Features
๐Ÿ”ง C Main programming language Core library, maximum performance
โšก C++ Header-only binding Easy integration, STL compatibility
๐Ÿ Python Cython bindings PyPI package, Pythonic interface
๐Ÿš€ CUDA GPU computing Parallel processing, extreme performance

๐Ÿ“ฆ Quick Installation

๐Ÿ Python Users (Recommended)

# ๐ŸŽ‰ One-liner installation from PyPI
pip install LibKaleidoscope

‍๐Ÿ’ก Pro Tip: Check python/python-test.py for example usage!

๐Ÿ› ๏ธ Building from Source

๐Ÿ—๏ธ Standard Build

# ๐Ÿš€ Quick build commands
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build . --parallel

โšก CUDA-Enabled Build

‍โš ๏ธ IMPORTANT: CUDA Toolkit must be installed and available on your system before building with CUDA support. Download from NVIDIA Developer.

# ๐Ÿ”ฅ GPU-accelerated build
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release -DKALEIDOSCOPE_ENABLE_CUDA=ON ..
cmake --build . --parallel

๐Ÿ”ง Custom Build Options

# ๐ŸŽ›๏ธ Disable command line tool (reduces dependencies)
cmake -DCMAKE_BUILD_TYPE=Release -DKALEIDOSCOPE_ENABLE_CMD_TOOL=OFF ..

‍๐Ÿ“ Note: The libjpeg-turbo dependency is only for testing and demo purposes


๐ŸŽฏ Usage Guide

๐ŸŽช Simple 3-Step API

LibKaleidoscope makes image transformation incredibly simple with just 3 functions:

flowchart LR
A[๐ŸŽฏ Initialize] --> B[๐ŸŽจ Process] --> C[๐Ÿงน Cleanup]
B --> B
๐Ÿ” C API Reference

Step Function Purpose
1๏ธโƒฃ initKaleidoscope() Initialize transformation matrix
2๏ธโƒฃ processKaleidoscope() Process images (reusable for same dimensions)
3๏ธโƒฃ deInitKaleidoscope() Clean up resources
// ๐ŸŽฏ Step 1: Initialize
int initKaleidoscope(KaleidoscopeHandle *handler, int n, int width, int height, double scaleDown);
// ๐ŸŽจ Step 2: Process (use multiple times)
void processKaleidoscope(KaleidoscopeHandle *handler, double k, unsigned char *imgIn, unsigned char *imgOut);
// ๐Ÿงน Step 3: Cleanup
int initKaleidoscope(KaleidoscopeHandle *handler, int n, int width, int height, int nComponents, double scaleDown)
Initializes kaleidoscope handler.
void processKaleidoscope(KaleidoscopeHandle *handler, double k, unsigned char *imgIn, unsigned char *imgOut)
Applies kaleidoscope effect to image.
void deInitKaleidoscope(KaleidoscopeHandle *handler)
Deinitializes kaleidoscope handler.
Struct for kaleidoscope effect generator.

‍๐Ÿ“š Example: Check src/kaleidoscope-cmd.c for complete usage

๐Ÿ–ฅ๏ธ Command Line Magic

Transform images instantly with the command line tool:

# โœจ Create kaleidoscope effect (N=8 segments)
./kaleidoscope-cmd <Input_Image> <Output_Image> <N>

๐ŸŽจ Visual Example

โžก๏ธ
๐ŸŽฎ Original โ†’ Kaleidoscope (N=8)
Image source: AC Valhalla

๐Ÿ’ป Programming Language Examples

โšก C++ Header-Only Binding

#include <kaleidoscope.hpp>
int main() {
// ๐ŸŽฏ One-line initialization with all parameters
kalos::Kaleidoscope handler(n, width, height, nComponents, scaleDown, k);
// ๐ŸŽจ Process your image data
handler.processImage(inData, outData, nPixel);
// ๐Ÿงน Automatic cleanup when handler goes out of scope
return 0;
}
Kaleidoscope effect generator.
int main(int argc, char *argv[])

‍๐Ÿš€ Advantage: RAII-style resource management, exception safety

๐Ÿ”ฅ CUDA GPU Backend

#include <cuda/kaleidoscope.cuh>
int main() {
// ๐Ÿš€ GPU-accelerated kaleidoscope
kalos::cuda::Kaleidoscope handler(n, width, height, nComponents, scaleDown, k);
// โšก Ultra-fast GPU processing
// โš ๏ธ Important: inData and outData must be device-allocated!
handler.processImage(inData, outData, nPixel);
return 0;
}

‍๐Ÿ’ก Performance Tip: Ensure your data is allocated on GPU memory for maximum speed

‍๐Ÿงช Examples: See tests/processingTest.cpp and tests/processingTest.cu for complete implementations

๐Ÿš€ Performance Benchmarks

โšก Lightning Fast Performance

Hardware: Intel i7-11800H CPU

๐ŸŽฅ Resolution ๐Ÿ“Š FPS ๐ŸŽฏ Use Case
๐Ÿ”ฅ 4K UHD (3840ร—2160) **~65 FPS** Professional video editing
๐ŸŽฌ Full HD (1920ร—1080) **~265 FPS** Real-time streaming
๐Ÿ“บ 720p (1280ร—720) **~640 FPS** Gaming overlays
๐Ÿ“ฑ 576p (720ร—576) **~1350 FPS** Mobile apps

๐Ÿ“ˆ Performance Visualization

Performance Chart
๐Ÿ”ฌ Mathematical Formula

The performance follows an exponential decay model:

$$\Large FPS = a \cdot e^{b \cdot nPixels} + c \cdot e^{d \cdot nPixels}$$

Where:

  • $a = 2492$
  • $b = -2.165 \times 10^{-6}$
  • $c = 364.9$
  • $d = -2.08 \times 10^{-7}$

๐Ÿƒโ€โ™‚๏ธ Benchmark Your System

# ๐ŸŽฏ Test performance on your hardware
./kaleidoscope-cmd <Input_Image> <Output_Image> <N> <Number_of_loops>

‍โš ๏ธ Important: Use -DCMAKE_BUILD_TYPE=Release for accurate benchmarks

๐Ÿค Contributing

We welcome contributions! Please feel free to submit issues, feature requests, or pull requests.

๐Ÿ“„ License

This project is licensed under the terms of MIT License.


๐ŸŒŸ Star this repo if you found it useful! ๐ŸŒŸ

Made with โค๏ธ by egecetin