Skip to content

Instantly share code, notes, and snippets.

View ndvbd's full-sized avatar

ndvb ndvbd

  • Self
View GitHub Profile
@ndvbd
ndvbd / SparseConnectedComponents.cpp
Created October 19, 2017 14:42
SparseConnectedComponents - Efficient Algorithm for Finding the Connected Components of Binary OpenCV Mat and Compute Their Center of Mass
// Written by Nadav Benedek 2017
#include "SparseConnectedComponents.h"
#include <iostream>
#include "opencv2/opencv.hpp"
SparseConnectedComponents::SparseConnectedComponents() {
}
@ndvbd
ndvbd / approx_sinc_interp.py
Created March 7, 2017 13:12
Upsampling - Approximated Sinc Interpolation in Python
# Written by Nadav Benedek
import numpy as np
from numba import jit, autojit
import scipy
@jit(nopython=True)
def approx_sinc_interp(x, s, u):
MAX_ELEMENTS_TO_TAKE_EACH_SIDE = 20 # Change this number to change the accuracy
result = np.empty(len(u))
def sinc_interp(x, s, u):
"""
Interpolates x, sampled at "s" instants
Output y is sampled at "u" instants ("u" for "upsampled")
"""
if len(x) != len(s):
raise Exception, 'x and s must be the same length'