Skip to main content

High-Performance Non-Linear Filters and Window Functions Library in C++ with Python Bindings

Project description

Logo

High-Performance Non-Linear Filters and Window Functions Library in C++ with Python Bindings

Comprehensive Library for Digital Signal Processing in C++, Python

mohammadraziei - MedianFilterCpp forks - MedianFilterCpp

Python Cpp

License issues - MedianFilterCpp

About The Project

fastfilter is a powerful library written in C++ with Python bindings. It provides you with the capability to use commonly used window functions and non-linear filters that are utilized in digital signal processing. You can use it in both Python and C++.

Features

Here are some key features of fastfilter

  1. Python Bindings

    • Easy Integration: Install the project in Python and use the filters and window functions seamlessly.
    • Cross-Language Compatibility: Utilize the library in both Python and C++ environments.
  2. Common Non-Linear Filters

    • Average Filter: Computes the mean of the surrounding values, smoothing the signal.
    • Median Filter: Reduces noise by replacing each value with the median of neighboring values.
    • Minimum Filter: Selects the smallest value from the surrounding values, useful for edge detection.
    • Maximum Filter: Selects the largest value from the surrounding values, enhancing bright regions.
    • High Performance: Implemented using one of the fastest algorithms to ensure efficient processing.
    • Versatile Usage: Suitable for various signal processing projects.
  3. Window Functions

    • Triangular Window: Simple and efficient, used for basic signal smoothing.
    • Hamming Window: Reduces the side lobes in the frequency domain, improving spectral analysis.
    • Parzen Window: Provides a smooth tapering of the signal, reducing spectral leakage.
    • Hann Window: Minimizes the first side lobe, commonly used in Fourier analysis.
    • Blackman Window: Offers better side lobe suppression, ideal for high-resolution spectral analysis.
    • Gaussian Window: Provides a smooth, bell-shaped curve, useful for time-frequency analysis.
    • Tukey Window: Combines rectangular and Hann windows, offering adjustable side lobe suppression.
  4. Header-Only Implementation

    • Ease of Use: No need for separate compilation, simply include the headers in your project.
    • Portability: Easily integrate into various projects without dependency issues.
  5. Comprehensive Documentation

    • Detailed Guides: Step-by-step instructions for using the filters and window functions.
    • Examples: Practical examples to help you get started quickly.

Usage in python

Using fastfilter is intuitive and straightforward. Below are some examples to help you get started.

Accessing Help

All classes come with a help section to guide you through their usage:

import medianFilter
help(medianFilter)
print(medianFilter.__version__)

Applying Filters

You can easily apply various filters to your signal data. Here are some examples:

Average Filter

import numpy as np
import medianFilter as filt

