Advertisement
hbar

scaler2.py

Nov 14th, 2013
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  1. import matplotlib.image as mpimg
  2. import matplotlib.pyplot as plt
  3. import numpy as np
  4.  
  5.  
  6. img = mpimg.imread("dw20.png")
  7.  
  8. img = 15*img
  9.  
  10.  
  11. f = open("dw.txt","w")
  12. for r in range(len(img)):
  13.     for c in range(len(img[0])):
  14.             pixel = img[r][c]
  15.             hexstr = "0x%0.2X%0.2X%0.2X" % (16*int(round(pixel[0])),16*int(round(pixel[1])),16*int(round(pixel[2])))
  16.             f.write(hexstr)
  17.     f.write("\n")
  18. f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement