在opencv中计算通道的标准偏差

2024-06-16 12:14:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图计算两种颜色(如R和绿色)之间的比率,输入是使用opencv检索的相机图像,如果有正确的输入数据,我得到NAN

def slidingMovingAverageWindow(x,y, windowLength):
     xS = pd.Series(x)
     yS = pd.Series(y)
     stdX = xS.rolling(window = windowLength).std()
     stdY = yS.rolling(window=windowLength).std()

     ratio = np.sqrt(stdX/stdY)
     return ratio
def compute_ippg(signal): # using color chorme
    B, G, R = cv2.split(signal)
    cv2.imshow('Frame', B)

    # convert to chrome key
    xs = 0.77 * R[2,:] - 0.51 * G[1,:]
    ys = 0.77 * R[2,:] + 0.51 * G[1,:] - 0.77 * B[0,:]
    a = slidingMovingAverageWindow(xs, ys, 2)
    iPPG = xs - a* ys;
    return iPPG

窗口为2,您可以对任何图像进行测试,以获得R和G之间的比率

下面一行有问题

ratio = np.sqrt(stdX/stdY) of NaN

Tags: 图像def比率seriespdxsratiorolling