← Back

ofxGlic

github.com/daitomanabe/ofxGlic · @daitomanabe
OF 0.12 Graphics Algorithms

Wraps the GLIC glitch image codec for openFrameworks, with presets, post-processing effects and ofImage integration.

3 0 Last commit 9mo ago Created 9mo ago

README

ofxGlic



ofxGlic Screenshot

openFrameworks addon for GLIC (GLitch Image Codec) - a creative image codec designed for generating glitch art effects.

Overview



ofxGlic wraps the GLIC C++ library to provide an openFrameworks-friendly API for encoding and decoding images with intentional glitch artifacts. GLIC uses various prediction algorithms, wavelet transforms, and quantization techniques to create unique visual effects.

Features



Installation



Clone with submodules



cd openFrameworks/addons
git clone --recursive https://github.com/daitomanabe/ofxGlic.git


Or add submodule manually



cd openFrameworks/addons
git clone https://github.com/daitomanabe/ofxGlic.git
cd ofxGlic
git submodule update --init


Usage



Basic Example



#include "ofxGlic.h"

ofxGlicCodec codec;
ofImage sourceImage;
ofImage resultImage;

void ofApp::setup() {
    sourceImage.load("input.png");

    // Configure codec
    auto& config = codec.getConfig();
    config.colorSpace = glic::ColorSpace::HWB;
    config.channels[0].predictionMethod = glic::PredictionMethod::PAETH;
    config.channels[0].quantizationValue = 110;
    config.channels[0].waveletType = glic::WaveletType::SYMLET8;

    // Copy settings to all channels
    config.channels[1] = config.channels[0];
    config.channels[2] = config.channels[0];
}

void ofApp::encode() {
    auto result = codec.encode(sourceImage, ofToDataPath("output.glc"));
    if (result.success) {
        resultImage = result.image;
    }
}

void ofApp::decode() {
    auto result = codec.decode(ofToDataPath("output.glc"));
    if (result.success) {
        resultImage = result.image;
    }
}


Using Presets



#include "ofxGlic.h"

void ofApp::setup() {
    // Get a preset
    auto preset = ofxGlicPresets::vhs();

    // Apply preset config to codec
    codec.setConfig(preset.codecConfig);

    // Preset includes recommended effects
    for (const auto& effect : preset.effects) {
        codec.addPostEffect(effect);
    }
}

// Available presets:
// ofxGlicPresets::subtle()    - Light glitch effect
// ofxGlicPresets::moderate()  - Balanced glitch
// ofxGlicPresets::extreme()   - Heavy artifacts
// ofxGlicPresets::vhs()       - VHS tape-like
// ofxGlicPresets::digital()   - Digital compression
// ofxGlicPresets::corrupted() - File corruption
// ofxGlicPresets::waves()     - Wave distortion
// ofxGlicPresets::blocky()    - Block artifacts
// ofxGlicPresets::dreamy()    - Soft, ethereal
// ofxGlicPresets::retro()     - Retro computing


Using Effects



#include "ofxGlic.h"

ofxGlicEffects effects;
ofImage processedImage;

void ofApp::setup() {
    // Add effects chain
    effects.addPixelate(8);
    effects.addScanline(50);
    effects.addChromatic(3, 0);
    effects.addPosterize(4);
    effects.addGlitchShift(16);
}

void ofApp::applyEffects() {
    // Apply effects to an image
    effects.apply(processedImage);

    // Or create a new processed image
    ofImage result = effects.process(sourceImage);
}

// Effect factory methods:
// ofxGlicEffect::pixelate(blockSize)
// ofxGlicEffect::scanline(intensity)
// ofxGlicEffect::chromatic(offsetX, offsetY)
// ofxGlicEffect::dither(intensity)
// ofxGlicEffect::posterize(levels)
// ofxGlicEffect::glitchShift(blockSize, seed)


Quick Encode/Decode



// Static methods for one-off operations
ofxGlicCodec::encodeImage(sourceImage, "output.glc");
auto result = ofxGlicCodec::decodeImage("output.glc");


