def calculateMean(self):
numSamples = self.trainNum
# OpenCV loads image as BGR order
B, G, R = 0, 0, 0
for idx in xrange(numSamples):
frameID = self.trainList[idx]
prev_img = frameID + "_img1.ppm"
next_img = frameID + "_img2.ppm"
source = cv2.imread(os.path.join(self.img_path, prev_img), cv2.IMREAD_COLOR)
target = cv2.imread(os.path.join(self.img_path, next_img), cv2.IMREAD_COLOR)
B += np.mean(source[:,:,0], axis=None)
B += np.mean(target[:,:,0], axis=None)
G += np.mean(source[:,:,1], axis=None)
G += np.mean(target[:,:,1], axis=None)
R += np.mean(source[:,:,2], axis=None)
R += np.mean(target[:,:,2], axis=None)
B = B / (2*numSamples)
G = G / (2*numSamples)
R = R / (2*numSamples)
return (B,G,R)
评论列表
文章目录