Skip to content

Instantly share code, notes, and snippets.

@ctralie
ctralie / Airplane.txt
Created September 1, 2018 13:38
CurvatureScaleSpace
64 235 65 234 66 234 67 234 68 233 69 233 70 233 71 232 72 232 73 232 74 232 75 232 76 231 77 231 78 231 79 231 80 231 81 230 82 230 83 230 84 230 85 230 86 230 87 230 88 230 89 230 90 230 91 229 92 229 93 229 94 229 95 229 96 229 97 229 98 229 99 229 100 229 101 228 102 227 101 226 100 226 99 226 99 225 99 224 100 224 101 224 101 225 102 226 103 226 104 226 105 227 106 227 107 227 108 226 109 226 110 226 111 226 112 226 113 225 114 225 115 225 116 225 117 225 118 224 119 224 120 224 121 224 122 224 123 224 124 223 125 223 126 223 127 222 128 222 129 222 130 222 131 222 132 222 133 221 134 221 135 221 136 221 137 221 138 221 139 221 140 221 141 221 142 221 143 221 144 221 145 221 146 221 147 221 148 221 149 221 150 221 151 221 152 221 153 221 154 221 155 221 156 221 157 221 158 221 159 221 160 221 161 221 162 221 163 221 164 221 165 221 166 221 167 221 168 221 169 221 170 221 171 221 172 221 173 221 174 221 175 221 176 221 177 221 178 221 179 221 180 221 181 221 182 221 183 221 184 221 185 221 186 221 187 221
@ctralie
ctralie / ConnectionLaplacian.py
Created January 9, 2019 22:31
The connection Laplacian and its use for synchronizing a set of vectors on an NxN grid
"""
Programmer: Chris Tralie (ctralie@alumni.princeton.edu)
Purpose: To implement the connection Laplacian and show its use
for synchronizing a set of vectors on an NxN grid
"""
import numpy as np
import numpy.linalg as linalg
from scipy import sparse
from scipy.sparse.linalg import lsqr, cg, eigsh
import matplotlib.pyplot as plt
@ctralie
ctralie / makeColorScatterplots.py
Created January 31, 2019 15:59
Plot "time-ordered point clouds" with colors on the rainbow to indicate the time
"""
Programmer: Chris Tralie
Purpose: To show how to plot "time-ordered point clouds"
with colors on the rainbow to indicate the time
(red beginning, magenta end)
"""
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
@ctralie
ctralie / EDMExample.py
Created November 9, 2019 00:16
Fast Euclidean Distance Matrix Computaiton
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
def getEDM(X):
"""
Compute an all pairs distance matrix using broadcasting
and matrix multiplications to speed up computations
Parameters
----------
@ctralie
ctralie / coolpattern.py
Created March 3, 2020 01:31
Bad Sampling Triangle Wave = Amazing Pattern
import numpy as np
import scipy.io.wavfile as wavfile
import matplotlib.pyplot as plt
duration = 20
fs = 44100
y = np.zeros(fs*duration)
n_harmonics = 5
t = np.arange(fs*duration) # INCORRECT SAMPLING
#t = np.linspace(0, duration, fs*duration) # CORRECT SAMPLING
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ctralie
ctralie / SquareWave.ipynb
Created February 16, 2021 23:11
DFT of Time Shifting Square Wave
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ctralie
ctralie / VoronoiBrutAnim.py
Created April 16, 2021 02:46
Brute Force Voronoi Animation with Moving Sites in Matplotlib
import numpy as np
import matplotlib.pyplot as plt
from scipy.spatial import KDTree
# Generate some number of sites in
# the square [0, 1] x [0, 1]
np.random.seed(0)
n_sites = 20
sites = np.random.rand(n_sites, 2)
# Create random velocities
@ctralie
ctralie / colormap.py
Created July 5, 2021 15:46
Colormaps
import matplotlib.pyplot as plt
from matplotlib import cm
import numpy as np
from skimage import data
from skimage.color import rgb2gray
from colorspacious import cspace_converter
I = data.astronaut()
I = rgb2gray(I)
cmaps = ['gray', 'magma', 'jet', 'RdGy']
@ctralie
ctralie / Cantor.ipynb
Created October 21, 2021 14:35
Cantor Function Approximation
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.