File size: 739 Bytes
39b4c8c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
import numpy as np
from scipy import signal
from .base import VHRMethod
class PBV(VHRMethod):
methodName = 'PBV'
def __init__(self, **kwargs):
super(PBV, self).__init__(**kwargs)
def apply(self, X):
r_mean = X[0,:]/np.mean(X[0,:])
g_mean = X[1,:]/np.mean(X[1,:])
b_mean = X[2,:]/np.mean(X[2,:])
pbv_n = np.array([np.std(r_mean), np.std(g_mean), np.std(b_mean)])
pbv_d = np.sqrt(np.var(r_mean) + np.var(g_mean) + np.var(b_mean))
pbv = pbv_n / pbv_d
C = np.array([r_mean, g_mean, b_mean])
Q = np.matmul(C ,np.transpose(C))
W = np.linalg.solve(Q,pbv)
bvp = np.matmul(C.T,W)/(np.matmul(pbv.T,W))
return bvp |