int weight = 0; Vec3i pixel = {0,0,0}; for(size_t index=0; index < singlePairFish->fishImgs.size(); index++){ pixel = (pixel * weight + curPixel) / (weight + 1); weight++; }