@staticmethod
def diff_normalize_data(data):
"""Calculate discrete difference in video data along the time-axis and nornamize by its standard deviation."""
n, h, w, c = data.shape
diffnormalized_len = n - 1
diffnormalized_data = np.zeros((diffnormalized_len, h, w, c), dtype=np.float32)
diffnormalized_data_padding = np.zeros((1, h, w, c), dtype=np.float32)
for j in range(diffnormalized_len - 1):
diffnormalized_data[j, :, :, :] = (data[j + 1, :, :, :] - data[j, :, :, :]) / (
data[j + 1, :, :, :] + data[j, :, :, :] + 1e-7)
diffnormalized_data = diffnormalized_data / np.std(diffnormalized_data)
diffnormalized_data = np.append(diffnormalized_data, diffnormalized_data_padding, axis=0)
diffnormalized_data[np.isnan(diffnormalized_data)] = 0
return diffnormalized_data
diffnormalized_len = n - 1, there are two times of minus 1 operation, causing the last two image of diffnormalized_databeing zeros. I suppose the range of j would be range(diffnormalized_len) not range(diffnormalized_len - 1)
diffnormalized_len = n - 1
, there are two times of minus 1 operation, causing the last two image ofdiffnormalized_data
being zeros. I suppose the range ofj
would berange(diffnormalized_len)
notrange(diffnormalized_len - 1)