Skip to main content
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
void deInitKaleidoscope(KaleidoscopeHandle *handler);

📚 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;
}

🚀 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

Metadata

Release files for LibKaleidoscope 1.4.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for LibKaleidoscope 1.4.2
File Size Uploaded
libkaleidoscope-1.4.2.tar.gz 69.9 kB Details

Release files / libkaleidoscope-1.4.2.tar.gz

Download URL libkaleidoscope-1.4.2.tar.gz
Size 69.9 kB
Tags Source
SHA-256 checksum
How to use checksums
3bc6301ca900255822a1c43492f637cf7e3be1e8b6773a31625c96f17b6de6cd
BLAKE2b-256 checksum
How to use checksums
bfd88554f64990a29a434a3505ccb8ebb0b8caff92d03b02b3f87eda2cf13870
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

1.4.2 This release

1 release file

1.4.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page