Advertisement
Svotin

Untitled

Jan 21st, 2022
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. from PIL import Image
  2. import numpy as np
  3.  
  4. with open("vl53l5cx_16x16_w_obstacle.txt") as f:
  5. lines = f.readlines()
  6.  
  7. imageNumber = int(input("Введите номер изображения: "))
  8.  
  9. line = lines[imageNumber].replace("\n", "").split(",")
  10.  
  11. # convert string array to
  12. intArray = [int(n) for n in line]
  13.  
  14. w, h = 8, 8
  15. matrix = np.zeros((h, w), dtype=np.uint8)
  16. count = 0
  17. for i in range(0, 64, 8):
  18. matrix[count] = intArray[i:i+8]
  19. count += 1
  20.  
  21. print(matrix)
  22. img = Image.fromarray(matrix, 'L')
  23. img.save('my.png')
  24. img.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement