Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/parkertomatoes/lttb-cpp

C++ implementation of the Largest Triangle Three Buckets (LTTB) downsampling algorithm
https://github.com/parkertomatoes/lttb-cpp

cpp downsample lttb

Last synced: about 1 month ago
JSON representation

C++ implementation of the Largest Triangle Three Buckets (LTTB) downsampling algorithm

Awesome Lists containing this project

README

        

# C++ Implementation of the Largest Triangle Three Buckets (LTTB) Downsampling Algorithm

This is a straightforward C++ port of the [reference implementation](https://github.com/sveinn-steinarsson/flot-downsample) of the Largest Triangle Three Buckets (LTTB) downsampling algorithm described in the paper ["Downsampling time series for visual representation" by Sveinn Steinarsson](http://hdl.handle.net/1946/15343). It is a single header, with a single class template that allows using different structures and data types.

## How To Install
Simply add the ```lttb.hpp``` header to your project. There are no binaries to install, and no dependencies outside the standard library.

## How To Use
Create a typedef to specify your time series datapoint type
```c++
#include "lttb.hpp"

struct ExamplePoint {
float x;
float y;
};

using PointLttb = LargestTriangleThreeBuckets
```

Then use the static method ```Downsample``` in the class. It can be used with iterators
```c++
std::vector in = GetYourInputsFromSomewhere();
std::vector out;
PointLttb::Downsample(in.begin(), in.size(), std::back_inserter(out), 50);
```

...or pointers:
```c++
ExamplePoint in[500];
GetYourInputsFromSomewhere(in);
ExamplePoint out[50];
PointLttb::Downsample(in, 500, out, 50);
```