Skip to content

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

License

Notifications You must be signed in to change notification settings

parkertomatoes/lttb-cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

This is a straightforward C++ port of the reference implementation of the Largest Triangle Three Buckets (LTTB) downsampling algorithm described in the paper "Downsampling time series for visual representation" by Sveinn Steinarsson. 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

#include "lttb.hpp"

struct ExamplePoint {
    float x;
    float y;
};

using PointLttb = LargestTriangleThreeBuckets<ExamplePoint, float, &ExamplePoint::x, &ExamplePoint::y>

Then use the static method Downsample in the class. It can be used with iterators

std::vector<ExamplePoint> in = GetYourInputsFromSomewhere();
std::vector<ExamplePoint> out;
PointLttb::Downsample(in.begin(), in.size(), std::back_inserter(out), 50);

...or pointers:

ExamplePoint in[500];
GetYourInputsFromSomewhere(in);
ExamplePoint out[50];
PointLttb::Downsample(in, 500, out, 50);

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published