Skip to content

Instantly share code, notes, and snippets.

View fubel's full-sized avatar
🚀
Work

Fabian Herzog fubel

🚀
Work
View GitHub Profile
@fubel
fubel / behrend.py
Last active January 14, 2018 16:19
Felix A Behrend's Algorithm for Set Coloring used for Communication Complexity
'''
This script is an implementation of Behrend's algorithm for set coloring.
Here we use it for communication complexity:
The question is, if the numbers [x,y,z] add up to n.
You can set n as well as the numbers
'''
import math
import numpy as np
import numpy as np
import matplotlib.pyplot as plt
def fourier_polynomial(f: 'function', n: int, r: int, M: int) -> np.array:
""" Computes the Fourier polynomial of degree n.
Args:
f: Any Python function that returns a float
n: Degree of the Fourier polynomial
@fubel
fubel / radon_transform.py
Created September 4, 2016 09:43
Python implementation of the Radon Transform
""" Radon Transform as described in Birkfellner, Wolfgang. Applied Medical Image Processing: A Basic Course. [p. 344] """
from scipy import misc
import numpy as np
import matplotlib.pyplot as plt
def discrete_radon_transform(image, steps):
R = np.zeros((steps, len(image)), dtype='float64')
for s in range(steps):
rotation = misc.imrotate(image, -s*180/steps).astype('float64')
R[:,s] = sum(rotation)