All Projects → hbldh → pyefd

hbldh / pyefd

Licence: MIT license
Python implementation of "Elliptic Fourier Features of a Closed Contour"

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to pyefd

Amazing Feature Engineering
Feature engineering is the process of using domain knowledge to extract features from raw data via data mining techniques. These features can be used to improve the performance of machine learning algorithms. Feature engineering can be considered as applied machine learning itself.
Stars: ✭ 218 (+207.04%)
Mutual labels:  feature-extraction, features
ImageCluster
Image cluster 图像聚类
Stars: ✭ 18 (-74.65%)
Mutual labels:  feature-extraction
Tf featureextraction
Convenient wrapper for TensorFlow feature extraction from pre-trained models using tf.contrib.slim
Stars: ✭ 169 (+138.03%)
Mutual labels:  feature-extraction
Bert Attributeextraction
USING BERT FOR Attribute Extraction in KnowledgeGraph. fine-tuning and feature extraction. 使用基于bert的微调和特征提取方法来进行知识图谱百度百科人物词条属性抽取。
Stars: ✭ 224 (+215.49%)
Mutual labels:  feature-extraction
Variational Ladder Autoencoder
Implementation of VLAE
Stars: ✭ 196 (+176.06%)
Mutual labels:  feature-extraction
Computer Vision Guide
📖 This guide is to help you understand the basics of the computerized image and develop computer vision projects with OpenCV. Includes Python, Java, JavaScript, C# and C++ examples.
Stars: ✭ 244 (+243.66%)
Mutual labels:  feature-extraction
Emotion Recognition Using Speech
Building and training Speech Emotion Recognizer that predicts human emotions using Python, Sci-kit learn and Keras
Stars: ✭ 159 (+123.94%)
Mutual labels:  feature-extraction
dspfun
Set of *nix utilities for experimentation and learning about spectral analysis of images
Stars: ✭ 21 (-70.42%)
Mutual labels:  fourier-series
Face.evolve.pytorch
🔥🔥High-Performance Face Recognition Library on PaddlePaddle & PyTorch🔥🔥
Stars: ✭ 2,719 (+3729.58%)
Mutual labels:  feature-extraction
Radiomics-research-by-using-Python
Radiomics (here mainly means hand-crafted based radiomics) contains data acquire, ROI segmentation, feature extraction, feature selection, machine learning modeling, and stastical analysis.
Stars: ✭ 27 (-61.97%)
Mutual labels:  feature-extraction
Piccante
The hottest High Dynamic Range (HDR) Library
Stars: ✭ 195 (+174.65%)
Mutual labels:  feature-extraction
Tsfel
An intuitive library to extract features from time series
Stars: ✭ 202 (+184.51%)
Mutual labels:  feature-extraction
Deep Learning Machine Learning Stock
Stock for Deep Learning and Machine Learning
Stars: ✭ 240 (+238.03%)
Mutual labels:  feature-extraction
Apkfile
Android app analysis and feature extraction library
Stars: ✭ 190 (+167.61%)
Mutual labels:  feature-extraction
contour-rs
Contour polygon creation in Rust (using marching squares algorithm)
Stars: ✭ 33 (-53.52%)
Mutual labels:  contours
Augmented reality
💎 "Marker-less Augmented Reality" with OpenCV and OpenGL.
Stars: ✭ 165 (+132.39%)
Mutual labels:  feature-extraction
Pliers
Automated feature extraction in Python
Stars: ✭ 243 (+242.25%)
Mutual labels:  feature-extraction
machine learning course
Artificial intelligence/machine learning course at UCF in Spring 2020 (Fall 2019 and Spring 2019)
Stars: ✭ 47 (-33.8%)
Mutual labels:  feature-extraction
bob
Bob is a free signal-processing and machine learning toolbox originally developed by the Biometrics group at Idiap Research Institute, in Switzerland. - Mirrored from https://gitlab.idiap.ch/bob/bob
Stars: ✭ 38 (-46.48%)
Mutual labels:  feature-extraction
tsflex
Flexible time series feature extraction & processing
Stars: ✭ 252 (+254.93%)
Mutual labels:  feature-extraction

PyEFD

Build and Test Documentation Status image image image

An Python/NumPy implementation of a method for approximating a contour with a Fourier series, as described in [1].

Installation

pip install pyefd

Usage

Given a closed contour of a shape, generated by e.g. scikit-image or OpenCV, this package can fit a Fourier series approximating the shape of the contour.

General usage examples

This section describes the general usage patterns of pyefd.

from pyefd import elliptic_fourier_descriptors
coeffs = elliptic_fourier_descriptors(contour, order=10)

The coefficients returned are the a_n, b_n, c_n and d_n of the following Fourier series representation of the shape.

The coefficients returned are by default normalized so that they are rotation and size-invariant. This can be overridden by calling:

from pyefd import elliptic_fourier_descriptors
coeffs = elliptic_fourier_descriptors(contour, order=10, normalize=False)

Normalization can also be done afterwards:

from pyefd import normalize_efd
coeffs = normalize_efd(coeffs)

OpenCV example

If you are using OpenCV to generate contours, this example shows how to connect it to pyefd.

import cv2 
import numpy
from pyefd import elliptic_fourier_descriptors

# Find the contours of a binary image using OpenCV.
contours, hierarchy = cv2.findContours(
    im, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)

# Iterate through all contours found and store each contour's 
# elliptical Fourier descriptor's coefficients.
coeffs = []
for cnt in contours:
    # Find the coefficients of all contours
    coeffs.append(elliptic_fourier_descriptors(
        numpy.squeeze(cnt), order=10))

Using EFD as features

To use these as features, one can write a small wrapper function:

from pyefd import elliptic_fourier_descriptors

def efd_feature(contour):
    coeffs = elliptic_fourier_descriptors(contour, order=10, normalize=True)
    return coeffs.flatten()[3:]

If the coefficients are normalized, then coeffs[0, 0] = 1.0, coeffs[0, 1] = 0.0 and coeffs[0, 2] = 0.0, so they can be disregarded when using the elliptic Fourier descriptors as features.

See [1] for more technical details.

Testing

Run tests with with Pytest:

py.test tests.py

The tests include a single image from the MNIST dataset of handwritten digits ([2]) as a contour to use for testing.

Documentation

See ReadTheDocs.

References

[1]: Frank P Kuhl, Charles R Giardina, Elliptic Fourier features of a closed contour, Computer Graphics and Image Processing, Volume 18, Issue 3, 1982, Pages 236-258, ISSN 0146-664X, http://dx.doi.org/10.1016/0146-664X(82)90034-X.

[2]: LeCun et al. (1999): The MNIST Dataset Of Handwritten Digits

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].