暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

visualize_frame.py 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/env python
  2. import matplotlib.pyplot as plt
  3. import numpy as np
  4. import sys
  5. import math
  6. if len(sys.argv) < 2:
  7. print("Usage:")
  8. print(" " + sys.argv[0] + " filename [...]")
  9. sys.exit(0)
  10. fig, axes = plt.subplots(1, len(sys.argv) - 1, figsize=(15, 5))
  11. # support one or multiple files
  12. if not isinstance(axes, np.ndarray):
  13. axes = [axes]
  14. for n in range(0, len(sys.argv) - 1):
  15. print("reading " + sys.argv[n + 1])
  16. frame = []
  17. with open(sys.argv[n + 1]) as f:
  18. lines = f.readlines()
  19. for line in lines:
  20. nums = line.split()
  21. for r in nums:
  22. frame.append(int(r, 16))
  23. print("frame length: " + str(len(frame)))
  24. row_len = math.sqrt(len(frame))
  25. print("row length: " + str(row_len))
  26. row_len = int(row_len)
  27. frame2d = []
  28. for i in range(0, row_len):
  29. row = []
  30. for j in range(0, row_len):
  31. row.append(frame[i * row_len + j])
  32. frame2d.append(row)
  33. im = axes[n].imshow(frame2d, vmin=0, vmax=0xFF, cmap='plasma')
  34. axes[n].set_title(sys.argv[n + 1], fontsize=18)
  35. fig.colorbar(im, ax=axes, label='Value Range')
  36. plt.suptitle('Pan and Zoom on colorbar to adjust', fontsize=10)
  37. plt.show()