Skip to content

Instantly share code, notes, and snippets.

@Schizo
Created Nov 29, 2017
Embed
What would you like to do?
import numpy as np
from scipy.interpolate import interp1d
from scipy.misc import imresize
import cv2
def mapCharacters(a):
m = interp1d([0,255],[0,22])
stamps = " .,:;irsXA253hMHGS#9B&@"
return stamps[int(m(a))]
img = cv2.imread("spidyHead.png", 0)
resizedIMG = imresize(img, (img.shape[0]/2, img.shape[1]/2))
afunc = np.vectorize(mapCharacters)
out = afunc(resizedIMG)
np.savetxt("test.txt", out, delimiter=',', fmt='%s')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment