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](https://img.shields.io/github/license/egecetin/libKaleidoscope?style=for-the-badge) ![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/egecetin/libKaleidoscope/codeql-analysis.yml?branch=master&label=CodeQL&logo=github&style=for-the-badge) ![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/egecetin/libKaleidoscope/os-builds.yml?branch=master&label=Build&logo=github&logoColor=white&style=for-the-badge) ![Sonarcloud Analysis](https://img.shields.io/sonar/quality_gate/egecetin_libKaleidoscope?server=https%3A%2F%2Fsonarcloud.io&style=for-the-badge&logo=sonarqubecloud) ![Scorecard score](https://img.shields.io/ossf-scorecard/github.com/egecetin/libKaleidoscope?label=OpenSSF%20Score&style=for-the-badge&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9IndoaXRlIiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCI+PHJlY3QgeD0iMyIgeT0iMTEiIHdpZHRoPSIxOCIgaGVpZ2h0PSIxMSIgcng9IjIiIHJ5PSIyIj48L3JlY3Q+PHBhdGggZD0ibTcgMTFWN0E1IDUgMCAwIDEgMTcgN3Y0Ij48L3BhdGg+PC9zdmc+) ### ๐Ÿ› ๏ธ **Technology Stack** ![C Badge](https://img.shields.io/badge/C-%23555555?style=for-the-badge&logo=c&logoColor=white) ![C++ Badge](https://img.shields.io/badge/C%2B%2B-%23f34b7d?style=for-the-badge&logo=cplusplus&logoColor=white) ![Python Badge](https://img.shields.io/badge/Python-%233572A5?style=for-the-badge&logo=python&logoColor=white) ![CUDA Badge](https://img.shields.io/badge/CUDA-%233A4E3A?style=for-the-badge&logo=nvidia&logoColor=white) ![CMake Badge](https://img.shields.io/badge/CMake-%23008FBA?style=for-the-badge&logo=cmake&logoColor=white)
--- ## ๐ŸŽฏ **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](https://egecetin.github.io/Projects/kaleidoscope) 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)** ```bash # ๐ŸŽ‰ One-liner installation from PyPI pip install LibKaleidoscope ``` > ๐Ÿ’ก **Pro Tip**: Check `python/python-test.py` for example usage! --- ## ๐Ÿ› ๏ธ **Building from Source**
๐Ÿ—๏ธ Standard Build ```bash # ๐Ÿš€ 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](https://developer.nvidia.com/cuda-downloads). ```bash # ๐Ÿ”ฅ GPU-accelerated build mkdir build && cd build cmake -DCMAKE_BUILD_TYPE=Release -DKALEIDOSCOPE_ENABLE_CUDA=ON .. cmake --build . --parallel ```
๐Ÿ”ง Custom Build Options ```bash # ๐ŸŽ›๏ธ 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**: ```mermaid 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 | ```c // ๐ŸŽฏ 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 void deInitKaleidoscope(KaleidoscopeHandle *handler); ``` > ๐Ÿ“š **Example**: Check `src/kaleidoscope-cmd.c` for complete usage
### ๐Ÿ–ฅ๏ธ **Command Line Magic** Transform images instantly with the command line tool: ```bash # โœจ Create kaleidoscope effect (N=8 segments) ./kaleidoscope-cmd ``` ### ๐ŸŽจ **Visual Example**
โžก๏ธ
๐ŸŽฎ Original โ†’ Kaleidoscope (N=8)
Image source: AC Valhalla
--- ### ๐Ÿ’ป **Programming Language Examples**
โšก C++ Header-Only Binding ```cpp #include 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; } ``` > ๐Ÿš€ **Advantage**: RAII-style resource management, exception safety
๐Ÿ”ฅ CUDA GPU Backend ```cpp #include 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** ```bash # ๐ŸŽฏ Test performance on your hardware ./kaleidoscope-cmd ``` > โš ๏ธ **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](https://github.com/egecetin)