Skip to content

Instantly share code, notes, and snippets.

@Schizo
Created November 29, 2017 23:41
Show Gist options
  • Save Schizo/3e70265767afcc66155b238e7155b76c to your computer and use it in GitHub Desktop.
Save Schizo/3e70265767afcc66155b238e7155b76c to your computer and use it in GitHub Desktop.
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