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: 8 months ago
JSON representation
C++ implementation of the Largest Triangle Three Buckets (LTTB) downsampling algorithm
- Host: GitHub
- URL: https://github.com/parkertomatoes/lttb-cpp
- Owner: parkertomatoes
- License: mit
- Created: 2019-12-05T17:12:24.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-09-11T03:01:33.000Z (over 1 year ago)
- Last Synced: 2025-04-12T21:38:05.784Z (10 months ago)
- Topics: cpp, downsample, lttb
- Language: C++
- Homepage:
- Size: 103 KB
- Stars: 35
- Watchers: 4
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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);
```