1#!/usr/bin/env python 2 3"""Helper script for creating image .dat files by numpy.save 4 5Usage: 6 7 python create_dat.py <name of image file> <name of dat file> 8 9Example (to create aero.dat): 10 11 python create_dat.py aero.png aero.dat 12 13Requires Scipy and PIL. 14""" 15 16from __future__ import print_function 17 18import sys 19 20import numpy as np 21 22 23def main(): 24 from scipy.misc import imread 25 26 if len(sys.argv) != 3: 27 print(__doc__) 28 exit() 29 30 image_fname = sys.argv[1] 31 dat_fname = sys.argv[2] 32 33 data = imread(image_fname) 34 35 np.savez_compressed(dat_fname, data=data) 36 37 38if __name__ == "__main__": 39 main() 40