ubicomplab / rPPG-Toolbox

rPPG-Toolbox: Deep Remote PPG Toolbox (NeurIPS 2023)
https://arxiv.org/abs/2210.00716
Other
442 stars 106 forks source link

is here a mistake? #224

Closed lddbetta closed 9 months ago

lddbetta commented 9 months ago
@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)

yahskapar commented 9 months ago

I think you're right, good catch, @lddbetta! I'll put up a PR for this soon.

yahskapar commented 9 months ago

This will be fixed as soon as #225 is approved and merged, thanks again for pointing this out.