Exercise 1b: Read a binary file which contains pixel data and apply transformations
import numpy as np
import matplotlib.pyplot as plt
# load figure as 2D array
data = np.load('horse.npy')
print(data.shape)
(2, 59520)
# just scale the data by a factor and shift by trans
trans = np.ones(data.shape)
trans[0,:] *=0.6
trans[1,:] *=0.4
factor = 0.5
data_scale = data * factor + trans
#compression in x and y
sx = 0.4
sy = 0.9
t = np.array([[sx,0],[0,sy]])
data_comp = t@data