All Projects → robotsorcerer → Savitzky-Golay

robotsorcerer / Savitzky-Golay

Licence: Apache-2.0 license
Computes the Savitzky-Golay Filter coefficients.

Programming Languages

C++
36643 projects - #6 most used programming language
CMake
9771 projects
c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to Savitzky-Golay

setigen
Python library for generating and injecting artificial narrow-band signals into radio frequency data
Stars: ✭ 19 (-75.64%)
Mutual labels:  signal-processing
CCWT
Complex Continuous Wavelet Transform
Stars: ✭ 136 (+74.36%)
Mutual labels:  signal-processing
pyssp
python speech signal processing library
Stars: ✭ 18 (-76.92%)
Mutual labels:  signal-processing
Metu-CENG
All the homeworks, studies and projects I've done at Metu-CENG
Stars: ✭ 32 (-58.97%)
Mutual labels:  signal-processing
python-meegkit
🔧🧠 MEEGkit: MEG & EEG processing toolkit in Python 🧠🔧
Stars: ✭ 99 (+26.92%)
Mutual labels:  signal-processing
2D 3D PolarFourierTransform
C++, CUDA, and MATLAB codes for the paper "An Exact and Fast Computation of Discrete Fourier Transform for Polar and Spherical Grid"
Stars: ✭ 31 (-60.26%)
Mutual labels:  signal-processing
vmdpy
Variational mode decomposition (VMD) in Python
Stars: ✭ 158 (+102.56%)
Mutual labels:  signal-processing
antropy
AntroPy: entropy and complexity of (EEG) time-series in Python
Stars: ✭ 111 (+42.31%)
Mutual labels:  signal-processing
Chinese-automatic-speech-recognition
Chinese speech recognition
Stars: ✭ 147 (+88.46%)
Mutual labels:  signal-processing
qEEG feature set
NEURAL: a neonatal EEG feature set in Matlab
Stars: ✭ 29 (-62.82%)
Mutual labels:  signal-processing
brain-monitor
A terminal app written in Node.js to monitor brain signals in real-time
Stars: ✭ 119 (+52.56%)
Mutual labels:  signal-processing
python-soxr
Fast and high quality sample-rate conversion library for Python
Stars: ✭ 25 (-67.95%)
Mutual labels:  signal-processing
mdct
A fast MDCT implementation using SciPy and FFTs
Stars: ✭ 42 (-46.15%)
Mutual labels:  signal-processing
ConvDecoder
An un-trained neural network with a potential application in accelerated MRI
Stars: ✭ 21 (-73.08%)
Mutual labels:  signal-processing
ssqueezepy
Synchrosqueezing, wavelet transforms, and time-frequency analysis in Python
Stars: ✭ 315 (+303.85%)
Mutual labels:  signal-processing
ReSampler
High quality command-line audio sample rate converter
Stars: ✭ 120 (+53.85%)
Mutual labels:  fir-filter
dictlearn
Dictionary Learning for image processing
Stars: ✭ 23 (-70.51%)
Mutual labels:  signal-processing
ssj
Social Signal Processing for Android
Stars: ✭ 24 (-69.23%)
Mutual labels:  signal-processing
Speech Feature Extraction
Feature extraction of speech signal is the initial stage of any speech recognition system.
Stars: ✭ 78 (+0%)
Mutual labels:  signal-processing
FftSharp
A .NET Standard library for computing the Fast Fourier Transform (FFT) of real or complex data
Stars: ✭ 132 (+69.23%)
Mutual labels:  signal-processing

Savitzky-Golay Filter in C++

Author: Lekan Ogunmolu

Table of Contents

Introduction

Nicely computes the Vandermonde matrix, Savitzky-Golay differentiation filters, and smoothing coefficients for any sequential signal. It is a textbook implementation of the Savitzky-Golay Filter. Initial testing of this code was on a Ubuntu 14.04.02 Trusty OS running Linux 4.4 but will work on any other Linux/Windows/Mac OS machine with little effort.

Below are examples of how the filter smoothes out a noisy depth map data from the kinect time-of-flight sensor:

Dependencies

  • Eigen3 Library for the linear algebra of the matrices, vectors and related algorithms. You can download the 3.2.5 library which I used from here and follow the README instructions after unpacking the tarball to install.

Usage

  • ./savgol

    Options

    • -h or --help: print out the help menu.

    • Example: Compute the savitzky-golay filter coefficients with frame size, F = 5 and polynomial order 3 (these are the default parameters of the filter) for linearly spaced data points between x_min = 900 and x_max = 980. A typical cmd line usage:

      ./savgoal 9 5 where F = 9 and k = 5.

    • To pass in your arbitrary data points between a value x_min and x_max, run this way in order: ./savgoal F k x_min x_max.

    The filtered values are returned to the console. Note that the Frame size should ideally be odd.

Components

  • MatrixXi vander(const int F);

    • Computes the Vandermonde matrix and the polynomial of basis vectors; it flips the vector column-wise, left to right.
  • MatrixXf B = MatrixXf sgdiff(int k, double F)

    • Designs a Savitzky-Golay FIR smoothing filter, B, with polynomial order k and frame size F of convolution coefficients. The polynomial order, k, must be less than the frame size F, and F must be odd.
  • savgolfilt(x, x_on, k, F)

    • Computes the smoothed values of the signal x, whose tansient on is x_on initialized with size F.
  • Note In calculating the transient off, x_off will be the last (F-1) x values, where x's are the data sequence we want to filter.If you are smoothing data offline, then this code will work seamlessly. Just load your data in the main() function where, for an example, I have used linearly spaced values between 900 and 980 at a frame 5 size for my steady state values.

Note, if you are smoothing data in real time, you need to find a way to let your compiler pick the last F-length samples from your data in order to compute your transient off, i.e., x_off. You could have the program wait for x_milliseconds after stopping your code before you pick the transient off, for example.

Compilation

There is a CMakeLists.txt file in the project root folder. From the project root directory:

  1. Create a build directory: mkdir build && cd build
  2. Compile the cpp code: cmake ../
  3. Build your executable: make
  4. Run the executable: ./savgol

Citation

If you have used Savitzky-Golay in your work, please cite it.

@misc{Savitzky-Golay,
  author = {Ogunmolu, Olalekan},
  title = {{Savitzky-Golay Filter in C++}},
  year = {2015},
  howpublished = {\url{https://github.com/lakehanne/Savitzky-Golay}},
  note = {Accessed August 15, 2015}
}

Issues

If you have issues running the files, please use the issues tab to open a bug. I will generally respond within a 24-hour period.

Changelog

  • Added citation to README (August 14, 2015)
  • Added examples to int main() function (August 15, 2015)
  • Modified frame size and polynomial order to be reconfigurable at run time (July 1, 2016)

TODO

Add a plotter to plot the filtered values on a gtk chart?

Reference

INTRODUCTION TO SIGNAL PROCESSING

Sophocles J. Orfanidis, Prentice Hall, 2010

Chapter 8; Section 8.3.5

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].