Skip to content

Instantly share code, notes, and snippets.

@pmneila
pmneila / plot.py
Last active July 4, 2024 16:15
Plot MMs
offsets = model.offsets(psa_angles)
plt.plot(offsets[:, 1], offsets[:, 0], '.-')
# plt.plot(offsets_bicubic[:, 1], offsets_bicubic[:, 0], '.-')
plt.plot(offsets[0, 1], offsets[0, 0], 'o')
plt.axis('equal')
plt.gca().invert_yaxis()
plt.xlabel(r"$\Delta{}x$ (px)", fontsize=14)
plt.ylabel(r"$\Delta{}y$ (px)", fontsize=14)
@pmneila
pmneila / maxflow_test.py
Created October 11, 2014 23:52
A PyMaxflow example
import numpy as np
import maxflow
from matplotlib import pyplot as plt
import networkx as nx
def plot_graph(nxgraph):
X, Y = np.mgrid[:5, :5]
@pmneila
pmneila / leaky_double.cpp
Created November 11, 2013 06:39
Example of numerical issues with double values.
#include <iostream>
int main()
{
double val1 = -10.0 + 0.4*14 + 0.4;
double val2 = -10.0 + 0.4*15;
std::cout << "val1 = " << val1 << "; val2 = " << val2 << std::endl;
std::cout << (val1 == val2 ? "Equal" : "Not equal") << std::endl;
import sys
import numpy as np
from scipy import ndimage
from scipy.misc import imread, imsave
def transform(X, Y, scale1, scale2):
shape = np.float_(X.max()), np.float_(Y.max())
X = X - shape[0]/2