# Script to visualize image generated by sensor simulations

import numpy as np
import matplotlib.pyplot as plt
import os.path
import sys

WIDTH = 16
HEIGHT = 16

# Script supports width and height parameter when running script
if (len(sys.argv) == 3):
    WIDTH=(int)(sys.argv[1])
    HEIGHT=(int)(sys.argv[2])

script_dir = os.path.dirname(os.path.abspath(__file__))

arr = np.loadtxt(os.path.join(script_dir, '../output/image.log'), dtype=int)

# Change from 1D array of pixel values to a 2d array where 
# width and height are equal to sensor pixel array width and height
arrReshape = np.reshape(arr, (HEIGHT, WIDTH))

plt.imshow(arrReshape, cmap='Greys', interpolation='none')
plt.axis('off')
# plt.savefig(os.path.join(script_dir, 'hello_world_24.png'), bbox_inches='tight')
plt.show()
