Blender comes bundled with numpy.
Image references have a property called
.pixels which you can turn into a numpy array of the same dimensions. Numpy does use overloaded operators for array math. The initial setup aside, you'll see it is quite close to what you were trying.
import numpy as np
img = bpy.data.images[img_name]
pixelsA = np_array_from_image('A')
pixelsB = np_array_from_image('B')
pixelsC = np_array_from_image('C')
pixelsD = (pixelsA + pixelsB + pixelsC) / 3
image_D = bpy.data.images['D']
image_D.pixels = pixelsD.tolist()
# then click in the UV editor / to update the view..to see the pixels of `D` updated
Maybe this will give enough insight, and push towards learning some numpy.
This does 'mix' btw..
I'm not sure about the algorithm for add.. (below shown using material rgb mix nodes)
it's not as simple as
a+b+c. maybe something like adding the smallest value of each array:
# add smallest element values
interim_1 = np.minimum(pixelsA, pixelsB)
pixelsD = np.minimum(interim_1, pixelsC)