signal = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
kernelSize = 5
output = filt.movingfilter(signal, kernelSize // 2, 'average')
print(output)

Median Filter

import numpy as np
import medianFilter as filt

signal = np.array([1, 12, 7, 8, 1, 16, 2, 18, 9, 21])
kernelSize = 5
output = filt.movingfilter(signal, kernelSize // 2, 'median')
print(output)

Maximum and Minimum Filters

import numpy as np
import medianFilter as filt

signal = np.array([1, 12, 7, 8, 1, 16, 2, 18, 9, 21])
kernelSize = 5

# Apply maximum filter
output_max = filt.movingfilter(signal, kernelSize // 2, 'maximum')
print(output_max)

# Apply minimum filter
output_min = filt.movingfilter(signal, kernelSize // 2, 'minimum')
print(output_min)

Using Window Functions

You can also apply various window functions to your signal data. Here’s an example of using the Hamming window:

import numpy as np
import windowFunctions as wf

# It should be completed here
# windowFunctions is not binded yet. 

Usage in C++

Integrating fastfilter into your C++ projects is simple.

Applying Filters

You can effortlessly apply various filters to your signal data.

Average Filter

#include <iostream>
#include "medianFilter.h"

int main() { 
    std::vector<float> data {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

    // Create output vector and variables
    std::vector<float> output(data.size());
    const uint32_t halfWindowSize = 2;

    // Apply median filter
    filt::movingFilter(output, data, halfWindowSize, filt::kernel::average);

    // Display the output
    for (const auto& val : output) {
        std::cout << val << " ";
    }
    std::cout << std::endl;

    return 0;
}

Median Filter

#include <iostream>
#include "medianFilter.h"

int main() { 
    std::vector<float> data {1, 12, 7, 8, 1, 16, 2, 18, 9, 21};

    // Create output vector and variables
    std::vector<float> output(data.size());
    const uint32_t halfWindowSize = 2;

    // Apply median filter
    filt::movingFilter(output, data, halfWindowSize, filt::kernel::median);

    // Display the output
    for (const auto& val : output) {
        std::cout << val << " ";
    }
    std::cout << std::endl;

    return 0;
}

Minimum and Maximum Filters

#include <iostream>
#include "medianFilter.h"

int main() { 
    std::vector<float> data {1, 12, 7, 8, 1, 16, 2, 18, 9, 21};

    // Create output vector and variables
    std::vector<float> output(data.size());
    const uint32_t halfWindowSize = 2;

    // Apply minimum filter
    filt::movingFilter(output, data, halfWindowSize, filt::kernel::minimum);

    // Display the output
    std::cout << "Minimum Filter Output: ";
    for (const auto& val : output) {
        std::cout << val << " ";
    }
    std::cout << std::endl;

    // Apply maximum filter
    filt::movingFilter(output, data, halfWindowSize, filt::kernel::maximum);

    // Display the output
    std::cout << "Maximum Filter Output: ";
    for (const auto& val : output) {
        std::cout << val << " ";
    }
    std::cout << std::endl;

    return 0;
}

Using Window Functions

Example 1: Basic Window Functions

#include <iostream>
#include "windowing.h"
#include <vector>

int main(int argc, char** argv) {
    std::vector<float> input = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; 
    std::vector<float> output(input.size()); 

    // Apply various window functions
    window::windowFunction(output, input, input.size(), window::kernel::triangularWindow);
    window::windowFunction(output, input, input.size(), window::kernel::hammingWindow);
    window::windowFunction(output, input, input.size(), window::kernel::parzenWindow);
    window::windowFunction(output, input, input.size(), window::kernel::hannWindow);
    window::windowFunction(output, input, input.size(), window::kernel::blackmanWindow);
    window::windowFunction(output, input, input.size(), window::kernel::triangularWindow);

    return 0; 
}

Example 2: Window Functions with Parameters

#include <iostream>
#include "windowing.h"
#include <vector>

int main(int argc, char** argv) {
    std::vector<float> input = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; 
    std::vector<float> output(input.size()); 

    const float parameter = 0.3; 

    // Apply window functions with parameters
    window::windowFunction(output, input, input.size(), parameter, window::kernel::gaussianWindow); 
    window::windowFunction(output, input, input.size(), parameter, window::kernel::tukeyWindow); 

    return 0; 
}

These examples demonstrate how to use various window functions provided by the library. The first example shows basic window functions, while the second example includes window functions that require additional parameters.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastfilter-0.0.3.tar.gz (45.4 kB view hashes)

Uploaded Source

Built Distributions

fastfilter-0.0.3-cp313-cp313-win_amd64.whl (138.9 kB view hashes)

Uploaded CPython 3.13 Windows x86-64

fastfilter-0.0.3-cp313-cp313-win32.whl (117.0 kB view hashes)

Uploaded CPython 3.13 Windows x86

fastfilter-0.0.3-cp313-cp313-musllinux_1_2_x86_64.whl (647.0 kB view hashes)

Uploaded CPython 3.13 musllinux: musl 1.2+ x86-64

fastfilter-0.0.3-cp313-cp313-musllinux_1_2_i686.whl (700.4 kB view hashes)

Uploaded CPython 3.13 musllinux: musl 1.2+ i686

fastfilter-0.0.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (126.0 kB view hashes)

Uploaded CPython 3.13 manylinux: glibc 2.17+ x86-64

fastfilter-0.0.3-cp313-cp313-manylinux_2_17_i686.manylinux2014_i686.whl (136.6 kB view hashes)

Uploaded CPython 3.13 manylinux: glibc 2.17+ i686

fastfilter-0.0.3-cp312-cp312-win_amd64.whl (138.7 kB view hashes)

Uploaded CPython 3.12 Windows x86-64

fastfilter-0.0.3-cp312-cp312-win32.whl (117.0 kB view hashes)

Uploaded CPython 3.12 Windows x86

fastfilter-0.0.3-cp312-cp312-musllinux_1_2_x86_64.whl (647.0 kB view hashes)

Uploaded CPython 3.12 musllinux: musl 1.2+ x86-64

fastfilter-0.0.3-cp312-cp312-musllinux_1_2_i686.whl (700.4 kB view hashes)

Uploaded CPython 3.12 musllinux: musl 1.2+ i686

fastfilter-0.0.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (126.0 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

fastfilter-0.0.3-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl (136.6 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ i686

fastfilter-0.0.3-cp311-cp311-win_amd64.whl (149.6 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

fastfilter-0.0.3-cp311-cp311-win32.whl (128.8 kB view hashes)

Uploaded CPython 3.11 Windows x86

fastfilter-0.0.3-cp311-cp311-musllinux_1_2_x86_64.whl (651.8 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.2+ x86-64

fastfilter-0.0.3-cp311-cp311-musllinux_1_2_i686.whl (705.8 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.2+ i686

fastfilter-0.0.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (131.3 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

fastfilter-0.0.3-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl (142.5 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ i686

fastfilter-0.0.3-cp310-cp310-win_amd64.whl (147.3 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

fastfilter-0.0.3-cp310-cp310-win32.whl (126.8 kB view hashes)

Uploaded CPython 3.10 Windows x86

fastfilter-0.0.3-cp310-cp310-musllinux_1_2_x86_64.whl (652.0 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.2+ x86-64

fastfilter-0.0.3-cp310-cp310-musllinux_1_2_i686.whl (705.8 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.2+ i686

fastfilter-0.0.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (131.9 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

fastfilter-0.0.3-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl (142.7 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ i686

fastfilter-0.0.3-cp39-cp39-win_amd64.whl (148.1 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

fastfilter-0.0.3-cp39-cp39-win32.whl (127.7 kB view hashes)

Uploaded CPython 3.9 Windows x86

fastfilter-0.0.3-cp39-cp39-musllinux_1_2_x86_64.whl (651.9 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.2+ x86-64

fastfilter-0.0.3-cp39-cp39-musllinux_1_2_i686.whl (705.8 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.2+ i686

fastfilter-0.0.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (131.8 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

fastfilter-0.0.3-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl (142.6 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ i686

fastfilter-0.0.3-cp38-cp38-win_amd64.whl (147.1 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

fastfilter-0.0.3-cp38-cp38-win32.whl (127.1 kB view hashes)

Uploaded CPython 3.8 Windows x86

fastfilter-0.0.3-cp38-cp38-musllinux_1_2_x86_64.whl (651.9 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.2+ x86-64

fastfilter-0.0.3-cp38-cp38-musllinux_1_2_i686.whl (705.4 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.2+ i686

fastfilter-0.0.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (131.7 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

fastfilter-0.0.3-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl (142.2 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ i686

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page