All Projects → mikepound → Convolve

mikepound / Convolve

Licence: unlicense
Simple demonstration of separable convolutions

Programming Languages

python
139335 projects - #7 most used programming language
cython
566 projects

Projects that are alternatives of or similar to Convolve

Ganja.js
📐 Javascript Geometric Algebra Generator for Javascript, c++, c#, rust, python. (with operator overloading and algebraic literals) -
Stars: ✭ 1,179 (+495.45%)
Mutual labels:  complex-numbers
Calc
C-style arbitrary precision calculator
Stars: ✭ 127 (-35.86%)
Mutual labels:  complex-numbers
Rocket
ROCKET: Exceptionally fast and accurate time series classification using random convolutional kernels
Stars: ✭ 163 (-17.68%)
Mutual labels:  convolution
Pyspeechrev
This python code performs an efficient speech reverberation starting from a dataset of close-talking speech signals and a collection of acoustic impulse responses.
Stars: ✭ 74 (-62.63%)
Mutual labels:  convolution
Algebra
means completeness and balancing, from the Arabic word الجبر
Stars: ✭ 92 (-53.54%)
Mutual labels:  complex-numbers
Jamesdspmanager
Audio DSP effects build on Android system framework layer. This is a repository contains a pack of high quality DSP algorithms specialized for audio processing.
Stars: ✭ 136 (-31.31%)
Mutual labels:  convolution
Swift Complex
Complex numbers in Swift
Stars: ✭ 66 (-66.67%)
Mutual labels:  complex-numbers
Etl
Blazing-fast Expression Templates Library (ETL) with GPU support, in C++
Stars: ✭ 190 (-4.04%)
Mutual labels:  convolution
Numphp
Mathematical PHP library for scientific computing
Stars: ✭ 120 (-39.39%)
Mutual labels:  complex-numbers
Sparse Winograd Cnn
Efficient Sparse-Winograd Convolutional Neural Networks (ICLR 2018)
Stars: ✭ 156 (-21.21%)
Mutual labels:  convolution
Pytsetlinmachine
Implements the Tsetlin Machine, Convolutional Tsetlin Machine, Regression Tsetlin Machine, Weighted Tsetlin Machine, and Embedding Tsetlin Machine, with support for continuous features, multigranularity, and clause indexing
Stars: ✭ 80 (-59.6%)
Mutual labels:  convolution
Calci Kernel
A complex calculation kernel in Java (for Calci calculator)
Stars: ✭ 90 (-54.55%)
Mutual labels:  complex-numbers
Psconv
[ECCV 2020] PSConv: Squeezing Feature Pyramid into One Compact Poly-Scale Convolutional Layer
Stars: ✭ 138 (-30.3%)
Mutual labels:  convolution
Scidart
Multiplatform scientific computing for Dart
Stars: ✭ 73 (-63.13%)
Mutual labels:  convolution
Complex.js
A complex number library
Stars: ✭ 165 (-16.67%)
Mutual labels:  complex-numbers
Coordconv
Pytorch implementation of "An intriguing failing of convolutional neural networks and the CoordConv solution" - https://arxiv.org/abs/1807.03247
Stars: ✭ 72 (-63.64%)
Mutual labels:  convolution
Mathjs
An extensive math library for JavaScript and Node.js
Stars: ✭ 11,861 (+5890.4%)
Mutual labels:  complex-numbers
Laser
The HPC toolbox: fused matrix multiplication, convolution, data-parallel strided tensor primitives, OpenMP facilities, SIMD, JIT Assembler, CPU detection, state-of-the-art vectorized BLAS for floats and integers
Stars: ✭ 191 (-3.54%)
Mutual labels:  convolution
Big Math
Advanced Java BigDecimal math functions (pow, sqrt, log, sin, ...) using arbitrary precision.
Stars: ✭ 173 (-12.63%)
Mutual labels:  complex-numbers
Pyeco
python implementation of efficient convolution operators for tracking
Stars: ✭ 150 (-24.24%)
Mutual labels:  convolution

convolve

Simple demonstration of separable convolutions. This includes a standard gaussian blur, and a more recent lens blur using complex kernels. This is a demo project only, it could contain errors!

Gaussian Blur

I've written this in python 3 using cython for a significant speed boost. In most cases if you want to use convolutions you're safer using a library like numpy or opencv. These tend to use a fourier transform for large convolutions, so I avoided them here just to show the performance benefits.

Python

To run this code you'll need python 3, and cython installed. I've used this in linux, it should port fairly easily to other operating systems. Cython in windows is a little more difficult, but doable!

Compiling with Cython

Cython compiles your (almost) python into C, which you then compile into a python module. You can compile using cython like this:

cython -a compute.pyx

The -a flag outputs a nice HTML file showing where C and Python interact. I've optimised this code for C, so there aren't many yellow lines. It was a lot worse when I started!

This will produce a c file, which you compile using something like this:

gcc -shared -pthread -fPIC -fwrapv -O2 -Wall -fno-strict-aliasing -I/usr/include/python3.6m -o compute.so compute.c

Notice you need to point the compiler ar your installed python headers - which may not be in the same place as mine.

If compilation is successful, then you'll obtain a compute.so file, which can be imported from python as normal. Windows compilation will be a little more complex, as gcc isn't available to you. Here might help!

Running the code

You can run the code like this:

python run.gaussian.py --sigma 3.0 ./christmas.jpg ./christmas.out.jpg

My included christmas tree picture is fairly large, so even a small convolution will take a while. You'll see quite a difference if you run this with the --no_separable_filters option though.

Lens Blur

This is also written in python 3, without cython this time. Complex convolutions aren't too difficuly, but I decided the scypi library was easier here. This lens blur is the sum of a number of components, which means that the time taken scales linearly with the number of components you wish to use. Larger images with high component counts will take a fair while!

Running the code

You can run the code like this:

python run.lens.py --radius 50 --components 3 --exposure_gamma 3 ./M35.jpg ./M35.out.jpg

I found numpy raises memory issues if you use very large images, avoiding the stack function would probably fix this, but I decided not to worry about it.

One interesting difference between this simulated lens blur and a real lens is that the lighting works differently. I used a gamma-like function to increase the exposure prior to convolving, and then reverse this afterwards, I found this tends to highlight the brighter areas of the image, but results will depend on your settings, and the image you are filtering.

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