Python RGB像素差异功能错误

时间:2019-03-11 05:03:07

标签: python opencv image-processing rgb

嗨,我正在尝试做一个基本的RGB值差功能。 2 RGB像素阵列的基本减法,但大多数时候都是错误的,我也不知道为什么。像素都是openCV视频帧像素。

这是我的代码

def getRGBDiff(old,new):
    print("old : %s new : %s" % (old,new))
    diff = 0
    for i in range(3):
        print("old : %s new : %s" % (old[i],new[i]))
        val = old[i] - new[i]
        print("Diff : %d" % val)
        diff += abs(val)
        print("Cumulative Abs Diff : %d" % diff)

if(diff > 200):
    return diff , True
return diff , False

输出:

Image size is 1080x1920
old : [ 95 105 122] new : [ 91 104 132]
old : 95 new : 91
Diff :4
Cumulative Abs Diff :4
old : 105 new : 104
Diff :1
Cumulative Abs Diff :5
old : 122 new : 132
Diff :246
Cumulative Abs Diff :251
old : [ 93 103 120] new : [ 91 104 132]
old : 93 new : 91
Diff :2
Cumulative Abs Diff :2
old : 103 new : 104
Diff :255
Cumulative Abs Diff :257
old : 120 new : 132
Diff :244

Cumulative Abs Diff :501
old : [ 88  98 115] new : [ 93 106 134]
old : 88 new : 93
Diff :251
Cumulative Abs Diff :251
old : 98 new : 106
Diff :248
Cumulative Abs Diff :499
old : 115 new : 134
Diff :237
Cumulative Abs Diff :736

0 个答案:

没有答案