Max_Leb

Untitled

Mar 19th, 2023
672
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. import math as mt
  2. import numpy as np
  3. from PIL import Image
  4.  
  5. f = open("data.txt")
  6.  
  7. data = []
  8.  
  9. height = 7340
  10. width = 8680
  11. m = 0
  12.  
  13. for i in range(height):
  14.     line = f.readline()
  15.     data.append(list(map(float, line.split())))
  16.  
  17.  
  18. for i in range(height):
  19.     m = max(m, max(data[i]))
  20.  
  21. pic = np.zeros([height, width, 3], dtype=np.uint8)
  22.  
  23. for i in range(height):
  24.     for j in range(width):
  25.         if(data[i][j] == 0):
  26.             pic[i][j] = 0
  27.         else:
  28.             pic[i][j] = 255 * mt.log(data[i][j], m)
  29.  
  30. img = Image.fromarray(pic)
  31. img.save('imrgb3.png')
  32.  
  33. f.close()
Advertisement
Add Comment
Please, Sign In to add comment