InĀ [1]:
#%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
InĀ [3]:
pad_input = np.load('PAD1_5010_5110.npy')
num_rows_total, num_buttons = pad_input.shape
InĀ [Ā ]:
pad_input.shape
Out[Ā ]:
(12000, 24)
InĀ [Ā ]:
plt.imshow(pad_input[:200], cmap='hot', interpolation='nearest')
Out[Ā ]:
<matplotlib.image.AxesImage at 0x7fae238f97e0>
aX+b -> E(aX+b) = E(xref) -> a E(X) + b = E(xref) -> E((aX+b - E(aX+b)Ā²) = sigma_refĀ² A * [E(X) , 1] = E(X_ref) A *
InĀ [4]:
for column in range(0, pad_input.shape[1], 10):
# plt.imshow(pad_in.reshape(10, 10), cmap='gray', interpolation='nearest')
# plt.show()
plt.hist(pad_input[:800, column].flatten(), bins=100, alpha=0.2)
InĀ [15]:
pad_patch = pad_input[:800, :]
avg, std = np.mean(pad_patch, axis=0), np.std(pad_patch, axis=0)
InĀ [16]:
ref = pad_input.shape[1] //2
pad_patch_corrected = std[ref]*(pad_patch-avg)/std + avg[ref]
InĀ [17]:
for column in range(0, pad_input.shape[1], 10):
# plt.imshow(pad_in.reshape(10, 10), cmap='gray', interpolation='nearest')
# plt.show()
plt.subplot(1, 2, 1)
plt.hist(pad_patch_corrected[:, column], bins=100, alpha=0.2)
plt.subplot(1, 2, 2)
plt.hist(pad_patch[:, column], bins=100, alpha=0.2)
plt.subplot(1, 2, 1)
plt.xlim(0, 80000)
plt.subplot(1, 2, 2)
plt.xlim(0, 80000)
plt.show()
InĀ [18]:
np.mean(pad_patch_corrected, axis=0), np.std(pad_patch_corrected, axis=0)
Out[18]:
(array([34258.50519375, 34258.50519375, 34258.50519375, 34258.50519375, 34258.50519375, 34258.50519375, 34258.50519375, 34258.50519375, 34258.50519375, 34258.50519375, 34258.50519375, 34258.50519375, 34258.50519375, 34258.50519375, 34258.50519375, 34258.50519375, 34258.50519375, 34258.50519375, 34258.50519375, 34258.50519375, 34258.50519375, 34258.50519375, 34258.50519375, 34258.50519375]), array([13394.2918277, 13394.2918277, 13394.2918277, 13394.2918277, 13394.2918277, 13394.2918277, 13394.2918277, 13394.2918277, 13394.2918277, 13394.2918277, 13394.2918277, 13394.2918277, 13394.2918277, 13394.2918277, 13394.2918277, 13394.2918277, 13394.2918277, 13394.2918277, 13394.2918277, 13394.2918277, 13394.2918277, 13394.2918277, 13394.2918277, 13394.2918277]))
InĀ [19]:
plt.figure(figsize=(20, 5))
plt.subplot(211)
plt.title("raw")
plt.imshow(pad_patch.T, cmap='hot', interpolation='nearest')
plt.subplot(212)
plt.title("corrected")
plt.imshow(pad_patch_corrected.T, cmap='hot', interpolation='nearest')
plt.show()
InĀ [20]:
plt.subplot(121)
plt.imshow(pad_patch[:200], cmap='gray', interpolation='nearest')
plt.subplot(122)
plt.imshow(pad_patch_corrected[:200], cmap='gray', interpolation='nearest')
Out[20]:
<matplotlib.image.AxesImage at 0x7fae20c1b8b0>