PartyTrix / Amplitude_selective_filtering

As described in: Amplitude-selective filtering for remote-PPG by Wang, den Brinker, Stuijk & de Haan
GNU General Public License v3.0
0 stars 1 forks source link

Wrong usage of the absolute value of the spectrum #1

Open franchukpetro opened 2 years ago

franchukpetro commented 2 years ago

Hello!

I have noticed that your implementation of the ASF produces the wrong signal.

In case when all is fine (weighting matrix W is composed of only 1's, meaning that there are no noise components in the signal), ASF produces totally different signal. However, in this case, the signal should be identical to the input one, since the spectrum of the input signal is weighted with 1's, which actually does nothing.

I guess that is because of the abs() function in the 18's line: F = abs(np.fft.fft(C,n=L,axis=1)/L) #L -> C_rgb.shape[0]

I didn't see any abs() in the original pseudocode in the paper, however, I assume you add this to take the absolute value of the energy of the spectrum, to compare against amax value. You have done the comparison with the absolute values of the spectrum in the lines 21 and 24, so I guess the abs() in the line 18 is redundant (since you change the values of the spectrum, which you then try to weight).

Best regards, Petro

franchukpetro commented 2 years ago

Also, I think that in the line 24 abs() function is misused:

W[np.abs(F[0,:]<amax)] = 1

while actually should be:

W[np.abs(F[0,:])<amax] = 1