Coder Social home page Coder Social logo

generalized-lloyd-max-methods's Introduction

logo

LGB-methods

In this repository there are various implementations of the Linde, Buzo, and Gray algorithm (generalize Lloyd-Max algorithm) for the calculation of vector quantizer.
- Requirements -


Installation

  • Manual

    Download this repository:

    git clone [email protected]:XaBerr/LGB-methods.git

    and compile it running:

    rm build/ -rf;cmake -S . -B build;make -C build;
  • CMake module

    Module data:

    FetchContent_Declare(
      "LGB-methods"
      GIT_REPOSITORY https://github.com/XaBerr/LGB-methods.git
      GIT_TAG        1.0.0
    )

Inclusion

All include file are avaiable in the include directory. You can include each library individually:

#include <LGB-methods/LGB.h>
#include <LGB-methods/LGBrandom.h>
#include <LGB-methods/LGBsplit.h>
using namespace LGBm;

or using the single include:

#include <LGB-methods.h>
using namespace LGBm;

Usage

These are the algorithms implemented until now:

  • LGB
  • LGB-random
  • LGB-split

LGB

First you need to initialize the quantizer.

LGB<float> quantizer;
std::vector<float> signal = {1, 0, 2, 0, 3, 0, 4, 0};
std::vector<std::vector<float>> initialPoints  = {{1, 0}, {2, 0}, {3, 0}, {4, 0}};
quantizer.rate = 1;
quantizer.nDimension = 2;

Then you can import the signal.

quantizer.vectorize(signal);

In the end you can run the LGB algorithm and print the result.

quantizer.run(initialPoints);
quantizer.printVectorPoints(quantizer.codebook);

LGB-random

First you must initialize the quantizer.

LGBrandom<float> quantizer;
std::vector<float> signal = {1, 0, 2, 0, 3, 0, 4, 0};
std::vector<std::vector<float>> initialPoints  = {{1, 0}, {2, 0}, {3, 0}, {4, 0}};
quantizer.rate = 1;
quantizer.nDimension = 2;

Then you can import the signal.

quantizer.vectorize(signal);

In the end you can run the LGB algorithm and print the result.

quantizer.run();
quantizer.printVectorPoints(quantizer.codebook);

LGB-split

First you must initialize the quantizer.

LGBsplit<float> quantizer;
std::vector<float> signal = {1, 0, 2, 0, 3, 0, 4, 0};
std::vector<std::vector<float>> initialPoints  = {{1, 0}, {2, 0}, {3, 0}, {4, 0}};
quantizer.rate = 1;
quantizer.nDimension = 2;

Then you can import the signal.

quantizer.vectorize(signal);

In the end you can run the LGB algorithm and print the result.

quantizer.run();
quantizer.printVectorPoints(quantizer.codebook);

The LGB parameters

Here we have the parameters and theirs default values.

// number of bit per sample
rate        = 2;

// the size of the vectors
nDimension  = 2;

// the maximum error allowed
threshold   = 0.01;

// max iteration limits
maxRuns     = 10;
maxZeroRuns = 5;

In addition for the LGB-split we have this parameter.

// the size of the jump during the split
perturbation = 0.01;

Exiting status for the run method

  • -2: Generated a cluster with zero elements
  • -1: Biggest cluster has zero size
  • +0: Finish without reaching distortion or threshold limit
  • +1: Stopped because distortion start increasing
  • +2: Stopped because threshold reached

Example

Also check out the example in apps/example.cpp.

generalized-lloyd-max-methods's People

Contributors

xaberr avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.