- /cygdrive/c/Users/Admin/Desktop/DMU/code/image_processing>
#!/usr/bin/python # -*- coding: utf-8 -*- # -------------------------------------------------- # File Name: toIm.py # Purpose: # Creation Date: 20-04-2017 # Last Modified: Thu, Apr 20, 2017 2:03:38 PM # Author(s): Mike Stout # Copyright 2017 The Author(s) All Rights Reserved # Credits: # -------------------------------------------------- import sys import numpy as np from PIL import Image import matplotlib.pyplot as plt def readFile(s): f = open(s) a = [] for line in f.readlines(): a.append(map(ord, line)) f.close() return np.array(a, dtype=np.float32) name=sys.argv[1] a = readFile(name).T a = 32/a[:10000] print a a.shape=100,100 im = Image.fromarray(np.uint8(plt.cm.gist_rainbow(a)*255)) im.save(name+".png")