Configuration Options



Color Spaces



NameDescription
RGBStandard RGB
HSBHue, Saturation, Brightness
HWBHue, Whiteness, Blackness
LABCIE Lab*
YUVAnalog video
OHTAOptimal color transform
...And 10 more

Prediction Methods



NameGlitch Characteristic
PAETHPNG-style prediction
SPIRALSpiral artifacts from center
WAVEWave-like distortions
RADIALRadial artifacts
CHECKERBOARDCheckerboard pattern
NOISENoise-like texture
BSADMaximum glitch (worst prediction)

Post-Processing Effects



EffectDescriptionParameters
PixelateMosaic effectblockSize
ScanlineCRT monitor linesintensity (0-100)
ChromaticRGB channel offsetoffsetX, offsetY
DitherBayer ditheringintensity (0-100)
PosterizeColor reductionlevels (2-16)
Glitch ShiftRandom row shiftingblockSize, seed

Channel Configuration



glic::ChannelConfig channelConfig;
channelConfig.minBlockSize = 2;           // Min quad-tree block size
channelConfig.maxBlockSize = 256;         // Max quad-tree block size
channelConfig.segmentationPrecision = 15; // Segmentation threshold
channelConfig.predictionMethod = glic::PredictionMethod::PAETH;
channelConfig.quantizationValue = 110;    // 0-255, higher = more glitch
channelConfig.waveletType = glic::WaveletType::SYMLET8;
channelConfig.transformScale = 20;
channelConfig.encodingMethod = glic::EncodingMethod::PACKED;


Examples



This addon includes six example projects:

ExampleDescription
example/Basic encode/decode with drag-and-drop
example_with_gui/Interactive GUI for adjusting parameters
example_effects/Post-processing effects demo with presets
example_realtime/Live camera input with real-time glitching
example_batch/Batch process multiple images from folder
example_video/Process video with multiple presets, export as image sequence

Building Examples



cd example
make
make run

Or use Xcode project

open example.xcodeproj


API Reference



ofxGlicCodec



Main codec class for encoding/decoding.

class ofxGlicCodec {
    // Configuration
    void setConfig(const glic::CodecConfig& config);
    glic::CodecConfig& getConfig();

    // Encoding
    ofxGlicResult encode(const ofImage& source, const std::string& outputPath);
    std::vector<uint8_t> encodeToBuffer(const ofImage& source);

    // Decoding
    ofxGlicResult decode(const std::string& inputPath);
    ofxGlicResult decodeFromBuffer(const std::vector<uint8_t>& buffer);

    // Post-effects
    void addPostEffect(const ofxGlicEffect& effect);
    void clearPostEffects();
};


ofxGlicEffects



Effects processor for post-processing.

class ofxGlicEffects {
    void addPixelate(int blockSize = 8);
    void addScanline(int intensity = 50);
    void addChromatic(int offsetX = 2, int offsetY = 0);
    void addDither(int intensity = 50);
    void addPosterize(int levels = 4);
    void addGlitchShift(int blockSize = 8, uint32_t seed = 12345);

    void apply(ofImage& image);
    ofImage process(const ofImage& source);
    void clear();
};


ofxGlicPresets



Preset manager with built-in configurations.

class ofxGlicPresets {
    static ofxGlicPresets& instance();

    std::vector<std::string> getPresetNames() const;
    const ofxGlicPreset& getPreset(const std::string& name) const;

    // Built-in presets
    static ofxGlicPreset subtle();
    static ofxGlicPreset moderate();
    static ofxGlicPreset extreme();
    static ofxGlicPreset vhs();
    static ofxGlicPreset digital();
    static ofxGlicPreset corrupted();
    static ofxGlicPreset waves();
    static ofxGlicPreset blocky();
    static ofxGlicPreset dreamy();
    static ofxGlicPreset retro();
};


Dependencies



License



MIT License

Credits



Get this addon

HTTPS
SSH